Cut 12.2 Soul fix batch 2, S3: measure allocations, correct an overclaiming comment
Measured (Release, 7x9 solid hull -- the LonginusX shipped-hull fixture the brief named is not available to this test file): - Lane: 0 B / 1000 calls (was: 64 B/call from Array.Sort's comparer wrapper; now confirmed 0 after the earlier IComparable<T> change in this batch). - Silhouette (caller-supplied buffer): 0 B / 1000 calls. - HitProbability, gated in (a real, non-gated-out call): ~120 B/call. This is NOT from Lane, Silhouette or the comparer -- it comes from Accuracy/ Resolution's own GetBehavior<T>, which walks Entity.Equipment and each item's Behaviors (both ReactiveCollection<T>); that type's enumerator is heap-allocated per foreach. This predates Cut 12.2 and is out of this cut's scope to fix. - Inspect, gated in: ~280 B/call (same cause, more GetBehavior<T> calls). The Forecast comment claiming "the forecast path (HitProbability, Inspect) no longer allocates on a gated-in call" was not true and is corrected to say what was actually measured: Silhouette itself is allocation-free given a pooled buffer, and the residual cost belongs to Entity's own collection choice. LaneAndSilhouetteAllocateNothingGivenAPooledBuffer asserts the true zero-alloc claims exactly and records (with a loose regression bound, not a false zero) the unrelated Entity-level cost on the full HitProbability path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
73c53a9335
commit
ca1670a216
2 changed files with 57 additions and 1 deletions
|
|
@ -188,9 +188,17 @@ public static class FireControl
|
|||
// the same thing are two places for the same bug to hide and only be found once.
|
||||
// Cost fix batch (Self, 2026-09-24): Forecast reads only sil.POnHull and sil.Span, never sil.Intervals, so
|
||||
// it rents the Silhouette's own scratch array from ArrayPool<Interval>.Shared and returns it before
|
||||
// returning -- the forecast path (HitProbability, Inspect) no longer allocates on a gated-in call.
|
||||
// returning -- Silhouette itself (given this pooled buffer) allocates nothing, measured directly.
|
||||
// Commit's own path (CommitProbability -> Silhouette, uncalled from here) still needs sil.Intervals alive
|
||||
// for the lateral draw that follows it, so it keeps its own owned array; only the forecast pools.
|
||||
// S3 fix batch (Hands, 2026-09-25) correction: "the forecast path no longer allocates on a gated-in call"
|
||||
// overclaimed -- a gated-in HitProbability/Inspect call still allocates roughly 120/280 bytes respectively
|
||||
// (measured, Release), from Accuracy/Resolution's own GetBehavior<T> walking Entity.Equipment and each
|
||||
// item's Behaviors (both ReactiveCollection<T>, whose enumerator is heap-allocated per foreach), not from
|
||||
// anything Silhouette or this pooling touches. That cost predates Cut 12.2 and belongs to Entity's own
|
||||
// collection choice; it is out of this cut's scope. Cut 10's own guard is what actually matters
|
||||
// operationally: HitProbability and CommitProbability both bail before Forecast is ever called for the
|
||||
// common gated-out case (GatedOutHitProbabilityAllocatesNothing pins that at exactly 0).
|
||||
private static (Silhouette Silhouette, float PSpread) Forecast(Weapon weapon, Entity source, Entity target, HullData targetHull, float precision, float range)
|
||||
{
|
||||
var bearing = Bearing(target, TravelDirection(weapon, source, target));
|
||||
|
|
|
|||
Loading…
Reference in a new issue