perf(physics): reuse reset-complete transition scratch

Mirror retail's ten-deep LIFO transition lifetime, retain all query scratch with complete reset contracts, and remove Tier-0 enum boxing without changing collision decisions. Fresh and retained engines are bit-identical across the expanded oracle, while measured transition profiles now allocate 0 bytes per resolve.
This commit is contained in:
Erik 2026-07-25 14:37:02 +02:00
parent 2effba5127
commit 16d182c2f0
19 changed files with 3037 additions and 1228 deletions

View file

@ -327,7 +327,7 @@ covered by a zero-managed-allocation test. Evidence:
## #237 — PhysicsEngine allocates a fresh Transition graph per resolve call
**Status:** OPEN
**Status:** DONE — 2026-07-25, Modern Runtime Slice I1
**Severity:** MEDIUM
**Filed:** 2026-07-24
**Component:** physics
@ -339,14 +339,21 @@ NPC/remote, projectiles, and the camera probe — per-tick GC pressure that
scales with active-mover count (combat/crowds), a scenario the audit's
dwell-heavy route under-measured.
**Root cause / status:** 2026-07-24 audit review finding. Pooling is only
allowed under plan Slice I's identity/lifetime-test condition (the adjacent
`LiveEntityAnimationScheduler` scratch-reuse pattern is the precedent) —
Transition state must be provably reset-complete between movers or a pooled
graph corrupts collision state, which is worse than the allocation.
**Resolution:** Each `PhysicsEngine` now owns retail-shaped ten-deep,
same-thread, LIFO transition scratch. Every stored member is reset and
reflection-poisoned in tests; exact-length walkable, candidate-cell, collision
GUID, and reentrant neighbor-order storage retains identity without exposing
stale state. Fresh-vs-reused engines are bit-identical across hostile
player/remote/projectile/camera/placement/failure/step/slide cases. Release
allocation fell from 2,5126,848 B/resolve to 0 B/resolve for all measured
mover profiles. Evidence:
`docs/research/2026-07-25-slice-i1-transition-scratch.md`.
**Files:** `src/AcDream.Core/Physics/PhysicsEngine.cs:995`;
`src/AcDream.Core/Physics/TransitionTypes.cs:360-367,694-698`.
**Files:** `src/AcDream.Core/Physics/TransitionScratchArena.cs`;
`src/AcDream.Core/Physics/PhysicsEngine.cs`;
`src/AcDream.Core/Physics/TransitionTypes.cs`;
`tests/AcDream.Core.Tests/Physics/TransitionScratchResetTests.cs`;
`tests/AcDream.Core.Tests/Physics/TransitionScratchDifferentialTests.cs`.
---