test: stabilize load-sensitive release contracts

This commit is contained in:
Erik 2026-08-18 11:50:23 +02:00
parent c8c764a40e
commit dfc841b779
8 changed files with 199 additions and 43 deletions

View file

@ -2372,13 +2372,24 @@ public sealed class RuntimeCollisionReportingStateTests
Collisions(target.Key!.Value.LocalEntityId);
Assert.False(Handle(lifetime, owner, 1d, collision));
_ = GC.GetAllocatedBytesForCurrentThread();
long before = GC.GetAllocatedBytesForCurrentThread();
// One call does not cross tiered-JIT/PGO thresholds for this stack.
// Warm the same steady-contact path at the measured batch size.
for (int index = 0; index < 10_000; index++)
_ = Handle(lifetime, owner, 1.1d, collision);
long allocated = GC.GetAllocatedBytesForCurrentThread() - before;
Assert.Equal(0, allocated);
long minimumAllocated = long.MaxValue;
for (int sample = 0; sample < 5; sample++)
{
long before = GC.GetAllocatedBytesForCurrentThread();
for (int index = 0; index < 10_000; index++)
_ = Handle(lifetime, owner, 1.1d, collision);
long allocated = GC.GetAllocatedBytesForCurrentThread() - before;
minimumAllocated = Math.Min(minimumAllocated, allocated);
}
// A real per-refresh regression allocates in every batch; a one-time
// tier transition does not invalidate the warmed steady-state claim.
Assert.Equal(0, minimumAllocated);
Assert.Equal(1, lifetime.Physics.CollisionReports.CaptureOwnership()
.TrackedObjectCount);
}