Savestate: compact BlockAllocator serialization (section v2) - #21990
Open
Arkadyzja wants to merge 1 commit into
Open
Savestate: compact BlockAllocator serialization (section v2)#21990Arkadyzja wants to merge 1 commit into
Arkadyzja wants to merge 1 commit into
Conversation
Serializing the kernel memory block lists (userMemory, kernelMemory, volatileMemory) wrote a full Section header per block and re-zeroed each block's tag padding with strlen+memset on every save. Games keep on the order of a thousand blocks alive, so the per-block overhead is both measurable save time and wasted payload bytes. Zero-pad tags once at write time instead (Block constructor and SetAllocated), so the v2 form can store blocks raw: start, size, taken, tag - no per-block section machinery, no per-save tag scrubbing. Uninitialized padding still never reaches the stream, since every path that writes a tag now clears it first. v1 states still load through the old per-block-Section form, which is kept unchanged.
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.
What
Bumps the
BlockAllocatorsavestate section to v2 with a compact per-block serialization form, and zero-pads block tags at write time instead of on every save.Why
Serializing the kernel memory block lists (
userMemory,kernelMemory,volatileMemory) currently pays two per-block costs on every save:Section("Block", 1)header per block — games keep on the order of a thousand blocks alive, so this is a thousand section headers of pure overhead in time and payload bytes.strlen+memsetper block to zero the tag padding before writing it (needed becausetruncate_cpyleaves the padding uninitialized).How
Block's constructor andSetAllocated()nowmemsetthe whole tag before writing it, so tag padding is always zero by construction and can be stored raw. Every path that writes a tag clears it first, so uninitialized bytes still never reach the stream.start, size, taken, tag— no per-block section machinery, no per-save tag scrubbing.Compatibility
Sectionread path is kept unchanged, selected by the section version.