Skip to content
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

Third attempt at refactoring garbage collector #1184

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

stevenmeker
Copy link
Collaborator

@stevenmeker stevenmeker commented Dec 10, 2024

The condition for requesting collections is replaced by requesting a collection
if an allocation passes a tripwire. This tripwire is initially set at MIN_SPACE
and is recalculated after each garbage collation as max(MIN_SPACE, |live data|).

This avoids a potential issue with the old behavior where collections were
trigged by allocating in the last 1 MB of previously allocated semispace, even
if little garbage is being generated, or not collecting frequently enough if
a period of low garbage generation is followed by a period of high garbage
generation, affecting cache performance.

Furthermore, garbage collections are only trigged by allocations in youngspace.
Allocations in oldspace no longer trigger collections since oldspace collections
are handled during a youngspace collection.
Allocations in alwaysgcspace no longer trigger collections since collection
of this space is handled outside of the main garbage collector.

Some class arena member functions have the arena_ component removed as superfluous.

@rv-jenkins rv-jenkins changed the base branch from master to develop December 10, 2024 22:15
@dwightguth
Copy link
Collaborator

This code tries to make collections happen more frequently when the live memory shrinks in order to improve cache performance of the garbage collector. It would be helpful before we merge this to see data about gc throughput to determine whether we see any regression that might be caused by the data not bearing out that assumption.

@stevenmeker
Copy link
Collaborator Author

Actually I got the formula wrong in the description - the tripwire is set to max(MIN_SPACE, EXPAND_FACTOR * |live data|). I set EXPAND_FACTOR = 2 but this could well be too low - I don't think you'd want to go any lower. An alternative would be to track the largest value of |live data| seen in collections to date and multiply this by EXPAND_FACTOR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants