Randomize cache index for singleton allocations - #1339
Randomize cache index for singleton allocations#1339Alessandro Mormandi (anti-morma) wants to merge 1 commit into
Conversation
|
Alessandro Mormandi (@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”),
|
|
I like this :-) But also I think it is implemented at the wrong level. Maybe we can look at applying this for the |
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