-
Notifications
You must be signed in to change notification settings - Fork 35
Clear tracker for the current pool on destroy #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear tracker for the current pool on destroy #759
Conversation
do we have any place where this was failing (without your change)? |
We do not parse logs in our CI tests. |
e14fcbd
to
abf8876
Compare
I do not understand why this logic is needed. I thought that |
The DevDax memory provider: and the file memory provider: do not support the |
I missed that (probably because I was on vacation), what is the reason for such a limitation? Does it mean that only jemalloc pool can be used today with these memory providers? |
Only the jemalloc pool or the course provider (#715 - hopefully it will be merged soon). |
The reason is to keep these providers as simple as possible. The course provider will take over the memory management for them. |
abf8876
to
34197ef
Compare
I look from the user perspective, does "keep these providers as simple as possible" mean that we simplify things for us (UMF developers) but complicate it for the users? Another question regarding correctness: when memory tracker is cleared? When the memory provider allocates a memory region it is added to the memory tracker, but if the pool implementation does not release memory back and relies on the fact that the memory provider implementation will release virtual memory mapping who will cleanup the memory tracker? If it is not done then it is an error, because after the memory provider is destroyed the virtual memory address range might be re-used by other memory providers and the same virtual memory region might be added to the tracker and it will fail because the same virtual memory region already presented in the tracker. |
34197ef
to
b147c91
Compare
Right. So I replaced it with clearing the tracker for the current pool - please re-review |
120b06d
to
3d3adf1
Compare
d7d4afd
to
04a55e3
Compare
Clear tracker for the current pool when destroying the pool |
I still think that not supporting free operation in the memory provider is weird:
Another consideration, I am working on the cache implementation for opened IPC handles, the cache is global and I need to remove entries from the IPC cache when the corresponding pool is destroyed. It looks like a similar problem. BUt I still think that in your case it is better to require free implementation in all providers. |
@vinser52 OK, let's move this discussion to #769. This PR is about clearing the tracker. Currently it is not cleared and this patch adds clearing the tracker. @vinser52 You have written recently:
So now the question is: should we clear the tracker or not? |
} | ||
#ifndef NDEBUG | ||
// print error messages only if provider supports the free() operation | ||
if (n_items && !upstreamDoesNotFree) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is upstreamDoesNotFree
needed for anything other than debug printing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, currently it is not. The tracker is cleared from all left non-freed pointers regardless of value of upstreamDoesNotFree
.
The general rule is that the tracker should always be cleared when some chunk is deallocated. Otherwise the state of the tracker is incorrect. Now regarding this PR: since file and DAX providers are already upstreamed to the main branch, this PR fixes the issue with the tracker. Yesterday we discussed this with @bratpiorka and agreed that while I disagree with the general design and we need design discussion on |
Yes, I agree. So you can approve or request changes to this PR. |
I approved, but maybe you can add a |
@vinser52 It seems that after the yesterday's discussion ( |
|
Clear tracker for the current pool on destroy. Do not print error messages if provider does not support the free() operation. Signed-off-by: Lukasz Dorau <[email protected]>
04a55e3
to
2766a21
Compare
@vinser52 TODO added. |
Clearing the tracker was a temporary solution and should be removed. The tracker should be cleared using the provider's free() operation. Replace clear_tracker_for_the_pool() with check_if_tracker_is_empty(). This patch reverts commit 2766a21 Ref: oneapi-src#759 Signed-off-by: Lukasz Dorau <[email protected]>
Clearing the tracker was a temporary solution and should be removed. The tracker should be cleared using the provider's free() operation. Replace clear_tracker_for_the_pool() with check_if_tracker_is_empty(). This patch reverts commit 2766a21 Ref: oneapi-src#759 Signed-off-by: Lukasz Dorau <[email protected]>
Clearing the tracker was a temporary solution and should be removed. The tracker should be cleared using the provider's free() operation. Replace clear_tracker_for_the_pool() with check_if_tracker_is_empty(). This patch reverts commit 2766a21 Ref: oneapi-src#759 Signed-off-by: Lukasz Dorau <[email protected]>
Clearing the tracker was a temporary solution and should be removed. The tracker should be cleared using the provider's free() operation. Replace clear_tracker_for_the_pool() with check_if_tracker_is_empty(). This patch reverts commit 2766a21 Ref: oneapi-src#759 Signed-off-by: Lukasz Dorau <[email protected]>
Description
Clear tracker for the current pool when destroying the pool
and clear the whole tracker when destroying the UMF library.
Print error messages about unfreed allocations left in the tracker
only if provider supports the
free()
operation.Checklist