Skip to content

engine: stop paying per-update work for resident entities that cannot change (#5009) - #5073

Merged
jakildev merged 5 commits into
masterfrom
claude/5009-static-residents
Nov 17, 2026
Merged

jakildev merged 5 commits into
masterfrom
claude/5009-static-residents

Conversation

@jakildev

@jakildev jakildev commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements docs/design/static-residents.md as merged (#5008, PR #5062): an entity its owner declares static (C_Static) stops matching pose writers at once, and stops being walked by the deriving systems once the engine has derived from its frozen inputs (C_Settled).

The pushes answer the steward directions on the thread (#5009 A2–A6) and conform to the merged document:

  • Rebased onto origin/master 345dbbf25 (the design document is master's merged version).
  • Gate 3 write witness. C_VoxelPool::markCullBoundsDirty counts every position and alpha write notification at the producer, before the pending-bit dedup, queue saturation or either cache consumer. The report prints it beside the total and camera/full-rebuild slot counts; the subtraction-based invalidated_slots is gone. Four positive-control unit tests.
  • Fixture warm-up. Every static fixture opens its profile window only once no position range is queued, neither cull cache has a write-pending chunk and the light occlusion grid has no stale world box (C_VoxelPool::pendingCullDebt), not only settling == 0. The mostly-static window does open under it (A3 asked). The static_cycle capture asserts the same list at its first shot (engine: stop paying per-update work for resident entities that cannot change #5009 A4); see "Plan departures" for its all-dynamic twin.
  • Bounded range policy. The position queue keeps every disjoint range up to a 65,536 bound, coalesces repeated, overlapping and touching notifications in place (reusing its storage), and saturates only past half the bound. GPU-owned gaps stay unqueued. The transform-index queue keeps its own 8,192 bound (its consumer reads only emptiness). The mostly-static million now submits 160,000 B per frame instead of 16,000,000.
  • The engine-owned boundary. IREntity::EngineAttach<T> / EngineAttachKey<T> / GenericAttachable, the constraint on every typed attach lane, insertNewComponent private, run-time refusals on addComponentDynamic, getOrCreateSingletonByComponentId, restoreEntitiesBatch and the snapshot loader, the restricted-bit assert in the move primitives, attachEngineComponentDeferred; IRSystem::promoteSettled / restampSettling / raiseSettleFloor / settleFloor on detail::SettlePromoter, the floor moved to the system manager; the private stamp with its copy and move rules.
  • The remaining typed-overwrite and boundary tests the document lists.

Nothing is open from the steward directions. The rotated cycle_* references are re-blessed at d9f87ddaf (criterion 5, #5009 A7), and lod_scene_fine_yaw90 is master's row (criterion 8; #4904, #5106).

2. An owner call on the mostly-static frame time. Closed: accepted under gate 3 as written (answer, #5009 A6). See "Mostly-static frame time" below.

Carries the fix of #5080 (now on master as PR #5082).

What is in it

  • Entity layer. Per-component traits recorded at registration (kStaticGuard, kClearedByForeignMove, kTracksInputChanges, EngineAttach), the tracked-change log (now also logging a removal that names a cleared component), per-worker entity notes. C_Settled is dropped by every archetype move that does not name it, by a parent-link change, by a parent's destruction and by a typed overwrite through setComponent. reserveRows sizes a node's columns once. The engine-owned boundary above.
  • System layer. C_Static / C_Settled, one exclusion function on every registration and query lane, declared and effective exclude archetypes, GatesSettled, rounds across INPUT, UPDATE and RENDER, the Walked count, SettlePromoter.
  • Prefab layer. IRPrefab::Static (freeze, thaw, resettle, drain, eligibility, audit), the engine mutators that thaw or resettle, the deriving systems (PROPAGATE_TRANSFORM, the modifier resolvers, UPDATE_VOXEL_SET_CHILDREN, REBUILD_GRID_VOXELS*, SEED_STAGED_VOXELS), the gated fog subject systems and LOD gate, the position-range policy and the write witness.
  • World, profile, Lua. The drain after each pipeline, snapshot inventory and the loader's restricted-id strip, the report's Walked column and Static residents section, the IRStatic table and reads = { … }.
  • IRPerfGrid. --no-static, --moving-fraction, --static-cycle, --recolor-every-update; two render-verify rows with their own "warmup": 48; the cache-debt start assert at the profile window and at the static cycle's first capture.
  • Rules. The rule changes the document requests (.claude/rules/cpp-ecs.md, engine/prefabs/irreden/voxel/CLAUDE.md), and the module CLAUDE.md entries for the boundary.

20 other system files only had a C_WorldTransform parameter declared const, so their systems keep matching static entities: HITBOX_MOUSE_TEST, CANVAS_RESIDENCY, DEBUG_CULLING_MINIMAP, ENTITY_CANVAS_TO_FRAMEBUFFER, FOG_REVEAL_EVAL_CANVAS (and its ghost twin), FOG_SUBJECT_ADOPT_CANVAS, FRAMEBUFFER_TO_SCREEN, PROPAGATE_CANVAS_PARTS, PROPAGATE_CANVAS_ROTATION, SHAPES_TO_TRIXEL, SPRITES_TO_SCREEN, SYNC_VIEWPORT_SUBJECTS, UPDATE_JOINT_MATRICES, UPDATE_VOXEL_POSITIONS_GPU, BUILD_SPATIAL_INDEX, COLLISION_NOTE_PLATFORM, CONTACT_NOTE_BURST, PARTICLE_SPAWNER, PERIODIC_IDLE_NOTE_BURST, PROPAGATE_CHUNK_MEMBERSHIP.

Conformance

Each "may assume" statement of the merged document and the test that pins it. Tests are in test/ecs/static_resident_world_test.cpp (StaticWorld.*) unless a suite is named.

Statement Test
PROPAGATE_TRANSFORM: a settled entity's world transform is the composition as it stood when it settled StaticResident.CreatedStaticSettlesAndMatchesTwinThroughItsLife, StaticChildOfStaticParentAndDynamicChildMatchTheirTwins, StaticResident.SettledEntityIsNotMatchedByTheDerivingSystems
…must not assume a later global modifier is folded in AGlobalModifierPushedAfterSettlingDoesNotReachTheEntity
Modifier resolvers: C_ResolvedFields holds the values of its last round GlobalPushAfterTheResolverHoldsPromotion, GlobalPushAfterTheRoundClosedHoldsPromotion, GlobalExpiryWhileSettlingHoldsPromotion, AGlobalPushedEveryUpdateHoldsEverySettlingEntity
MODIFIER_DECAY never matches a static entity; lifetimes do not advance AStaticEntitysModifierLifetimesDoNotAdvance, ARegisteredMoverNeverVisitsAStaticEntity
UPDATE_VOXEL_SET_CHILDREN: pool positions current, owner range registered, range queued once, no cull chunk invalidated StaticResident.SettledEntityQueuesNoPositionsAndInvalidatesNoCullChunk, OwnerAdoptionCoversAnEmptySetAndAnEditBeforeTheFirstDrain, ARoundSpansThePipelinesAndOnlyTheRenderJoinClosesIt
REBUILD_GRID_VOXELS*: the span holds the raster for the current rotation ARotatedGridEntityIsRasterizedWhenItSettlesAndMatchesItsTwin, AHiddenSetStillHoldingARotatedRasterIsHeldUntilItIsShown
SEED_STAGED_VOXELS: every set is resident AStagedSetIsHeldUntilItIsSeeded
Fog subject systems: verdict current after every update; every trigger arms the pass ASettledSubjectIsWalkedOnlyWhenAFogInputChanged (one assertion per trigger row), AReplacedFogComponentArmsThePassAtAnEqualRevision, AnArmedPassCoversEveryStaggeredRowOnce, ASettledSubjectsFogVerdictStillFollowsTheFog, FogSettersResettleTheSubject, LuaFogVisionSlotsTest.EveryVisionWriteAdvancesTheOwnersRevision
GATE_VOXEL_SETS_BY_LOD: lodCulled_ matches the resolved tier ASettledSetsLodGateFollowsTheActiveTier, MidRoundLodBandChangeRestartsTheWait, TheAuditCatchesARawLodBandAssignment, LuaStatic.LodBandPropertiesResettleASettledOwner
A settling row is derived on every dispatch; promotion needs one complete round FreezePromotesAfterExactlyOneCompleteRound, the four MidRound* tests, ResettleOnASettlingEntityMovesPromotionOneRoundLater, AppendingADerivingSystemMidRoundDelaysPromotionUntilItHasRun
A system that neither writes pose inputs nor derives is unchanged StaticPolicy.AlsoWritesCountsAsADeclaredWrite (its Unrelated system visits all three rows)
Readers (collision, picking, render stages): transform, pool positions and owner range are current No dedicated test. Pinned by the twin comparisons (expectTwin compares world transform, every pool position, visible_, lodCulled_ and fog bits) and the owner-range test above.
Cull-bound caches: invalidated when it settles, not again StaticResident.SettledEntityQueuesNoPositionsAndInvalidatesNoCullChunk; the control's Cull writes: notifications=0 below
Snapshots: C_Static saved, C_Settled not; loads settling LuaWorldSnapshotTest.RoundTripsAStaticResidentAsSettling (now settled through promoteSettled before the save)
Chunk residency No new code and no test; the document adds no behaviour here.
Parent and child links AStaticTreeCreatedWithItsParentsSettlesAndStaysStatic, the two Reparenting…Subtree… tests, UnparentingResettlesTheSubtreeAsARoot, ReparentingUnderADynamicEntityMakesTheSubtreeDynamic, ADestroyedParentsSurvivorsKeepTheirLinkAndDeriveAsRoots, APreDestroyHookThatReparentsASurvivorLeavesItUnderTheNewRoot, StaticEntityLayer.*
Matching policy on every lane StaticPolicy.* (19 tests), LuaStatic.AnEvalSystem*, LuaStatic.APropertyWriteThroughAReadsColumnNeverReachesTheRow (a reads column's :at returns a copy, so a usertype property write never reaches the live row; it fails against the old reader), LuaSystemCodegenTest.ReadsComponentIsDeclaredConstAndStillRead, AQueryBetweenUpdatesNeitherDerivesNorDelaysASettlingEntity
The engine-owned boundary: only promoteSettled attaches C_Settled, after re-checking the rule Typed lanes: the static_assert(!…) block over createEntity (facade and manager), setComponent (both), setComponents, setComponentDeferred (both), insertReservedEntity, createEntitiesBatch, createEntityBatch, createEntityBatchWithFunctions, singleton, singletonEntity, getOrCreateSingleton, each with its C_Static positive control, plus insertNewComponent inaccessible for both and the key not constructible. By-id lanes: TheByIdLanesRefuseSettledAndTheSettlingEntityPromotesWithItsTwin, LuaStatic.LuaCannotNameSettled. Restore: ARestoreIntoASettledArchetypeIsRefused. promoteSettled itself: PromoteSettledReChecksEveryRowItIsGiven, PromoteSettledRefusesARowTheSettleFloorHolds, APromotionStagedAfterTheTagsRemovalIsDropped
The stamp: private, a copy arrives as zero, moves keep it The static_asserts on settleStamp_ access, move assignment, copy assignment and noexcept move construction; ACopiedStaticArrivesWithAZeroStampAndWaitsForANewRound
Removing C_Settled returns the entity to settling; removing C_Static drops both RemovingSettledLeavesItSettlingAndRemovingStaticLeavesNeitherTag, StaticEntityLayer.EveryMoveThatDropsAClearedComponentLogsTheEntity
Typed overwrites resettle, pose components with the static subtree ATypedOverwriteOfThePoseResettlesTheSubtreeAndMatchesTheTwin (three forms), ATypedOverwriteOfAnotherComponentResettlesOnlyTheEntity, ATypedOverwriteOfTheLodOverrideResettlesOnlyTheRoot (settled and settling tree), LuaStatic.TheLodOverrideBindingResettlesASettledEntity, ATypedOverwriteOfModifiersIsResolvedOnceAndDoesNotDecay, TheReferenceAnOverwriteReturnsIsTheEntitysRow, AnOverwriteOnADynamicTreeLogsNothingAndMovesNoEntity (10,000-entity subtree), LuaStatic.SetLuaFieldOnASettledEntityIsTheRawPath, StaticEntityLayer.ATypedOverwriteDropsSettledAndLogsTheEntity
Forbidden writes StaticResident.RawWriteIsRetainedAndNotDerivedUntilResettle, TheAuditCatchesARawWriteThatIsNeverResettled, AModifierPushThawsAndReachesTheWorldTransformLikeOnATwin, ModifierMutatorsThawOrResettleTheirTarget, EveryVoxelSetMutatorResettlesItsOwner, RotationModeAndGizmoAttachThaw, the typed-overwrite row above
Gate 3 write witness and its positive controls ChunkBoundsEvictionTest.APositionWriteGivesANonzeroWriteWitness, AnAlphaOnlyWriteGivesANonzeroWriteWitness, WritesKeepTheirWitnessOnAFrameThatTakesTheFullCardinalRebuild (position and alpha), ACameraOnlyRebuildLeavesTheWriteWitnessAtZero, VoxelPositionQueueTest.ASaturatedQueueStillInvalidatesTheCullCaches
Warm-up: settlement finished and cache debt paid ChunkBoundsEvictionTest.CullDebtCountsWriteDebtUntilEachCacheConsumerPaysIt; the fixture's start assert (staticFixtureReady / staticCacheDebt in creations/demos/perf_grid/main.cpp), at the profile window and at the static cycle's first capture. Positive control: --static-cycle --auto-screenshot 10 exits 3 with stale_world_chunks=832.
Range policy VoxelPositionQueueTest.* (repeated writes, overlaps and touches, 10,000 disjoint ranges under repeated catch-up writes, the bound and one past it, a full queue of repeats compacting instead of saturating), PositionUploadTest.TenThousandDisjointRangesSubmitOnlyTheirSlots, the saturated-queue tests rewritten to saturate with disjoint ranges

Gates

The document adopts or replaces each default gate of #5009. Its wording is the gate.

# Decision The document's version
1 Replaced "the Entities column of PropagateTransform, UpdateVoxelSetChildren and ModifierDecay, and the Walked column of FogRevealEval and of every other gated system, are each under 1% of the base arm's Entities for the same row"
2 Adopted "The sum is per-call mean times calls divided by rendered frames … plus on the head arm every row this design adds. Head is at most 10% of base."
3 Replaced "After settlement and cache warm-up, every sampled frame submits zero position-upload bytes and receives zero position/alpha write-invalidation notifications for the resident population. Write-driven cull rebuild work is zero. Camera/projection-only rebuild work is reported separately … Mostly-static million, over gate 8's population: position bytes submitted for upload per frame are above zero and at most 16 times the moving cells' voxels (160,000)."
4 Adopted, extended Twin comparison at every step, the cutover tests, and "the static-cycle rows equal the --no-static rows at maximum delta 0"
5 Adopted "one test per path", per mutator row and per fog and LOD trigger, the engine-owned boundary and the typed overwrites
6 Adopted "the per-call means of the four systems are not above the base arm's by more than twice its round range"; with --no-static --recolor-every-update, "frame time is not above base by more than twice its round range"
7 Adopted render-verify for four targets, nine-yaw identity, light-verify --if-changed
8 New "promotion_ms_max is at most 4 ms on the reference host"
9 New "a settled subject inside a vision circle … follows the fog"

Acceptance evidence

Perf: Release, Apple M4 Max, Metal, scripts/perf/repeat_profile.py, interleaved base and head rounds, every counted run RESULT=CLEAN with QUIET=guarded (contaminated runs were discarded and re-run; a codex pane's quiet lease rolled its parker mid-run several times). Base is origin/master 345dbbf25, the head's fork point; the recolor base arm is that commit plus the --recolor-every-update patch in the thread. Fixture commands are the four in the thread. The control, dynamic and mostly-static rounds ran on a head that also counted notified slots in the write witness; the recolor rounds marked "final" ran on the final witness (notifications only), and one control and one mostly-static run at the final commit 045b35508 read the same witnesses (control Position upload: bytes=0, Cull writes: notifications=0 frames=0 of 300; mostly-static max_frame_bytes=160000 frames=300 of 300, promotion_ms_max=2.318).

Criterion Result Evidence
1. Conformance Met at the merged document Tables above
2. Rows not walked (gate 1) Met Million control, per call: PropagateTransform 131 of 1,000,131 (0.013%; the demo's non-cell entities), UpdateVoxelSetChildren 0 of 1,000,000, ModifierDecay 0 of 1,000,000, FogRevealEval walked 0 of 1,000,000 matched. Three runs.
3. Perf (gate 2) Met Four-system time per rendered frame: base 6.472 / 6.965 / 6.637 ms (range 0.493), head 0.0237 / 0.0286 / 0.0286 ms: 0.4% of base. Frame 45.4 → 35.5 ms.
4. Gate 3, control Met Every one of the 300 frames, three runs: Position upload: bytes=0, Cull writes: notifications=0. Camera/full rebuild: 4,000,000 slots on the 4 frames where the sweep reaches a cardinal yaw, equal to the total rebuild count, so no slot was rebuilt for a write. The window opened only after staticCacheDebt read zero queued ranges, zero write-pending cardinal chunks and zero stale world boxes.
4. Gate 3, mostly-static Met --moving-fraction 0.01, the window opened under the full start assert: 160,000 B submitted in every one of the 300 frames (bytes=48000000 max_frame_bytes=160000 frames=300 of 300), three runs; 10,000 notifications per frame.
5. Motion control (gate 4) Met: static = dynamic, references re-blessed (drift from #5063, per #5009 A7) StaticResident.*, StaticWorld.*. At 35ff50dc5, with the full start list asserted at the first shot (warm-up 48), the static run and its --no-static twin capture byte-identical frames on all seven cycle_* shots (md5 per shot, both arms: 6f34de37… ×3, 0e986e41…, a2359dd9…, 3a925711…, a57865e4…). Before the re-bless, render-verify --target IRPerfGrid read 29 of 35: three rotated shots of each run (cycle_zoom1_rot, cycle_zoom4_rot, cycle_zoom4_rot_pan, 99.93–99.98% match, max delta 52–53) failed the references blessed on 369cb6b06, identically in both runs. Master renders the same seven frames: 345dbbf25 plus a move-only --static-cycle patch (patch in the thread), built and captured in the same tree at warm-up 48, is byte-identical to both head runs on every shot. The drift is #5063's, per #5009 A7: the scene overflows the sun-record pool (requested=786432 at a ceiling of 131072) and #5063 changes which records the overflow keeps. The three rotated references are re-blessed at d9f87ddaf (0e986e41…, a2359dd9…, a57865e4…; the new PNGs were inspected and differ from the old ones only in a few ridge-top highlight voxels). git diff --stat of that commit names only those three files. render-verify --target IRPerfGrid at d9f87ddaf: all 35 checks pass, both cycle runs included (Debug, Metal, M4 Max, pool-7 build/).
6. Forbidden write (gate 5) Met Conformance table, "Forbidden writes", "The engine-owned boundary" and "Typed overwrites" rows
7. No cost to dynamic entities (gate 6) Met Dynamic million, per-call means, base (range) → head: PropagateTransform 1.105 / 1.327 / 1.203 (0.222) → 1.043 / 1.174 / 1.160; UpdateVoxelSetChildren 1.339 / 1.331 / 1.377 (0.046) → 1.311 / 1.331 / 1.378; FogRevealEval 1.187 / 1.224 / 1.208 (0.037) → 1.181 / 1.203 / 1.217; ModifierDecay 0.002 / 0.003 / 0.003 (0.001) → 0.003 / 0.003 / 0.003. No head mean is above its base mean by more than twice the range. Frame 57.2 → 53.4 ms. Recolor, frame time, final witness: base 244.32 / 242.50 / 245.68 ms (range 3.18), head 243.51 / 247.07 / 241.62 ms; the head mean is 0.10 ms below base.
8. Render regression (gate 7) Met (lod_scene_fine_yaw90 tracked by #4904 and #5106) IRFogDemo 69 of 69, IRCanvasStress 59 of 59, light-verify --if-changed all pass (re-run at 35ff50dc5), nine-yaw IRCanvasStress set byte-identical between origin/master and head (sha256 of all nine). IRPerfGrid 35 of 35 at d9f87ddaf (criterion 5); the 21 non-cycle rows keep their unchanged capture frames. IRShapeDebug 128 of 148 (10 pending): 19 rows fail on origin/master on this host too, at the same max deltas (owner #4904; PR #5103 refreshes them). lod_scene:lod_scene_fine_yaw90 is the same frame on master and head in one build tree (pool-5 build/, Debug, Metal, M4 Max, fleet-run --timeout 90 IRShapeDebug --auto-screenshot 20 --lod-scene --pivot-origin, both RESULT=CLEAN, Discovered 1 display monitors). Master 345dbbf25 was built first and captured, then head 045b35508 was built in the same tree (every changed file touched; the exe carries C_Settled) and captured. All six shots are byte-identical: coarse / restored e1250f7c45a9847e2f104cfae38058cf, medium_yaw45 6b877a9e24511a6023373fc53ea52b14, fine_yaw90 450cab722cbb972497593d665424a4a0, return_yaw180 85d1c05e3eaeeeddeebae90d21b5be29, coarse_yaw270 e60af1f72c654fd98e21653547136d04. SunFaceAdmit is in both binaries. My earlier "head-only" reading compared arms from different trees. The row is not this PR's (#5009 A5, A7): it fails with the same metrics on master in the same tree. Trackers: #4904 (the re-bless) and #5106 (the build-tree factor).
Gate 8, transition cost Met promotion_ms_max 2.53 / 2.55 / 2.42 ms over three mostly-static runs with the default cap, against 4 ms. The promotion now applies at the flush through attachEngineComponentDeferred.
Gate 9, fog follows the fog Met ASettledSubjectsFogVerdictStillFollowsTheFog; render-verify --target IRFogDemo 69 of 69

The witness cost, measured. With a slot count beside the notification count, recolor read base 243.88 / 243.44 / 245.14 ms against head 254.84 / 256.93 / 256.78 ms (+12.0 ms), all of it in the fixture's recolor row (22.2 → 23.7 ms per call, 8 calls per frame, about 1M markCullBoundsDirty calls each). A diagnostic tree with both counters removed read 246.70 / 245.84 / 247.91 ms. Dropping the slot count and keeping the counting entry a small wrapper over the unchanged chunk-marking body gives the "final" numbers above.

Mostly-static frame time, accepted under gate 3 as written. The owner accepted the cost under gate 3 as written (#5009 A6). It is not a waiver: no gate bounds this fixture's frame time. The per-range Metal blit cost is the accepted residual #3725 tracks, and this fixture fires that ticket's pick-up trigger (table). Rows 1–2 are mine, interleaved, three rounds each, same fixture and commit. The old-bound arm is a diagnostic tree that restores the 8,192 bound, which saturates on this fixture and uploads every CPU-owned slot. Row 3 is the fixture's all-dynamic twin, what master does on this scene today. It is a record row, not a gate, cited from the answerer's four interleaved pairs against the head's Release binary in a separate session (every run RESULT=CLEAN / QUIET=guarded). The head read 44.12 / 44.52 / 45.53 / 46.68 ms in those pairs, ahead of the twin in every pair.

Arm Bytes submitted per frame Steady frame ms vs1_pos CPU ms GPU frame ms UpdateVoxelSetChildren ms
Head (range policy) 160,000 43.53 / 44.27 / 44.40 3.68 34.8 / 35.5 / 35.6 0.142–0.149
Old bound (whole CPU pool) 16,000,000 39.26 / 39.88 / 39.79 0.74 33.4 / 34.2 / 34.1 0.235–0.241
All-dynamic twin (--wave-freeze --moving-fraction 0.01 --no-static), record row 16,000,000 46.46 / 46.38 / 46.76 / 50.71 — — —

The gate holds, and the frame is 4.4 ms slower. The time is in the flush: on Metal subDataRanges → stagePatch packs the 10,000 ranges into one staging slice and then encodes one copyFromBuffer per range, so the frame carries 10,000 blit commands (CPU encode +2.9 ms, GPU +1.4 ms). The whole-pool path is one memcpy and one blit. Any policy that keeps the gate's byte bound keeps the ranges disjoint, so the cost is in the backend's per-range encoding, not in the queue. The old-bound arm goes through stagePatch with one range, not replaceBacking: the position buffer is 33,554,432 B and 16,000,000 B does not cover it. The backend is unchanged here; landing disjoint ranges in one GPU pass is #3725's.

Not gated, for the record: the control lifts the promotion cap and promotes 1,000,000 rows in one drain: promotion_ms_max 251–259 ms on the control (the fixture accepts one long frame; gate 8 is on the capped mostly-static population).

Unit suite: fleet-run IrredenEngineTest, 3957 passed, 3 skipped (host-specific skips that predate this PR).

Plan departures

  • Reference re-bless. Registering C_Static at startup moves every later entity id by one. TRIXEL_GLITCH salts its noise by raw entity id, so the nine lit macOS glitch_subject_* references reseed, as after render: keyboard-first widgets and hotkey hints (#4679) #4707 and render: player-facing perf hud toggled by f3 #4739. origin/master with one extra component registration at startup renders all nine byte-identical to this branch (sha256 of each capture compared). The _off rows and choreo_tick_n1 are untouched.
  • IRPrefab::Static::noteHeld is a sibling of noteChanged for a deriving system that holds a row. The document describes the hold without naming the call.
  • upsertBySourceInPlace does not thaw. It takes a C_Modifiers &, not an entity id. A system holding that reference declares a write to a pose input, so it never matches a static entity; only a raw reference can reach one.
  • The canvas fog variants are not gated. A canvas-owning entity is not eligible to be static, so FOG_REVEAL_EVAL_CANVAS* and FOG_SUBJECT_ADOPT_CANVAS never see a settled row.
  • A creation's own C_ResolvedFields seeder must exclude C_Settled, or the resolver composes a settling row from an unseeded value. Documented in engine/prefabs/irreden/common/CLAUDE.md.
  • Lua C_FogRevealed.override and .channels stay raw writes, as the document says of the fields ("delayed, not lost"). No Lua form of setOverride / setChannels is added.
  • Drain state lives in a C_StaticState singleton; staticDrain is a new IR_PROFILE_SCOPE row.
  • EntityManager::reserveRows is new. The drain sizes the settled twin of a settling node once, so a capped promotion never regrows columns over rows already settled.
  • IRPerfGrid static fixtures open their profile window only when nothing is settling and the cache debt is paid, then replay the yaw sweep from its first pose, so a report covers the same 300 poses as the base arm. The static_cycle capture asserts the full § "Fixtures" list at its first shot (engine: stop paying per-update work for resident entities that cannot change #5009 A4). Its two runs carry "warmup": 48 in the manifest: the static run settles at frame 8 and pays its last stale world box at frame 23. The 21 other IRPerfGrid rows keep their capture frames, and other --wave-freeze capture tools (perf-grid-rotate-sweep, feeder-margin-verify) keep the settlement-only check. The --no-static twin is held to settlement and the script, not the cache half. Its cells are dynamic and re-notify their writes every frame, so its light occlusion grid holds a steady 960 stale world boxes (measured on frames 1–80: 960 from frame 6 on, with nothing queued and no pending cull chunk), and no warm-up pays them. This is the same exemption the all-dynamic arms of the profile fixtures already take (!g_staticCells). The twin is the "all-dynamic twin of every fixture", not one of the four fixtures, and the image identity above holds with it. This departure stands per engine: stop paying per-update work for resident entities that cannot change #5009 A7. The recolor fixture's base arm is origin/master plus the --recolor-every-update flag (the patch is in the thread), built in a scratch tree.
  • The write witness counts notifications, not slots. The document asks for one count per range; a slot count beside it cost 1.4 ns per call on the recolor fixture (8M calls per frame, +12 ms), so it was dropped, and the counting entry is a small wrapper over the unchanged chunk-marking body.
  • attachEngineComponentDeferred takes the key by value and applies after every other staged change of the flush, as a per-manager list of (entity, component, companion, row appender) with no closure per attach.
  • IRAsset::Result<T>::success constructs its value in place, so a T with no public move assignment (C_Static) can be read.
  • A removal that names a cleared component is logged in the tracked-change log, as the merged document says ("including a removal that names it"); handleInputChange logs each entity once.
  • test/common/settle_now.hpp settles an entity through promoteSettled for a test that runs no pipelines, replacing the tests that attached C_Settled directly; the entity-layer tests use a local trait stand-in.

Test plan

  • fleet-build --target IrredenEngineTest and fleet-run IrredenEngineTest (3957 passed, 3 skipped)
  • python3 scripts/perf/test_profile_parser.py (35 tests)
  • python3 scripts/lint_comment_refs.py, python3 scripts/lint_instruction_size.py --against origin/master, fleet-build --target header-checks, fleet-build --target format-changed
  • python3 scripts/render-verify.py: IRFogDemo and IRCanvasStress pass; IRPerfGrid 35 of 35 at d9f87ddaf (criterion 5); IRShapeDebug 19 inherited rows (render: refresh stale macos-debug ShapeDebug and CanvasStress references #4904), and lod_scene_fine_yaw90 byte-identical to master in one tree (criterion 8; render: refresh stale macos-debug ShapeDebug and CanvasStress references #4904, render: make lod_scene_fine_yaw90 deterministic across macOS build trees #5106)
  • lod_scene pass, master and head in one build tree, six shots byte-identical
  • cycle_* scene, master arm (move-only --static-cycle patch) and head in one build tree, seven shots byte-identical
  • static_cycle start-assert positive control (--auto-screenshot 10 exits 3), and static = dynamic byte-identical on all seven cycle_* shots at warm-up 48
  • Nine-yaw IRCanvasStress identity, origin/master against the head
  • python3 scripts/light-verify.py --if-changed
  • python3 scripts/perf/repeat_profile.py, four fixtures, base and head interleaved, plus the old-bound and no-witness diagnostic arms
  • Windows and Linux smoke

Closes #5009

🤖 Generated with Claude Code

@jakildev

Copy link
Copy Markdown
Owner Author

NEEDS-DESIGN

Gate 3 of docs/design/static-residents.md (issue criterion 4) cannot be met as written on either fixture. Both halves fail for a reason outside what a static resident costs, and each fix I can see changes engine behaviour the document does not cover. Every other measured gate passes; the numbers are in the PR body.

Measured on the final head 0c134c331, Release, Apple M4 Max, RESULT=CLEAN / QUIET=guarded.

1. Million control: "cull-bound slots rebuilt are zero" in every frame

The gate: "In every frame of the profile window, position bytes uploaded are zero and cull-bound slots rebuilt are zero."

What the control reads over its 300 frames:

Position upload: bytes=0 max_frame_bytes=0 frames=0 of 300
Cull bounds: slots_rebuilt=4000000 max_frame_slots=1000000 frames=4 of 300
Cull bounds by cause: invalidated_slots=0 invalidated_frames=0 whole_cache_slots=4000000 whole_cache_frames=4

Position bytes are zero. No slot is rebuilt because a write invalidated it. But the sweep (--yaw 0 --yaw-step 0.020943951) lands on a cardinal yaw on four frames, and C_VoxelPool::rebuildChunkBounds rebuilds the cardinal iso cache whole on a cardinal frame that follows a continuous-yaw one (m_chunkBoundsDirty is set on every non-cardinal frame). That is 1,000,000 slots on each of those frames. The camera causes it, origin/master does the same, and nothing in this design touches it.

I added the Cull bounds by cause line (and CullRebuildCounters::wholeCacheSlots_) so the two causes are separate in the report.

  • Option A (my recommendation). Read the gate as "cull-bound slots rebuilt because a position or alpha write invalidated their chunk are zero in every frame", which is invalidated_slots=0 invalidated_frames=0. This is what the document's own claim says ("A settled entity's chunks are invalidated when it settles and not again by any per-frame system"). Already met.
  • Option B. Keep the wording. Then the cardinal cache must stop rebuilding whole on a cardinal frame, for example by keeping a cache per cardinal index. That is a cull-cache change with its own memory cost (four caches) and its own tests, and I would file it as a separate ticket rather than fold it in here.
  • Option C. Drop the cull half of the gate and keep the position half.

2. Mostly-static million: "at most 16 times the moving cells' voxels (160,000)"

The gate: "Mostly-static million: position bytes uploaded per frame are at most 16 times the moving cells' voxels (160,000) and above zero."

Measured: 16,000,000 bytes per frame, in all 300 frames, three runs. The 10,000 moving cells queue 10,000 position ranges per frame. C_VoxelPool::kMaxPendingPositionRanges is 8,192 (unchanged from master); past it queuePositionRange drops the range and flushPendingPositionRanges uploads every CPU-owned slot. So this fixture uploads the whole buffer, as the all-dynamic scene does.

One more run to check the mechanism, --moving-fraction 0.005 (5,000 cells, under the cap): 80,000 bytes per frame, exactly 16 × the moving voxels. Its frame time is 45.3 ms against 41.8 ms at 0.01 (single run against a three-run range of 0.58 ms). So on Metal 5,000 scattered ranges cost about 3.5 ms more per frame than one whole-buffer upload. I have not profiled where that time goes.

  • Option A. Keep the gate and raise or remove the cap in this ticket. The 0.005 run suggests this makes the mostly-static frame slower on Metal, not faster, so I would not do it without a measurement that says otherwise.
  • Option B (my recommendation). Reword the gate to what the design controls: the static cells queue no range. A witness for that is the number of voxel slots in the position ranges queued per frame, counted before the cap and the coalescing (it should read the moving cells' voxels, 10,000, on this fixture). The report does not print it yet; I would add it. Bytes submitted then stay a fact about the flusher's saturation policy, not about static residents.
  • Option C. Change the fixture to --moving-fraction 0.005, which meets the gate as written today (80,000 bytes per frame) and leaves the cap alone.

Not questions, for the record

  • The design head moved past this PR. It implements the document through 7ded02267 and the typed-overwrite rule from a10a847b9. The engine-owned boundary (promoteSettled, EngineAttach, the GenericAttachable constraint, the private stamp) and its tests are not implemented. The PR body lists exactly what is missing. Whoever resumes this should re-diff docs/design/static-residents.md against 7ded02267 first.
  • Criterion 8 is blocked on render: IRShapeDebug yaw-180/270 references fail on master after #4939 #5051. render-verify --target IRShapeDebug fails 19 of 148 on origin/master. This branch fails the same 19 rows with the same maximum deltas, and no others.

— worker (pool-7)

@jakildev jakildev added fleet:design-blocked Worker escalated for architectural input mid-task; architect should respond fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 12, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Reproducing the recolor fixture's base arm (gate 6). origin/master has no --recolor-every-update, so the base arm is 369cb6b06 plus this patch to creations/demos/perf_grid/main.cpp, built Release in a scratch worktree and passed to repeat_profile.py through IRREDEN_BUILD_DIR. It was not committed anywhere.

diff --git a/creations/demos/perf_grid/main.cpp b/creations/demos/perf_grid/main.cpp
index a82679aa2..99301a339 100644
--- a/creations/demos/perf_grid/main.cpp
+++ b/creations/demos/perf_grid/main.cpp
@@ -555,6 +555,7 @@ void logDefaultShotDiagnostics(int shotIndex) {
 // render-verify regression tier needs the frozen static twin instead. Off by
 // default -> flagless spawn path is untouched (byte-identical to master).
 bool g_waveFreeze = false;
+bool g_recolorEveryUpdate = false;
 bool g_fogReveal = false;
 bool g_fogGhostHeavy = false;
 bool g_fogGhostSighting = false;
@@ -888,6 +889,11 @@ void registerCliArgs() {
         "attaching C_PeriodicIdle; makes voxel_set/sdf wave content static and "
         "deterministic (#2332)"
     );
+    args.flag("--no-static", "Accepted for command parity; every cell is dynamic here");
+    args.flag(
+        "--recolor-every-update",
+        "Recolor every voxel set to its own color on every fixed update"
+    );
     args.flag(
         "--fog-reveal",
         "Tag every voxel-set entity for entity-anchor fog evaluation against 8 outside circles"
@@ -1055,6 +1061,7 @@ void readCliArgs() {
     g_debugOverlay = IRRender::debugOverlayModeFromString(args.getEnum("--debug-overlay").c_str());
     g_noPerVoxelOcclusion = args.getFlag("--no-per-voxel-occlusion");
     g_waveFreeze = args.getFlag("--wave-freeze");
+    g_recolorEveryUpdate = args.getFlag("--recolor-every-update");
     g_fogReveal = args.getFlag("--fog-reveal");
     g_fogGhostSighting = args.getFlag("--fog-ghost-sighting");
     g_fogGhostHeavy = args.getFlag("--fog-ghost-heavy") || g_fogGhostSighting;
@@ -1944,6 +1951,22 @@ void initSystems() {
         {IRSystem::createSystem<IRSystem::PERIODIC_IDLE_POSITION_OFFSET>()},
         {IRSystem::createSystem<IRSystem::PROPAGATE_TRANSFORM>()},
     };
+    if (g_recolorEveryUpdate) {
+        updateGroups.insert(
+            updateGroups.begin(),
+            {IRSystem::createSystem<C_Name>(
+                "StaticFixtureScript",
+                [](C_Name &) {},
+                []() {
+                    IREntity::forEachComponent<C_VoxelSetNew>([](C_VoxelSetNew &set) {
+                        if (set.numVoxels_ > 0) {
+                            set.changeVoxelColorAll(set.voxels_[0].color_);
+                        }
+                    });
+                }
+            )}
+        );
+    }
     for (IRSystem::SystemId id : IRPrefab::Fog::revealSystems()) {
         updateGroups.push_back({id});
     }

Fixture commands, each with --no-overlay --pivot-origin --auto-profile 300 --config-preset configs/perf/million-profiling-off.lua --yaw 0 --yaw-step 0.020943951:

  • control: --wave-freeze
  • dynamic: no extra flag
  • recolor: --wave-freeze --no-static --recolor-every-update
  • mostly-static: --wave-freeze --moving-fraction 0.01 (head only)

— worker (pool-7)

@jakildev

Copy link
Copy Markdown
Owner Author

Steward triage (2026-11-12): both questions are novel and are sent to proposal. Both would change or narrow gate text the owner signs: static-residents.md § "Decisions the owner signs", item 12, read together with #5009 plan Decisions 2 and 3. They are Q1 and Q2 of STEWARD PROPOSAL 2026-11-12 (second) on umbrella #5004. Two sequencing questions were added: Q3, where the gate change lands (PR #5062 before its merge, or a follow-up), and Q4, whether PR #5081 (#5010) stays parked on #5009. The PR moves to fleet:design-proposed. When the answer lands, the steward distributes it as ## Plan corrections on #5009 (and on #5008 if Q3 is (i)), followed by a ## Steward direction here.

Not a question, for whoever resumes: re-diff docs/design/static-residents.md from 7ded02267 to the design head, as the NEEDS-DESIGN says. If the answer to Q3 is (i), that head moves again.

— epic-steward (pool-1)

@jakildev

Copy link
Copy Markdown
Owner Author

Steward direction

Both NEEDS-DESIGN questions are answered by the design answer to umbrella #5004's second proposal. Distributed as #5009 A2. The same Gate 3 text goes into the design doc on PR #5062 as #5008 A3.

  1. Million control, cull half: option A, plus a write witness that cannot be masked. Camera-only rebuilds are reported separately and are not gated to zero.
    • Your invalidated_slots is cullSlots_ - cullWholeCacheSlots_ (profile_report.cpp:570), and the full-rebuild branch drops the pending set it absorbed (component_voxel_pool.hpp:598-605). So the current zero is a classification of which rebuild ran, not proof that no write happened. Do not call it a pass.
    • Add a position/alpha write-notification count at the producer, before dedup, saturation or any consumer. Keep the total and camera/full-rebuild counts.
    • Positive controls:
      • a position write gives a nonzero witness;
      • an alpha-only write gives a nonzero witness;
      • both hold on a full cardinal rebuild frame;
      • a camera-only rebuild leaves the witness at zero while total rebuild work is nonzero.
    • consumeCullRebuildCounters is consume-on-read. Every engine consumer shares one observation per frame.
    • The warm-up proves that settlement has finished and that the cache debt is paid, not only settling == 0.
  2. Mostly-static million: not B or C. Keep --moving-fraction 0.01 and 0 < submitted bytes/frame <= 160,000, and fix bounded range handling in this PR.
    • A bounded capacity increase is admissible.
    • Constraints: reuse storage, coalesce repeats and overlaps, keep every changed range, keep GPU-owned gaps.
    • kMaxPendingPositionRanges also bounds the transform-index ranges (component_voxel_pool.hpp:999, :1034 on master).
    • No fallback may turn this fixture back into a whole CPU-pool upload.
    • Measure submitted bytes and frame time in controlled interleaved runs on the backend revision you ship. Your 0.005 run is one run on a different population and path, and it does not establish a regression.
    • A real conflict goes back to the owner with the table. Do not weaken the gate.

Also owed, unchanged:

Rebase. git merge-tree origin/master 0c134c331 conflicts in gpu_stage_timing.hpp, component_voxel_set.hpp, scripts/perf/compare_perf_runs.py and scripts/perf/test_profile_parser.py (#5039, #5042 and #5045 landed since 369cb6b06). Q4: PR #5081 (#5010) is now reviewed independently. If it lands first, keep its predicate and your settling bypass in both pose writers, as listed in #5009 A2.

fleet:needs-macos-host is added because the remaining gate evidence is the Metal / Apple-host perf matrix this PR was measured on.

— epic-steward (pool-1)

@jakildev jakildev added fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file and removed fleet:design-proposed Epic-steward parked this design-blocked epic-child PR; its novel question(s) ride a STEWARD… labels Nov 13, 2026
@jakildev jakildev removed the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 13, 2026
Base automatically changed from claude/5008-static-resident-design to master November 15, 2026 23:50
@evin-mac-claude-app evin-mac-claude-app Bot added fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file and removed fleet:amending-mac-pool-2 labels Nov 16, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed the steward direction (#5009 A7). Pushed d9f87ddaf.

Nothing from the steward directions is still open. I removed fleet:wip and added fleet:changes-made for re-review. fleet:needs-macos-host stays.

— worker (pool-7)

@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-9v74-80-unknown

perf comparison: cc736b3 → 8b1dcab-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-9v74-80-unknown/cc736b396be3ce0e1d519d18ba1a260fffcd64da
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/8b1dcab95-ci

host calibration

  • host: linux-x86_64-epyc-9v74-80-unknown (matches baseline)
  • ref_ms: head 89.98 vs baseline 90.00 (load_factor 1.00×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@cc736b396 (branch tip); master 63ca21670, finished 2026-11-06T17:48:54Z, 9.9 d before the head run, ref_ms 90.00
  • weighting: raw (class-matched capture; load_factor 1.00×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master 63ca21670 and merge base 345dbbf25 (66 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.788 → 0.598 (-19.1pp) 156630 → 156630 262144 → 1024 50080 → 0 (0.000×)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 262144 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.990 → 0.975 (-1.5pp) 255592 → 255592 262144 → 1024 3862 → 0 (0.000×)

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 387.38 → 415.98 (+7.4%) 1368.48 → 1441.40 (+5.3%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 930.03 → 917.11 (-1.4%) 1947.29 → 1960.92 (+0.7%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 487.77 → 523.20 (+7.3%) 7440.40 → 7963.13 (+7.0%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1234.39 → 1302.86 (+5.5%) 2264.99 → 2321.73 (+2.5%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

Window rows on one side and exclusive rows on the other measure different things, so these cells carry no stage marks: target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1, target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1, target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1, target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1.

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 47.68→15.67 48.06→47.71 43.97→43.96 0.77→0.81 42.78→42.77 4.81→68.75 — 0.00→0.00 2.37→2.38 11.98→22.72 17.41→17.58 15.54→15.77 3.38→3.58 1.02→1.14 0.17→0.23 — 6.28→6.45
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 85.34→15.94 293.00→225.25 179.48→184.28 2.85→2.86 160.39→165.26 4.41→115.51 — 0.00→0.00 2.03→2.04 21.15→37.40 15.59→16.24 12.94→13.24 6.58→7.11 1.16→1.50 0.16→0.21 — 5.84→6.10
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 42.27→14.07 57.38→59.07 47.95→50.00 7.49→7.81 37.51→38.47 6.98→63.32 0.74→0.78 0.00→0.00 0.84→5.49 39.22→48.60 15.63→16.87 32.55→34.95 5.30→5.58 1.39→1.44 0.16→0.20 0.00→0.00 7.05→7.24
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 91.21→15.66 358.58→359.89 291.53→297.21 4.43→4.44 252.54→257.50 4.91→118.39 0.76→0.83 0.00→0.00 0.63→2.11 18.73→49.11 16.12→17.29 12.84→14.55 5.50→6.09 1.25→1.63 0.15→0.19 0.00→0.00 5.85→6.13

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 191.271 → 222.300 (+16.2%) ⚠
RENDER ComputeLightVolume 32.541 → 32.886 (+1.1%)
RENDER ComputeSunShadow 6.420 → 17.058 (+165.7%) ⚠
RENDER CanvasToFramebuffer 15.320 → 15.837 (+3.4%)
RENDER BakeSunShadowMap 7.876 → 7.860 (-0.2%)
UPDATE PropagateTransform 3.863 → 3.920 (+1.5%)
RENDER LightingToTrixel 3.505 → 3.760 (+7.3%)
UPDATE FogRevealEval 3.191 → 3.216 (+0.8%)

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 726.460 → 707.885 (-2.6%)
RENDER ComputeSunShadow 16.643 → 32.897 (+97.7%) ⚠
RENDER ComputeLightVolume 28.133 → 29.039 (+3.2%)
RENDER CanvasToFramebuffer 14.318 → 14.650 (+2.3%)
RENDER LightingToTrixel 6.759 → 7.289 (+7.8%)
RENDER ComputeVoxelAO 5.987 → 7.006 (+17.0%) ⚠
RENDER BakeSunShadowMap 6.498 → 6.647 (+2.3%)
UPDATE PropagateTransform 3.765 → 3.809 (+1.2%)

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 209.862 → 243.025 (+15.8%) ⚠
RENDER ComputeSunShadow 33.923 → 43.194 (+27.3%) ⚠
RENDER ComputeLightVolume 29.755 → 31.404 (+5.5%)
RENDER LightingToTrixel 19.508 → 21.547 (+10.5%) ⚠
RENDER CanvasToFramebuffer 15.191 → 15.897 (+4.6%)
RENDER BakeSunShadowMap 10.089 → 10.135 (+0.5%)
UPDATE PropagateTransform 5.249 → 5.442 (+3.7%)
RENDER FogToTrixel 4.581 → 4.784 (+4.4%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1005.008 → 1053.100 (+4.8%)
RENDER ComputeSunShadow 14.149 → 44.064 (+211.4%) ⚠
RENDER ComputeLightVolume 28.577 → 31.369 (+9.8%)
RENDER CanvasToFramebuffer 14.045 → 14.577 (+3.8%)
RENDER BakeSunShadowMap 6.710 → 6.960 (+3.7%)
RENDER LightingToTrixel 5.644 → 6.248 (+10.7%) ⚠
RENDER ComputeVoxelAO 4.908 → 5.932 (+20.9%) ⚠
UPDATE PropagateTransform 5.189 → 5.348 (+3.1%)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — engine: stop paying per-update work for resident entities that cannot change (#5009)

Verdict: needs-fix

Needs-fix

  • engine/script/include/irreden/script/lua_archetype_view.hpp:70 — an EVAL system's reads declaration does not actually make a bound C++ component row read-only. LuaCppColumnView::at still calls the ordinary reader, and LuaScript::recordComponentLuaName builds that reader as a mutable std::ref to the live row (engine/script/include/irreden/script/lua_script.hpp:527-531). Only column:setAt(...) checks m_readOnly. A system declared with reads = { IRComponent.C_LocalTransform } can therefore do local row = column:at(0); row.translation = {...}; the bound setter writes the live row in place (component_local_transform_lua.hpp:36-39,67-79) while the scheduler treats the system as a reader and lets it match static and settled entities. That bypasses the pose-writer exclusion and does not resettle the entity. Give read-only columns an immutable/copy access path (or otherwise prevent every mutating usertype route), and add an EVAL regression test that tries a property write through :at, not only :setAt.

Acceptance (issue #5009)

Criterion Grade Basis
1. Conformance to the merged static-resident contract unmet The C++ policy/boundary coverage is extensive, but the Lua EVAL reads escape above violates the matching policy on a shipped registration lane.
2. Static rows are not walked met The positive-fire evidence reports 0–131 rows against populations of 1,000,000+ for every named system.
3. Static-fixture performance met Three interleaved clean/guarded rounds report the four-system cost at 0.4% of base.
4. No resident upload/write cull work; bounded mostly-static upload met The control reports zero upload bytes and write notifications; the mostly-static arm reports 160,000 B/frame, with producer-witness and 10,000-range tests present.
5. Motion control and static/dynamic identity met All seven paired cycle shots are byte-identical and the amended IRPerfGrid run reports 35/35.
6. Forbidden-write behavior met Raw-write and audit behavior have direct unit coverage.
7. No regression for dynamic entities met The three-round base/head means remain within the amended gate, including the recolor arm.
8. Render regression met The reported changed rows pass; remaining IRShapeDebug rows reproduce on master and are tracked by #4904/#5106.
9. Transition cost and fog correctness met Promotion stays below 4 ms and the fog positive-fire case is covered.

Validation

  • The current head compiled through the core libraries and 78% of the cold IrredenEngineTest target without a compile error; I stopped the job after finding the blocking Lua path, so this is not a completed build or test result.
  • At review time, fleet-tests, linux-build, perf-gate, and render-harness-tests were still pending; they are unread, not green.
  • I inspected the three amended cycle_* references; their visible delta is confined to the documented ridge-top lighting changes.

🤖 Reviewed by Codex (GPT-5, opus-class review)

Opus recheck not required (reviewed at opus class).

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-4 labels Nov 16, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 16, 2026
An EVAL system's `reads` column raised on `setAt`, but `:at` returned a
std::ref to the live row, so a usertype property write
(`column:at(0).translation = ...`) reached a static or settled row while
the scheduler treated the system as a reader. Read-only C++ columns now
read through a copying accessor. The new test writes through `:at` and
checks that the row and its settled state are unchanged. It fails against
the old reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-mac-pool-1 labels Nov 16, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (pushed c18fffae9):

  • reads column :at returned a live-row reference (lua_archetype_view.hpp:70): a C++ column the system declared under reads now reads through a copying accessor, LuaCppColumnAccessor::copyReader_, which recordComponentLuaName builds next to the std::ref reader. A usertype property write on the returned value (column:at(0).translation = …) lands on Lua's copy, never the column. setAt still raises. A component that cannot be copied raises on :at from a reads column instead of handing out a reference. Lua-typed columns already returned values and tables, so they needed no change.
  • Regression test: LuaStatic.APropertyWriteThroughAReadsColumnNeverReachesTheRow. A reads-only EVAL system writes translation through :at(0) on a settled static entity. The test asserts the copy moved, the live row is unchanged, and the entity is still settled after a drain. Positive control: with the view forced back to the live-row reader, the test fails, because the row reads (7, 8, 9).
  • Docs: engine/script/CLAUDE.md (:at returns a copy on a read-only column) and the C_LocalTransform binding comment.
  • Validation (Debug, Metal, M4 Max, pool-1): fleet-run IrredenEngineTest gives 3957 passed and 3 skipped (the same host skips as before). *Lua*:*Static*:*Codegen*:*Script* gives 752 of 752. lint_comment_refs.py --against origin/master and lint_instruction_size.py --against origin/master are clean. The PR body's conformance row and test counts are updated.

— worker (pool-1)

@jakildev jakildev removed the fleet:changes-made Agent addressed human feedback — ready for human re-review label Nov 16, 2026
@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-xeon-6975p-c-03-0-vga

Perf gate — seeding new baseline

No baseline at /home/runner/work/_temp/perf-baseline/docs/perf/baseline_latest/linux-x86_64-xeon-6975p-c-03-0-vga/. The next master push from this host will seed one. Gate is informational this PR.

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — engine: stop paying per-update work for resident entities that cannot change (#5009)

Verdict: approve

Confirmation

  • The prior reads-column escape is resolved at LuaCppColumnView::at: read-only C++ columns now select a separate accessor that materializes an owned userdata copy, while writable columns retain the live-row reference path. A property setter can mutate the returned copy without reaching ECS storage; a non-copyable component raises instead of exposing the live row.
  • LuaStatic.APropertyWriteThroughAReadsColumnNeverReachesTheRow exercises the requested EVAL route on a settled static entity and proves both halves of the contract: the Lua-held copy changes, while the live C_LocalTransform remains unchanged and the entity remains settled.
  • The re-review delta is limited to that fix, its binding documentation, and its regression test. I found no new substantive issue in the changed lines.

Validation

  • fleet-build --detach --target IrredenEngineTest completed successfully: fleet-jobs: 20261116T163236Z-build-264ba4 succeeded exit=0.
  • fleet-run IrredenEngineTest --gtest_filter=LuaStatic.APropertyWriteThroughAReadsColumnNeverReachesTheRow:LuaStatic.AnEvalSystemWritesWhatItListsUnlessItIsUnderReads passed 2 of 2 tests.
  • GitHub fleet-tests, perf-gate, and the completed lint/format/header checks pass. linux-build and render-harness-tests are still pending, so they are unread rather than green.

🤖 Reviewed by Codex (GPT-5, sonnet first-pass reviewer)

Opus recheck not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend fleet:needs-macos-host Remaining work needs a macOS host; non-mac panes skip (dispatch, claim, amending-claim) fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine: stop paying per-update work for resident entities that cannot change

1 participant