perf(nodes): batch ceiling undersides and slab bodies (charter row 16) - #789
Open
wass08 wants to merge 8 commits into
Open
perf(nodes): batch ceiling undersides and slab bodies (charter row 16)#789wass08 wants to merge 8 commits into
wass08 wants to merge 8 commits into
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: d4012a5d-4673-411a-98cb-33f3158b6e6c |
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
rich-4× idle frame CPU (charter backlog row 16): ceilings and slabs — 696 opaque, level-parented, one-geometry-per-node meshes on that fixture — draw through the per-level
BatchedMeshcontainers ofshared/node-batch/like items, columns, doors and windows already do.Same-load PR-vs-main pairs (the machine ran at load average ~7 all afternoon, so absolute numbers are inflated and only back-to-back pairs are quoted):
Like-gesture edit receipts (wall/door body moves, undo) are flat or better; every fixture ends at dirty 0 with zero phantom marks. One receipt regressed deterministically (rich-2×, moving the wall behind a ceiling-hosted light: 32 frames vs 6–9) and turned out to be a real bug this batching exposed: the grid raycaster never enabled
BATCHED_LAYER, so the ground ray under a dragged wall missed the now-batched slab, the wall jumped 8.5 m and created a bridge wall (135 walls re-marked). Fixed in dd745a0 (291 ms / 8 frames after, main 336 / 8), and the same guard was applied to every non-hover raycaster that can hit batched sources first-person door/window targeting, item/column support caps, accessory placement, door/window paint, wall paint — 7a64290; the support-cap and door/window ones were already exposed on main for the kinds batched since #760. The audit table of all 35 raycasters lives in the private charter folder.What it took (beyond adding two kinds)
viewer/src/systems/ceiling/ceiling-system.tsxconsumed atuseFramepriority 0; the batch snapshots pending marks at 1. It now consumes at 2 likeGeometrySystem(definitionsystem.priorityorders components, not frames —node-definitions.mdsaid otherwise and is corrected).transparent: truewith opacity 1 (introducing commit 967a905 calls it opaque; no fade). Now opaque, so it batches in the default textures-on appearance. Blend order against glass changes by a few hundred pixels (parity below).useLiveTransforms, and paint previews swap materials on every fan-out target, without dirty marks. Both release now and defer joins; a paint commit ends its holds through a single owner (paint-preview-owner.ts) — the first cut leaked the hold forever on commit and reached columns/doors/windows too; an apply() that throws after the scene write ends holds without restoring stale materials.externalSelectedIdsrelease like local selection; hidden-level candidates are re-offered when the level comes back.release()used to keep obsolete packed geometry inuseduntil an overflow rebuilt the whole bucket. Surfaces now own a stable slot with 25 % headroom and rejoin viasetGeometryAtwhen the new geometry fits; overflow rebuilds size from live geometry only; multi-node releases flush once per frame; an emptied container survives the quiet window; released surfaces on a level wait while any wall there carries a live override and until the wall queue drains, then join in one wave. Counters under__pascalPerf.batchStats()(releases, joins, replacements, overflow rebuilds, bytes copied).pascalExport = 'strip', so a capture that landed while it was sewn exported 80 k duplicate wall vertices. Fixed (separate commit).drag:movenow carry the moved node id (scopenodeId), so the matrix runner can refuse to diff unlike gestures.Gates
outline-parity.tsposes H/S/SH/SI on rich 4× + Maxi 1×: 0.36–0.46 % pixels differ, localized to window glass, glass-room seams and two small floor patches; selection census identical on the stable poses (the 3a/3b batching row accepted 0.4 % of the same kind).wall-batchmeshes; materials 91 → 60 (deduplicated slab defaults), −1.1 MB.bun test packages/nodes --randomize --seed=12 127 pass; discriminating tests for every mechanism above (the new node-batch tests were written to fail without each fix).Follow-ups filed (idea inbox, not changed here)
history.tsrefreshSceneAfterHistoryJump), releasing every batched member on every level per undo.Charter:
plans/performance/editor-scalable-scene-runtime.mdrow 16 (private PR follows with the evidence row, dashboard refresh and the gesture-aware runner).🤖 Generated with Claude Code
https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
Note
Medium Risk
Large changes to batch membership, material cache lifecycle, and many editor raycast paths; regressions would show up as wrong placement, paint, or support surfaces rather than auth/data issues.
Overview
Extends level
BatchedMeshbatching to ceilings and slabs (alongside items, columns, doors/windows), with a reworked batch store: per-shadow containers, reserved geometry slots for mutable surfaces, coalesced releases, and deferred empty-container disposal. Sources stay mounted but draw-hidden; live transforms, slot paint previews, external selection, and material cache clears now release and re-offer batch members on the same rules as hover/selection.Raycasting for tools and walkthrough no longer misses batched floors/slabs: non-hover raycasters call
setSurfaceRaycastLayersso hits still use source meshes when batch draws take over. Ceiling rebuild timing moves to frame priority 2 so the batch’s priority-1 dirty snapshot sees geometry changes; ceiling underside materials are opaque so they can batch in the default appearance.Paint gets a shared
paint-preview-owner(fan-out cleanup/commit) and slot-preview holds that keep batched nodes on their sources until previews settle.clearMaterialCacheregisters cleanups and disposes after consumers rebuild; selection highlights and slab caches hook in so previews never restore disposed materials. Wall merged batches and node batches are taggedpascalExport: 'strip'for GLB capture.Reviewed by Cursor Bugbot for commit 7a64290. Bugbot is set up for automated code reviews on this repo. Configure here.