feat: add direct rewind materialization fast path#123
Merged
Antonov548 merged 13 commits intomainfrom Apr 21, 2026
Merged
Conversation
This was referenced Apr 17, 2026
df92cf5 to
0f59afb
Compare
Antonov548
approved these changes
Apr 21, 2026
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
#120's frontier model with a direct rewind/replay fast path for common out-of-orderinsert/move/payloadappendsdelete/tombstoneon the conservative replay-from-frontier path for nowWhy
After
#120, materialization state is explicit (head + replay_from) and out-of-order remote ops no longer use a coarse dirty flag.This PR improves the normal catch-up path for common out-of-order sync cases.
Instead of deferring those cases to a later read and replaying broadly from the op log, append-time catch-up now:
oprefs_childrenWhat Changes
For common out-of-order
insert/move/payloadappends, the normal path no longer relies on:A narrow payload shortcut also remains in place for dominated out-of-order payload ops that do not change materialized payload state.
Fallback Behavior
This PR is intentionally conservative for the annoying cases:
deleteortombstone, append falls back to the existing replay-from-frontier catch-up pathensure_materializedrecovery still uses the conservative replay pathSo the fast path is targeted at the common structural/payload out-of-order cases, while delete/revival semantics stay on the safer route.
Backend Changes
Postgres
PgOpStoragesqlite
SqliteOpStorageTests
Verified locally with:
cargo test -p treecrdt-core --test materialization_helperscargo test -p treecrdt-postgres --test postgres_testcargo test -p treecrdt-sqlite-ext --features ext-sqlite --test extension_roundtrippnpm run clippypnpm -C examples/playground typecheckpnpm -C examples/playground buildThe shared backend conformance suite covers:
ensure_materializedrecovery