Repository navigation
a write snapshots only what it changed; a clean state resolves its saved epoch once - #70
Merged
Merged
Conversation
…ved epoch once Two costs that grew with every registered state, measured in Toad's Qt client: - record_snapshot found which clean scopes share an object with a changed one by deep-copying every registered state's values on every write, though it copies only the changed ones. Each scope now keeps the objects its values reached when it was last captured (SnapshotReach, which holds them so their ids stay theirs). A scope left clean keeps that capture in the next snapshot and reaches the same objects, so only the scopes being captured are walked. A clean scope that shares an object with one of them is still captured with it, and time travel forgets what scopes reached, since restored scopes hold copies. - A state opened or saved under ancestors holding exactly their saved parameters resolved every field twice in __init__ (live, then saved) and again in mark_saved. While this state and every registered ancestor are not raw-dirty, both epochs read the same values, so the saved epoch is the live snapshot, copied as the saved parameters are (a live value changed in place stays dirty). Otherwise it is resolved on its own, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…d name, one long line wrapped Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
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.
Summary
This removes two objectstate costs that grew with every registered state: one paid on every write, one on every state opened.
1. A write's snapshot walked every state
_record_snapshot_internalcopies only the changed scopes. To find which clean scopes share an object with them, though, it deep-copied every registered state's values on every write. Most of a write's snapshot time went there (in Toad's Qt client at phone speed,object_state_registry.py:1269was the largest line underupdate_parameter).SnapshotReach. Each scope now keeps the objects its values reached when it was last captured, together with that capture. It holds those objects, so their ids can't be reused by other objects while the entry lives. Without that, a freed metadata copy's id was taken by a new object and made two independent scopes look shared.test_alias_graph_is_detached_and_restored_across_scopes_and_saved_livetest covers this.clear()does too.2. A clean state resolved every field three times
ObjectState.__init__resolved every field for the live epoch, then again for the saved epoch, andmark_savedresolved the saved epoch once more. Every view Toad opens over saved settings takes this path._saved_resolved_snapshotchanges that. While a state and every registered ancestor hold exactly their saved parameters (none isis_raw_dirty), both epochs read the same values. In that case the saved epoch is the live snapshot, copied the way saved parameters are, so a live value changed in place still shows as dirty. Otherwise it is resolved on its own, as before.Why a write re-derives every view (not changed here)
Invalidation was already scoped by scope, type and field. In Toad, every view's configuration is a lazy copy of the whole settings tree that inherits every field it doesn't set. So a global write really does change every open view's resolved value, and each view is a true dependent.
What made a write expensive was work proportional to everything registered, not to the dependents:
Measured in Toad's Qt client
qt_drive drag_speed, at phone speed (45% of one core), 3 runs per tree, median. The release carries one settings write.ObjectConfigurationbuilds it (unthrottled, median of 5):Tests
test_a_snapshot_walks_only_the_scopes_it_captures:test_a_state_opened_under_saved_ancestors_resolves_its_saved_epoch_as_its_live_one:🤖 Generated with Claude Code
https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3