perf(viewer): avoid repeated spatial keys during markup restore

Merged
LO
20d ago
+344-27

Markup restore registered a mutation view, then read the symbolic parse cache without that binding. The viewport used the registered view, so the cache kept alternating bindings and rebuilding the sorted spatial-key digest. Restore now shares the viewport's binding. Numeric FNV preserves the existing 64-bit key value and removes per-character BigInt arithmetic; persisted keys need no migration.

The default annotation/grid parse still runs on ordinary Holter loads. The conservative source preflight skips provably empty restore work outside render, admits STEP escapes and live edits, and avoids an unused view when it can prove there is nothing to restore.

Scheduling and the queue regression

The dequeued head serialized candidate parsing behind the localStorage hash. That was a real behavior regression, exposed by drawingMarkupPersistencePrecedence.test.tsx. Final386 starts candidate parsing alongside hashing, keeps restore writes behind the precedence decision, and creates a restore-owned view after a negative hash decision. Both original precedence tests and the original fake-worker setup/release order pass unchanged in substance. A bare tryRestoreDrawingMarkup call retains requestParse=false and starts no worker.

D = model activation/effect; H = localStorage decision; P = a parse attempt subject to the existing RTC/cache/owner gates; V = a restore-owned view. Rlocal is at H; Rembedded waits for H=false and a matching parse.

Case, with H pending at DMainDequeued5390Hotfix a59Final386 (same NEW-3 runtime as d5)
LocalStorage markup, including a saved empty entryP at D alongside H; local restore at HNo P while pending; none after saved entry winsCandidate P alongside H, but V created earlyCandidate P alongside H, using only an existing V; local restore unchanged
Embedded markup onlyP alongside H; V after H=false; restore after both prerequisitesH=false before P: serializedP alongside H, but V created earlyP alongside H; V after H=false; same restore ordering as main
No markup, provably negative preflightRedundant P; unused V after H=falseSkip restore P/V after H=falseSkip restore P/VSkip restore P/V; independent overlay producers unchanged

If H already confirms a saved entry at activation, final removes the restore-path parse attempt that cannot contribute to a restore. Uncertain encoded sources still follow the candidate path. Holter admits the preflight and still registers a view; the measured win is shared-binding reuse plus numeric FNV, rather than skipping its normal overlay parse.

Untimed diagnostic, pending scoreboard confirmation

Exact base9eff0f8f3a versus final386a713177: three repetitions per source, each cold/warm1/warm2, 18 successful real-model opens. The fixture is the fetched public Holter model. All opens used hardware NVIDIA/lovelace/fallback=false; all cold paths used WASM, both warm paths used cache, and all warm2 opens adopted the snapshot. Cache-write and snapshot completion were confirmed for all six profiles.

Characters fed to the spatial-key FNV loop, measured by native-operation counters and verified against the actual served minified function in every sample:

OpenBase, repetitions 1 / 2 / 3Final, repetitions 1 / 2 / 3
Cold9,653,570 / 34,752,852 / 9,653,5702,896,071 / 2,896,071 / 2,896,071
Warm13,861,428 / 3,861,428 / 3,861,4281,930,714 / 1,930,714 / 1,930,714
Warm2, snapshot3,861,428 / 3,861,428 / 1,930,7141,930,714 / 1,930,714 / 1,930,714

Final BigInt64 operations: zero on all nine opens. The final branch retains the earlier03c/5390 branch's feed counts exactly; restoring parallel parse/hash kickoff gave back none of the counted saving in these repetitions. The base also changed, so no elapsed comparison with the older campaign is inferred. The cold outlier and the warm2 base case that already avoids repeated work are retained.

The capture runs from input arming through interactive plus a three-second tail. Counters identify work removed, not an end-to-end speedup. Actual profile launch loads were7.41,9.63,7.02,9.23,9.41,7.08; private Xvfb, unchanged Balanced profile and ifc-gpu-check throughout. Guard refusals at13.01/16.39 and the earlier setup failure are preserved. Completed profiles were retained; only remaining profiles resumed after rechecking identical artifact hashes. No exclusive idle-host or elapsed-speedup claim.

Both bundles were force-built and bound to successful original sourceUnchanged receipts. Actual served index/WASM hashes are recorded. The three internal WASM binaries differ only in embedded checkout-SHA strings: normalization in memory produces byte identity, and the geometry executable-code section hashes match. Served files were unmodified. Campaign artifacts include source-and-host.json, attribution-summary.json, native-frame excerpts, wasm-provenance.json and verified trace archives.

Validation and size

  • Final full four-shard viewer suite:22,752 passed,15 skipped,zero failed/cancelled. PC request auto-f750f34e4c104c30b0b0618c1d04e3a6, job72829317-a405-4e84-a1aa-1122cb96300b, exit0/sourceUnchanged=true.
  • Final full four-shard Node package suites:27,570 passed,142 skipped,two expected failures,zero unexpected failures;71/71 tasks,none cached. Script tests4,571 passed/20 skipped;history12,provenance269,API89 passed. Integration, real-WASM255 passed/one DuckDB skip,14 real diff comparisons,8 snap checks and the independent IfcOpenShell section oracle passed. Pop request auto-b5496b3bc8514434a0a08937a2fec966, job42ceb863-9c6f-4ff2-a9e7-12f7f8fd2a64.
  • Focused precedence/restore/reviewer differential:87 passed,zero skipped. The copied reviewer probe covers200k random UTF-16 strings,all single code units/carry pairs,a1M-character string,20k random maps and a200k-entry map against the BigInt original.
  • Full root typecheck,including4,853 test files/71 packages and root tsc tail;root lint;forced viewer build;all14 pre-handoff gates passed with zero skips. Corrected request auto-ff0a783c0e244a2684dc7bda8b8c2442, jobdc65f404-675e-4107-9808-ec617cf7b34c, exit0/sourceUnchanged=true. Prior failed/interrupted receipts remain in the campaign log and are not counted as passes.

Qualified eager JS18,047,376 bytes versus exact base18,046,318: own delta+1,058,headroom29,505 below unchanged allowed18,076,881. CI measured18,047,418,headroom29,463. No ceiling changes or trimming.

Source CI run42934333022 passed Changed tests observe production,Perf ratchet ceilings,Typecheck,Lint,Node guards and the Build aggregate. Later metadata-only skips are not additional passes. Required gates remain enabled. Review questions are answered; the zero-source finding was rebutted with actual parser/compression/reader fixture output and resolved. Non-required review quota absence is not used as acceptance.

Keep unqueued; the orchestrator owns queueing. All requested final-head functional checks and three-repetition attribution are complete. End-to-end load-time confirmation remains with the exclusive scoreboard.