perf(streaming): reserve destination reveal capacity
Join destination scheduling to the canonical reveal generation, protect its share across every typed frame-budget dimension, and prevent stale work from clearing a replacement reservation. Remove forced incomplete materialization and project retail's centered portal wait cue while the authored tunnel remains active. Tests: Release build clean; 91 focused reservation/reveal tests; full solution 8,158 passed, 5 skipped. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
98f1ac8934
commit
2ff8f844b0
33 changed files with 870 additions and 230 deletions
|
|
@ -117,6 +117,110 @@ public sealed class StreamingWorkBudgetTests
|
|||
meter.Snapshot.LastLimit);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ActiveReveal_ProtectsDestinationShareAcrossEveryCountAndByteDimension()
|
||||
{
|
||||
var meter = new StreamingWorkMeter(
|
||||
Budget(
|
||||
milliseconds: 100,
|
||||
completions: 4,
|
||||
cpuBytes: 100,
|
||||
entityOperations: 8,
|
||||
gpuBytes: 100,
|
||||
retireOperations: 4),
|
||||
static () => 0,
|
||||
timestampFrequency: 1_000,
|
||||
destinationReservationActive: true);
|
||||
|
||||
StreamingWorkCost unreservedShare = new(
|
||||
CompletionAdmissions: 1,
|
||||
AdoptedCpuBytes: 25,
|
||||
EntityOperations: 2,
|
||||
GpuUploadBytes: 25,
|
||||
GlRetireOperations: 1);
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Admitted,
|
||||
meter.TryReserve(unreservedShare, "ordinary"));
|
||||
meter.Complete();
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Yielded,
|
||||
meter.TryReserve(
|
||||
new StreamingWorkCost(CompletionAdmissions: 1),
|
||||
"ordinary-over-reserve"));
|
||||
|
||||
using (meter.EnterLane(StreamingWorkLane.Destination))
|
||||
{
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Admitted,
|
||||
meter.TryReserve(
|
||||
new StreamingWorkCost(
|
||||
CompletionAdmissions: 3,
|
||||
AdoptedCpuBytes: 75,
|
||||
EntityOperations: 6,
|
||||
GpuUploadBytes: 75,
|
||||
GlRetireOperations: 3),
|
||||
"destination"));
|
||||
meter.Complete();
|
||||
}
|
||||
|
||||
StreamingWorkMeterSnapshot snapshot = meter.Snapshot;
|
||||
Assert.Equal(unreservedShare, snapshot.NonDestinationUsed);
|
||||
Assert.Equal(3, snapshot.DestinationUsed.CompletionAdmissions);
|
||||
Assert.Equal(100, snapshot.Used.AdoptedCpuBytes);
|
||||
Assert.Equal(100, snapshot.Used.GpuUploadBytes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InactiveReveal_DoesNotApplyDestinationReservation()
|
||||
{
|
||||
var meter = new StreamingWorkMeter(
|
||||
Budget(completions: 4),
|
||||
static () => 0,
|
||||
timestampFrequency: 1_000,
|
||||
destinationReservationActive: false);
|
||||
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Admitted,
|
||||
meter.TryReserve(
|
||||
new StreamingWorkCost(CompletionAdmissions: 4),
|
||||
"ordinary"));
|
||||
meter.Complete();
|
||||
|
||||
Assert.Equal(4, meter.Snapshot.NonDestinationUsed.CompletionAdmissions);
|
||||
Assert.Equal(0, meter.Snapshot.DestinationUsed.CompletionAdmissions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ActiveReveal_ProtectsDestinationWallClockAfterOrdinaryShareIsSpent()
|
||||
{
|
||||
long now = 0;
|
||||
var meter = new StreamingWorkMeter(
|
||||
Budget(milliseconds: 100),
|
||||
() => now,
|
||||
timestampFrequency: 1_000,
|
||||
destinationReservationActive: true);
|
||||
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Admitted,
|
||||
meter.TryReserve(default, "ordinary"));
|
||||
now = 25;
|
||||
meter.Complete();
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Yielded,
|
||||
meter.TryReserve(default, "ordinary-after-25ms"));
|
||||
|
||||
using (meter.EnterLane(StreamingWorkLane.Destination))
|
||||
{
|
||||
Assert.Equal(
|
||||
StreamingWorkAdmission.Admitted,
|
||||
meter.TryReserve(default, "destination"));
|
||||
now = 99;
|
||||
meter.Complete();
|
||||
}
|
||||
|
||||
Assert.Equal(2, meter.Snapshot.CompletedOperations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MeterUsesInjectedMonotonicClockAndRecordsOverrunAndFailure()
|
||||
{
|
||||
|
|
@ -427,21 +531,32 @@ public sealed class StreamingWorkBudgetTests
|
|||
cpuBytes: 1_000,
|
||||
gpuBytes: 44,
|
||||
retireOperations: 1));
|
||||
controller.PriorityLandblockId = center;
|
||||
controller.BeginDestinationReservation(1, center, 0);
|
||||
|
||||
controller.Tick(32, 32);
|
||||
|
||||
Assert.Equal([center], applied);
|
||||
Assert.Equal(1, controller.WorkDiagnostics.DeferredCompletions);
|
||||
Assert.Equal(1, controller.WorkDiagnostics.LastFrame.YieldCount);
|
||||
Assert.Equal(2, controller.WorkDiagnostics.LastFrame.YieldCount);
|
||||
Assert.Equal(44, controller.WorkDiagnostics.LastFrame.Used.GpuUploadBytes);
|
||||
Assert.Equal(0, controller.WorkDiagnostics.LastFrame.Used.GlRetireOperations);
|
||||
|
||||
controller.Tick(32, 32);
|
||||
|
||||
Assert.Equal([center, ordinary], applied);
|
||||
Assert.Equal(0, controller.WorkDiagnostics.DeferredCompletions);
|
||||
Assert.Equal(0, controller.WorkDiagnostics.LastFrame.Used.GlRetireOperations);
|
||||
|
||||
for (int i = 0;
|
||||
i < 4
|
||||
&& (controller.WorkDiagnostics.DeferredCompletions != 0
|
||||
|| source.BacklogCount != 0);
|
||||
i++)
|
||||
{
|
||||
controller.Tick(32, 32);
|
||||
}
|
||||
|
||||
Assert.Equal(0, controller.WorkDiagnostics.DeferredCompletions);
|
||||
Assert.Equal(0, source.BacklogCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue