-
Notifications
You must be signed in to change notification settings - Fork 1.9k
do a cyclic scan for orphan objects in zstd memory pool #10969
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
Conversation
Why is that? Do we know? Don't we care?
This seems a bit hacky IMHO. Wouldn't the proper fix be to investigate why the memory ends up orphaned in the first place and ensure it doesn't? |
@mschilli87 let me explain. right now with regular use, the pool is checked for old objects on each allocation attempt from this pool. so basicly polling by its use. now consider what happens if someone writes alot of files and stops use of the volume or even unmounts it. so the code will no longer check if objects can be released from the pool. so what has been allocated still stays in pool cache. this is no big issue for common use. but someone discovered this issue while doing tests. personally i know this behaviour and i'm aware of it. its no big issue. just a enhancement. see also #10938 |
@BrainSlayer: Thank you for the explanation. My two cents:
|
copied the my explaination to the title. will add it later to the commit message after testrun is done regarding the check procedure. zstd is just a algorithm. it doesnt know of any higher level operation and does not know if a volume is in use, mounted or unmounted. the pool is also not used per volume, but used for the algorithm which can be used by multiple volumes of course. and yes the polling remains also if all is freed. but it only happens once in a minute and does not cause any measureable performance impact since the code which is executed is very small for checking. forget about thinking in volumes. just think about a compression algorithm which is available globally for everything you do. the case i mentioned was just a example. if a any volume is in use and you just dont write or isnt in use, the preallocated ram stays allocated without that patch. so its basicly just a optimization to reduce memory usage if everything related to zstd is in idle state. of course i can stop the thread after nothing is left and restart it on first new allocation. but this is a more complicated handling and may cause a latency spike on first allocation attempt. keep it simple as possible is the best way from my oppinion. stopping and restarting threads needs also special handling to avoid race conditions in this threaded context. the current simple approach is thread safe |
That's a good enough explanation for me, as long as it makes it into the commit message and/or a comment in the source code itself. Thanks for taking the time to walk me through. |
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.
Looks good with a slight nitpick on the note not refering to the 60 seconds.
Ping for @c0d3z3r0 and @allanjude to check this out if they want.
d2c8cf8
to
81ae20e
Compare
ISTM that this is the wrong approach. We know when an objectset is removed from the system (umount, destroy, close) and we already have async clean to clear its data from ARC. Why not just extend it to also clear out the zstd memory pool? |
This is a pool of memory allocations used for compression. It is not tied to any specific objset. It is just that after a period of high activity, the amount of memory used by this pool may be high, and it doesn't shrink when there is no activity. |
@allanjude: That is what confused me at well until @BrainSlayer explained it. I think this whole discussion just stresses that the change suggested here should come with good documentation. |
circular dependency. no call to zstd code can be made from functions within zfs. zzstd must be loaded before zfs is loaded. such solutions are only possible with installable hooks |
according to what he wrote, he did understand very well how it works. |
This comment has been minimized.
This comment has been minimized.
2b289f3
to
be616dc
Compare
@behlendorf please check the new solution for handling the memory cleanup. |
7f2dd02
to
592ba61
Compare
211545a
to
aa33676
Compare
@behlendorf regarding the way when to reclaim space and when not. the pool allocator is self managing. waiting until memory is low, if avoidable is not a good way from my point of view. in our testcase we had about 1.5 gb unused memory left. thats no small piece. releasing it if not in use for a while avoids such situations which will slow down zfs. so if avoidable without performance impact is a good approach |
aa33676
to
624c1aa
Compare
in non regular usecases allocated memory might stay persistent in memory pool. this small patch checks every minute if there are old object which can be released from memory pool. right now with regular use, the pool is checked for old objects on each allocation attempt from this pool. so basicly polling by its use. now consider what happens if someone writes alot of files and stops use of the volume or even unmounts it. so the code will no longer check if objects can be released from the pool. already allocated objects will still stay in pool cache. this is no big issue for common use. but someone discovered this issue while doing tests. personally i know this behaviour and i'm aware of it. its no big issue. just a enhancement Signed-off-by: Sebastian Gottschall <[email protected]>
624c1aa
to
7ca1fdd
Compare
In non regular use cases allocated memory might stay persistent in memory pool. This small patch checks every minute if there are old objects which can be released from memory pool. Right now with regular use, the pool is checked for old objects on each allocation attempt from this pool. so basically polling by its use. Now consider what happens if someone writes a lot of files and stops use of the volume or even unmounts it. So the code will no longer check if objects can be released from the pool. Already allocated objects will still stay in pool cache. this is no big issue for common use. But someone discovered this issue while doing tests. personally i know this behavior and I'm aware of it. Its no big issue. just a enhancement Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Kjeld Schouten-Lebbing <[email protected]> Signed-off-by: Sebastian Gottschall <[email protected]> Closes #10938 Closes #10969
In non regular use cases allocated memory might stay persistent in memory pool. This small patch checks every minute if there are old objects which can be released from memory pool. Right now with regular use, the pool is checked for old objects on each allocation attempt from this pool. so basically polling by its use. Now consider what happens if someone writes a lot of files and stops use of the volume or even unmounts it. So the code will no longer check if objects can be released from the pool. Already allocated objects will still stay in pool cache. this is no big issue for common use. But someone discovered this issue while doing tests. personally i know this behavior and I'm aware of it. Its no big issue. just a enhancement Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Kjeld Schouten-Lebbing <[email protected]> Signed-off-by: Sebastian Gottschall <[email protected]> Closes openzfs#10938 Closes openzfs#10969
In non regular use cases allocated memory might stay persistent in memory pool. This small patch checks every minute if there are old objects which can be released from memory pool. Right now with regular use, the pool is checked for old objects on each allocation attempt from this pool. so basically polling by its use. Now consider what happens if someone writes a lot of files and stops use of the volume or even unmounts it. So the code will no longer check if objects can be released from the pool. Already allocated objects will still stay in pool cache. this is no big issue for common use. But someone discovered this issue while doing tests. personally i know this behavior and I'm aware of it. Its no big issue. just a enhancement Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Kjeld Schouten-Lebbing <[email protected]> Signed-off-by: Sebastian Gottschall <[email protected]> Closes openzfs#10938 Closes openzfs#10969
in non regular usecases allocated memory might stay persistent
in memory pool. this small patch checks every minutes if there are
old objects which can be released from memory pool.
right now with regular use, the pool is checked for old objects on each allocation attempt from this pool. so basicly polling by its use. now consider what happens if someone writes alot of files and stops use of the volume or even unmounts it. so the code will no longer check if objects can be released from the pool. so what has been allocated still stays in pool cache. this is no big issue for common use. but someone discovered this issue while doing tests. personally i know this behaviour and i'm aware of it. its no big issue. just a enhancement. see also #10938
covers #10938
Signed-off-by: Sebastian Gottschall [email protected]
Motivation and Context
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.