Repository navigation
bugfix(gamememory): Align memory pool allocations to 8 bytes - #637
Open
tintinhamans wants to merge 1 commit into
Open
tintinhamans wants to merge 1 commit into
tintinhamans wants to merge 1 commit into
Conversation
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.
The memory pools put a 12 byte header in front of each block and round sizes to 4, so the engine's
operator newreturns pointers that are 4 mod 8 about half the time. MSVC promises 8 on x86, and the original code already had a@todo srj -- make this work for 8on it.protobuf relies on that:
RepeatedFieldkeeps flags in the low bits of its heap pointer, so on our heap it frees a pointer 4 bytes early. That crashed GNS, which is linked into the exe. DLLs use their own CRTnewand are not affected.MEM_BOUND_ALIGNMENTis now 8 and the header (plus the leading wall in debug) is padded to a multiple of 8 in one place,SINGLEBLOCK_USERDATA_OFFSET. Debug builds assert the alignment, and the pool size asserts compare against the rounded size. The blob count check keeps its 4, that rule is about pool counts, not alignment. Both the Generals and Zero Hour copies are changed.This costs about 4.5 MB (~8%) of initial pool memory on Zero Hour, measured on upstream's pool tables. Nothing in the simulation orders or hashes by pointer.