Replace per-save-point array snapshots with an undo trail - #870
Open
natecook1000 wants to merge 1 commit into
Open
Replace per-save-point array snapshots with an undo trail#870natecook1000 wants to merge 1 commit into
natecook1000 wants to merge 1 commit into
Conversation
Creating a save point previously copied the four mutable register arrays (ints, positions, values, and storedCaptures) to enable restoration during backtracking. This led to a large amount of reference counting traffic and copy-on-write of the original register arrays whenever they were updated. This change moves the restoration data from using full copies of each array in every save point, to tracking a log of the changes to each array in the processor itself and only storing the current state of the logs in each save point. This allows `SavePoint` to be a trivial type (almost) and removes all the copy-on-write traffic. Backtracking now uses the tracking logs to unwind the registers to the specific previous state. This change also includes a minor refactor, moving the `storedCaptures` array to the `Registers` struct, alongside the other mutable registers. Future work includes breaking out the mutable registers into their own type, creating a flat structure for these instead of maintaining four different dynamically allocated arrays, and moving further toward making `SavePoint` trivial.
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.
Creating a save point previously copied the four mutable register arrays (ints, positions, values, and storedCaptures) to enable restoration during backtracking. This led to a large amount of reference counting traffic and copy-on-write of the original register arrays whenever they were updated.
This change moves the restoration data from using full copies of each array in every save point, to tracking a log of the changes to each array in the processor itself and only storing the current state of the logs in each save point. This allows
SavePointto be a trivial type (almost) and removes all the copy-on-write traffic. Backtracking now uses the tracking logs to unwind the registers to the specific previous state.This change also includes a minor refactor, moving the
storedCapturesarray to theRegistersstruct, alongside the other mutable registers. Future work includes breaking out the mutable registers into their own type, creating a flat structure for these instead of maintaining four different dynamically allocated arrays, and moving further toward makingSavePointtrivial.