Randomize cache index for singleton allocations#1339
Draft
anti-morma wants to merge 1 commit into
Draft
Conversation
Contributor
|
@anti-morma please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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.
Fixes #1121.
What changed
Root cause
Large singleton allocations start on 64 KiB slice boundaries. A sequence of equally sized allocations can consequently map corresponding elements of every allocation to the same cache sets, causing severe conflict misses even though allocation itself is outside the timed region.
For the #1121 reproducer, all 1000 allocations were 64 KiB aligned before this change. With cache-index randomization, typically 10–24 of 1000 retain that alignment.
Results
Measured on an Intel Core i5-1235U, pinned to one CPU, using release builds from commit
a3ca0e5e:The mimalloc virtual allocation span remains 345 MiB before and after. A separate loop of 100,000 allocation/free pairs at the affected size remained approximately 0.044 s both before and after.
Hardware performance counters were unavailable on the test host because
perf_event_paranoid=4.Validation
4 5 2)git diff --check: passed