Phase 11.10: diagnose + pad backend atomics for false-sharing - #63
Merged
Merged
Conversation
`BackendFragCounters::bytes_committed` + `bytes_decommitted_to_os` shared a cache line, as did `StatsRange::current_usage` + `peak_usage`. Every `notify_using` invalidated the line that the matching `notify_not_using` had just read, and the `current_usage`/`peak_usage` CAS dance bounced the line for no reason. Add `alignas(64)` to each global atomic so each lives on its own cache line. Cost: ~96 bytes of additional BSS per template instantiation. Correctness unchanged. Diagnostic write-up + recommended next steps in docs/heap-profiling-diagnostic-11-10.md.
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.
Summary
medium_allocs(~1.05) andmixed(~1.03): false-sharing on process-global backend atomicsBackendFragCounters(bytes_committed + bytes_decommitted_to_os) andStatsRange::Type(current_usage + peak_usage)alignas(64)to each atomic so each lives on its own cache lineClickUp
Test plan
-DSNMALLOC_STATS_BASIC=ON -DCMAKE_BUILD_TYPE=ReleaseDiagnostic
Full write-up:
docs/heap-profiling-diagnostic-11-10.md. Cost of padding: ~96 bytes BSS per template instantiation. Correctness unaffected.Follow-up if bench shows no improvement
File Phase 11.11 — disassembly diff (objdump -d) BASIC vs OFF on Allocator<...>::alloc to identify the actual hot-path delta. False-sharing was the highest-probability hypothesis; if disproved, codegen drift is next.