Skip to content

[re-un-revert] Replace per-save-point array snapshots with an undo trail - #889

Merged
natecook1000 merged 1 commit into
mainfrom
savepoint-simplify-attempt-3
Sep 30, 2026
Merged

natecook1000 merged 1 commit into
mainfrom
savepoint-simplify-attempt-3

Conversation

@natecook1000

Copy link
Copy Markdown
Member

Third and final* attempt to land the work originally in #870…

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.
@natecook1000
natecook1000 marked this pull request as ready for review September 30, 2026 00:23
@natecook1000
natecook1000 merged commit a6ac4f7 into main Sep 30, 2026
24 checks passed
natecook1000 added a commit to swiftlang/swift that referenced this pull request Sep 30, 2026
@natecook1000
natecook1000 deleted the savepoint-simplify-attempt-3 branch September 30, 2026 17:05
Teemperor pushed a commit to Teemperor/swift-mono that referenced this pull request Sep 30, 2026
=== swift ================================================
Add UndoableArray.swift to Runtime CMakeLists (Issue/PR 92749)
For coordination with
swiftlang/swift-experimental-string-processing#889.

=== swift-experimental-string-processing =================
[re-un-revert] Replace per-save-point array snapshots with an undo trail (Issue/PR 889)
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant