perf(runtime): remove measured steady allocations

Eliminate boxed production surface-override enumeration, retain vital modifier projections until the enchantment registry mutates, and measure DAT font widths without allocating a captured delegate. Preserve exact hashes, spell stacking, and glyph advances with warmed zero-allocation tests.

Validated by the focused rendering, UI, and spell suites, a zero-error Release build, and 8,409 passing Release tests with five pre-existing skips.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-25 17:50:30 +02:00
parent 574a6c454f
commit feb80a67d9
6 changed files with 188 additions and 14 deletions

View file

@ -848,18 +848,33 @@ internal sealed class CurrentRenderSceneOracle :
ulong xorHigh = 0;
ulong sumLow = 0;
ulong sumHigh = 0;
foreach ((uint surfaceId, uint replacementId) in overrides)
if (overrides is Dictionary<uint, uint> dictionary)
{
StableRenderHash128 pair = StableRenderHash128.Create();
pair.Add(surfaceId);
pair.Add(replacementId);
RenderSceneHash128 value = pair.Finish();
xorLow ^= value.Low;
xorHigh ^= value.High;
unchecked
// Production hydration owns Dictionary instances. Enumerating
// through IReadOnlyDictionary boxes Dictionary.Enumerator for
// every live mesh on both projection-sync phases.
foreach (KeyValuePair<uint, uint> pair in dictionary)
{
sumLow += value.Low;
sumHigh += value.High;
Accumulate(
pair.Key,
pair.Value,
ref xorLow,
ref xorHigh,
ref sumLow,
ref sumHigh);
}
}
else
{
foreach ((uint surfaceId, uint replacementId) in overrides)
{
Accumulate(
surfaceId,
replacementId,
ref xorLow,
ref xorHigh,
ref sumLow,
ref sumHigh);
}
}
@ -870,6 +885,27 @@ internal sealed class CurrentRenderSceneOracle :
geometry.Add(sumLow);
geometry.Add(sumHigh);
return geometry.Finish();
static void Accumulate(
uint surfaceId,
uint replacementId,
ref ulong xorLow,
ref ulong xorHigh,
ref ulong sumLow,
ref ulong sumHigh)
{
StableRenderHash128 pairHash = StableRenderHash128.Create();
pairHash.Add(surfaceId);
pairHash.Add(replacementId);
RenderSceneHash128 value = pairHash.Finish();
xorLow ^= value.Low;
xorHigh ^= value.High;
unchecked
{
sumLow += value.Low;
sumHigh += value.High;
}
}
}
internal static RenderSceneHash128 FingerprintSelectionGeometry(