-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Do not mark a page with any live object as GC_MARKED during quick sweep #13993
Conversation
280d694
to
9f25f60
Compare
Also updated the free page fast path logic since |
sorry for the lag. Yep the logic was flawed here, thanks for continuing to give this code the review time it probably lacked before the merge :-) This fix should work but IIUC we are losing some of the fastpath advantage. I vaguely remember discussing this with you in person, but we should probably move away from the weird sweep-mark-sweep old gen collection. The easiest would be to have a flag that basically says "interpret GC_MARKED as GC_QUEUED for now". It looks like it would allow us to get rid of the sweep_mask things and probably clean up the code a little bit since all sweeps are now the same. I didn't think this through yet. Thoughts ? |
Which fast path? (old page with no new objects?)
I think that could work but I also need to think about it more. We still need to distinguish bewteen for states during the full collection so I guess we could just flip the meaning of |
yep, we'll be sweeping it for nothing on the first quick sweep after a long one right ? The more I think about it the more I like the flag thing : mark: (same as now) sweep: flip: (semantically, really we only flip a flag) We get rid of sweep_mask. I think we can also get rid of the "pre-sweep memory accounting" ugliness since we can decide to flip the flag after the sweep when we know the correct memory stats. Let's see if this still sounds legit after a couple cups of coffee :-) |
strike that, since
oh well. |
So we do you want to flip the meaning and when do you decide whether a full collection is necessary? I think the flip shouldn't last longer than a full collection because the WB won't be accurate otherwise. (therefore the (only and last) sweep in the full collection should fix it back). And since we are not walking though the |
also, this does not solve the problem that this PR is addressing since we can't know if a page had all it's queued cells marked after the mark phase. |
I'm not sure I understand the point about the WB. In what I had in mind, the WB code also uses the flag to correctly recognize if a specific bit pattern happens to mean gc_queued or gc_marked at the moment. In fact, I think it's equivalent to separating full sweeps into two "phases" where the first one is a quick sweep and the other one is something that happens to be implementable without walking the heap at all. (in this scheme, the fact that a sweep is long or short only depends on the pg_gc_bits optimization) |
I'm hoping that we don't need to change the WB code..... Will this make it more expensive since we need to read a global variable everytime? |
Yep. We could mitigate this a little by doing a first check |
What about |
Bump, is this still needed? |
Yes but shouldnt hold up the next 0.4 release |
9f25f60
to
22415b2
Compare
Bump again, why hasn't this been merged into master yet? |
There could be young objects in it! Also update the logic for free page fast path since the page gc bits could be GC_QUEUED after this change.
22415b2
to
f2a0f51
Compare
Bump. |
Replacement coming soon. |
There could be young objects in it!
This fixes the memory leak for my minimum repro in #11814 (comment). I have yet to check if this actually fix
(github don't close it yet)#11814 itself.@carnaval
design note for a alternative scheme that also solves this issue