perf: drain initial wall builds within the time budget (charter row 6) - #800
Merged
Conversation
|
I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…). Please try again, rephrase, or reach out if it keeps failing. Error id: d08da89a-c471-4f51-ab16-816f2435e6c2 |
wass08
force-pushed
the
perf/initial-load-drain
branch
from
September 10, 2026 13:47
52b1b5b to
54cedd9
Compare
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.
Metric
Maxi 8× time-to-first-clean after load (charter backlog row 6; the row's
settled < 8 starget contains a 3 s runner quiet window, so the runner now reportsfirstCleanMsalongside it).Three back-to-back PR-vs-main pairs, same machine (a fourth under load average 21–24 discarded as starved); third pair = this tip:
What changed
setScene's hydration token and left on the first frame with no dirty wall and an empty pending-neighbour queue (a document write, live override/transform, or canvas pointer/wheel ends it early). Exposed read-only viaisWallInitialBuildActive().__pascalPerf.batchStats().wallDrain(walls consumed per frame, exit reasons, pending-neighbour length, first-build vs re-invalidation) and awall-initial-buildspan.Gates
--randomize --seed=1);tsc --noEmitcore/viewer/nodes clean; biome clean.?perf-gated, allocation-free diagnostics) plus a pre-existing core test-fixture ordering flake fixed (three seeds green).wiki/architecture/systems.mddescribes the initial-build scheduling.Charter:
plans/performance/editor-scalable-scene-runtime.mdrow 6 (private PR follows with the evidence row and the runner's first-clean / undo-phase sampling).🤖 Generated with Claude Code
https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
Note
High Risk
Touches core scene load/hydration, undo/history boundaries, and wall rebuild scheduling—incorrect token or invalidation timing could cause wrong geometry, stalled loads, or extra full-level invalidation after edits.
Overview
Introduces a scene hydration boundary around
setScene: elevator opening sync runs synchronously, stair rise/opening normalization is queued on microtasks, and ahydrationTokenis published only after that work finishes. Document writes outside normalization atomically cancel pending publication or clear an issued token; live overrides/transforms and canvas pointer/wheel also end hydration early.applySceneSnapshotnow clears live maps before replacing the scene.Initial wall build follows that token: walls drain under the existing 8 ms frame budget without the interactive 8 walls/frame cap (heavy walls still get a dedicated frame), and each wall’s first build skips neighbour re-invalidation while hydration is active. A canvas-level lifecycle owner tracks drain state across lazy
WallSystemmounts, exposesisWallInitialBuildActive(), and adds optional?perfwall-drain counters. Stair auto-sync defers throughqueueSceneNormalizationso it participates in the same boundary.Fixes hydration invalidation happening as a nested write (which could double space reconciliation on the first post-load edit). Docs and broad lifecycle tests cover interruption, late system mount, and pending-neighbour behaviour during drain.
Reviewed by Cursor Bugbot for commit 54cedd9. Bugbot is set up for automated code reviews on this repo. Configure here.