Repository navigation
Omit redundant buffer padding for aligned element types - #69
Merged
Merged
Conversation
Closed
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
Avoid allocating two extra elements when the element alignment already separates the buffer from adjacent allocations. This completes the remaining optimization requested in #30; its redundant trailing-padding cleanup was already applied in 1053918.
Add coverage for alignment equal to and greater than the false-sharing range, plus a same-sized type with weaker alignment that must retain padding. Verify exact allocation counts, overflow boundaries through both allocator paths, element alignment, FIFO/full/empty behavior across wraps, and deallocation. Use std::allocator in the tracking allocator so the tests support over-aligned elements.
Fixes #30.
Evidence
CHECK(requested == expected).After: Full test suite passes in Debug and Release with GCC 16.2.1, and with AddressSanitizer/UndefinedBehaviorSanitizer.
git diff --checkpass.Merge Danger
Door: two-way
Blast Radius: allocation
Queue storage allocation sizes change for sufficiently aligned element types. Public capacity and synchronization remain unchanged. Custom allocators must honor the element type's alignment requirement.