perf(viewer): hand the entity index to the parser the moment it exists

Draft
LO
13d ago
+39-5

On cold loads of files of 32 MB and up, the viewer held the geometry pre-pass's entity index back from the parser worker until a geometry worker had finished, the stream completed, or 8 ms per MB had passed. This change hands the index over as soon as it exists, at every size.

Why now

The hold was added in #3921 to give geometry a head start and to keep parser allocations from overlapping the geometry pool's peak. Since the cold-finalize work (#9684, #9747), the hold no longer makes metadata wait off to the side. It pushes metadata into the renderer finalize. Timed figures come from the scoreboard, main+#9684+#9747 (000532b2cc), 5 rounds, exclusive admission:

  • Holter: the index exists at about 0.59 s but is released by the deadline at about 1.65 s; the parser waits 1,070 ms (timed span).
  • Finalize: scene.finalize takes 195–245 ms when metadata stays out of it. It takes 518–680 ms in every round where parser.complete and the store commit land inside it (Holter 1 of 5 rounds, BWK 3 of 5).

Change

  • coldEntityIndexHandoffPolicy() in entityIndexHandoff.ts makes the policy explicit and testable: no deferral at any size.
  • useIfcLoader uses it. forwardEntityIndexTo keeps its deferral mode, now unused by the loader.
  • New test: at 0.5–1,050 MB the index reaches the parser sink at once, and a later release() does not deliver it twice.

Not yet verified (in progress)

  • Timed A/B on top of #9684 + #9747: Holter, BWK (#3921's architecture model), advanced_model and FZK; cold plus both reopens; 5 rounds; peak memory. A memory regression beyond the noise floor fails the change. This PR stays unqueued until that verdict and the data-store identity check (entities, all edges, on-demand maps, every property and quantity result, spatial hierarchy) on all seven scoreboard fixtures are in.
  • The focused viewer tests run through the fleet. Locally, entityIndexHandoff.test.ts passes 14/14.

šŸ¤– Generated with Claude Code