Repository navigation
Coalesce relationship sync events + O(1) parent index to unblock the UI during a large pull (#1673) - #1680
Merged
mstomar125 merged 1 commit intoJul 16, 2026
Conversation
… the UI during a large pull During the initial pull of a populated tenant the daemon floods the WatchNodes stream and the webview applied each event synchronously: every has_child relationship event ran an O(N) parent scan and copied the whole children map (a global reactive invalidation), so a 39k-edge burst was O(N^2) on the main thread and the app sat unusable on "Loading…". - reactive-structure-tree.svelte.ts: reverse child->parent index makes getParent O(1) (verified against the children map, self-healing on a miss); runBatch() applies a burst of ops under a single notifyChange. - tauri-sync-listener.ts (Pro path): buffer has_child relationship events over the existing 16ms coalescing window and flush them through one runBatch (arrival order preserved, so create/delete of the same edge in a window resolves exactly as un-coalesced); chunk the node-fetch flush (200/chunk) with a main-thread yield and a per-chunk epoch re-check, and guard against overlapping flushes sharing tombstone state. Community build unchanged: non-Pro relationship events still apply synchronously per event. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
Author
|
APPROVE (adversarial re-review) Tried hard to break it across all 7 surfaces; no correctness defect found. All 19 new tests pin the claimed behaviors and pass (123 tests green in the affected suites).
Nits only (non-blocking): runBatch assumes a synchronous mutate (sole caller is sync); reparent-prune now depends on index accuracy (safe — children is never externally mutated); +16ms latency on Pro has_child events (intended, symmetric with the node coalescer). Ship it. |
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
Fixes #1673 — the round-1 P0 where the app is unusable during the initial cloud-sync pull of a populated tenant (24,197 nodes / 39,183 relationships): the daemon floods the WatchNodes stream (69× "subscriber lagged; events dropped") and the webview applied each event synchronously. Every
has_childrelationship event ran an O(N) parent scan and copied the entire children map (a global reactive invalidation), so a 39k-edge burst was O(N²) on the main thread — the app sat on "Loading…".Changes
reactive-structure-tree.svelte.ts— a reverse child→parent index makesgetParentO(1) (verified against the children map, self-healing on a miss so a stale entry can't return a wrong parent). NewrunBatch()applies a burst of ops under a singlenotifyChangeinstead of one per op.tauri-sync-listener.ts(Pro path) — bufferhas_childrelationship events over the existing 16 ms coalescing window and flush them through onerunBatchin arrival order (so create/delete of the same edge in a window resolves exactly as un-coalesced). Chunk the node-fetch flush (200/chunk) with a main-thread yield and a per-chunk epoch re-check, plus a reentrancy guard so overlapping flushes can't share tombstone state.Community build unchanged
Non-Pro relationship events still apply synchronously per event (a dedicated guardrail test asserts this);
free-user-guardrail.test.ts11/11.Tests
+19: single
notifyChangeper burst; O(1)getParentasserted via a counting map (zero full-map iterations over 500 calls); create→delete and delete→create ordering both ways; per-chunk epoch drop on a mid-flush database switch; reverse-index consistency across add/remove/reparent/clear/restore. Full frontend suite 4079 green; svelte-check 0 errors; eslint/prettier clean.Companion: the daemon-side double-spawn + startup-progress work is nodespace-sync#324 (progress
detailrenders here). Round-1 evidence:validation-round1/reports/val-P0-ui-blocked-during-sync.md.🤖 Generated with Claude Code