Align buffer blocks in saved state. #1240
Closed
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.
This wastes some bytes for the rare irregular buffer, but it opens up the possibility of running block-based deduplication that reaches across multiple large system components. For example, we can detect when a block from disk has one or more copies in main memory.
In a small experiment I ran to choose an optimal block size for memory blocks, I found 512 was the best (balancing frequency of block repetition with the storage needed to store block ids). However, a block size of 256 was nearly as good. Further, this block size matches the one used in the Buffer system for caching lazily loaded disk blocks. As a result, it seems like the best overall choice.
Context: I'm working towards losslessly compressing a sequence of savestates to create a video-like record of interactive performances. If potentially repetitive elements of state files are block-aligned, I can blindly deduplicate saves without inventing a new storage format.