Repository navigation
Conversation
Free pages awaiting QSBR are added to each thread's `mimalloc.page_list`. The list is only drained if the owning thread needs new pages, performs an allocation larger than mimalloc's medium-object limit, or the thread exits. This means that we don't free pages if a thread's allocation pattern quiesces or falls into a pattern that can be serviced by existing pages. This can be problematic for threads that allocate a bunch of memory and then settle into the previous pattern.
Add _testinternalcapi.get_qsbr_page_list_length(), which counts the pages on all threads' QSBR page lists, and use it to check that gc.collect() frees empty pages parked by the calling thread and by an idle thread. Also check that the GC skips thread states that have not initialized their mimalloc state yet.
mpage
force-pushed
the
gh-158972-drain-page-list
branch
from
October 21, 2026 23:40
d28e6a5 to
d689f54
Compare
mpage
marked this pull request as ready for review
October 22, 2026 17:20
corona10
reviewed
Oct 23, 2026
corona10
left a comment
Member
There was a problem hiding this comment.
Hmm let me take a look also!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Free pages awaiting QSBR are added to each thread's
mimalloc.page_list.The list is only drained if the owning thread needs new pages, performs
an allocation larger than mimalloc's medium-object limit, or the thread
exits. This means that we don't free pages if a thread's allocation
pattern quiesces or falls into a pattern that can be serviced by
existing pages. This can be problematic for threads that allocate a
bunch of memory and then settle into the previous pattern.
It's worth noting that this may increase GC pause times, though it's not clear
by how much. There are a few alternatives if folks are concerned about overhead:
page_listif over a certain size threshold.page_liston manual calls togc.collect.