Trigger multiple GC sweeps between samples/trials instead of a single sweep #22
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.
If a benchmark is "slow" (e.g. doesn't require multiple evaluations per sample to overcome timer error) then it's likely worth it to run GC between samples (a feature which is normally turned off by default).This PR originally sought to make GC behavior more stable when running many benchmarks in succession by finding more conditions in which GC should be manually triggered. However, it turns out that
gc()only triggers a single sweep, meaning that young objects don't get freed (just marked, I'm guessing). Doing multiple sweeps every time we manually trigger GC does a much better job of freeing stale objects leftover from previous benchmarks.This PR replaces manual calls to
gc()with calls togcscrub = (gc(); gc(); gc(); gc()). Four sweeps might be overkill, but I'm unsure of how many "marking levels" exist between object youth and object freeing in a general case.Thanks to @vchuravy for suggesting I play around with using multiple sweeps.