Savestate: store only live audio queue data (AudioChannel section v3) - #21989
Open
Arkadyzja wants to merge 1 commit into
Open
Savestate: store only live audio queue data (AudioChannel section v3)#21989Arkadyzja wants to merge 1 commit into
Arkadyzja wants to merge 1 commit into
Conversation
FixedSizeQueue::DoState serializes the entire fixed backing store. For the sceAudio channel queues that is 512KB per channel (32768*8 s16 samples), or ~4.6MB of mostly dead bytes in every savestate across the nine channels - the live sample count at any moment is normally a few KB. This addresses the existing TODO in DoState. Add DoStateCompact(), which stores only the live [head, head+count) region and restores it linearized at the front of storage. A wrapped live region is written as its two pieces in pop order; since the POD DoArray path writes raw bytes with no per-element or per-call header, the single linear read on load consumes them identically. The count is validated on load and a bad value fails the load cleanly via p.SetError. AudioChannel bumps its section to v3 to use the compact form; old states still load through the unchanged full-storage path. This shrinks every savestate by several MB uncompressed and cuts the copy/compress cost of each save, including the rewind feature's periodic states.
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
Adds
FixedSizeQueue::DoStateCompact()and bumps theAudioChannelsection to v3 to use it. This addresses the existing TODO inFixedSizeQueue::DoState:Why
DoStateserializes the entire fixed backing store. EachsceAudiochannel queue isFixedSizeQueue<s16, 32768 * 8>= 512KB, and there are nine of them — ~4.6MB of almost entirely dead bytes in every savestate, while the live sample count at any moment is typically a few KB. That's wasted memcpy, wasted compression input, and wasted size in every save — manual saves, save slots, and the rewind feature's periodic in-memory states alike.How
DoStateCompact()stores only the live[head, head+count)region:DoArraypath writes raw bytes with no per-element or per-call header, so the concatenation is byte-identical to a single linear write of the logical queue contents.head = 0,tail = count % N), which is an equivalent queue state.p.SetError()instead of desyncing the stream.The old full-storage
DoState()is untouched; the two formats are not interchangeable, so callers opt in via their own section version — whichAudioChannel(the only caller changed here) does with v3.Compatibility
AudioChannelsections) load exactly as before through the full-storage path.