test(streaming): enforce slice E physical evidence
Record route-lifetime streaming overruns and maximum operation costs, require canonical reveal/resource convergence at every connected checkpoint, and keep recenter semantics independent of the production wall-clock budget. Co-authored-by: Erik Nilsson <erikn@users.noreply.github.com>
This commit is contained in:
parent
2ff8f844b0
commit
621f70eab6
6 changed files with 215 additions and 4 deletions
|
|
@ -69,6 +69,12 @@ public sealed class StreamingController
|
|||
private long _nextCompletionSequence;
|
||||
private int _legacyCompletionProfile = 4;
|
||||
private DestinationReservation? _destinationReservation;
|
||||
private long _lifetimeWorkOverruns;
|
||||
private long _lifetimeOversizedProgress;
|
||||
private double _maximumWorkFrameMilliseconds;
|
||||
private string? _maximumWorkFrameStage;
|
||||
private double _maximumWorkOperationMilliseconds;
|
||||
private string? _maximumWorkOperationStage;
|
||||
|
||||
private readonly GpuWorldState _state;
|
||||
private StreamingRegion? _region;
|
||||
|
|
@ -190,6 +196,12 @@ public sealed class StreamingController
|
|||
_completionQueue.CaptureSnapshot();
|
||||
return new StreamingWorkDiagnostics(
|
||||
_lastWorkMeter,
|
||||
_lifetimeWorkOverruns,
|
||||
_lifetimeOversizedProgress,
|
||||
_maximumWorkFrameMilliseconds,
|
||||
_maximumWorkFrameStage,
|
||||
_maximumWorkOperationMilliseconds,
|
||||
_maximumWorkOperationStage,
|
||||
queued.Count,
|
||||
queued.RetainedCpuBytes,
|
||||
queued.OldestAgeMilliseconds,
|
||||
|
|
@ -690,11 +702,42 @@ public sealed class StreamingController
|
|||
finally
|
||||
{
|
||||
meter.FinishFrame();
|
||||
_lastWorkMeter = meter.Snapshot;
|
||||
StreamingWorkMeterSnapshot snapshot = meter.Snapshot;
|
||||
ObserveWorkLifetime(snapshot);
|
||||
_lastWorkMeter = snapshot;
|
||||
_activeWorkMeter = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ObserveWorkLifetime(StreamingWorkMeterSnapshot snapshot)
|
||||
{
|
||||
_lifetimeWorkOverruns = SaturatingAdd(
|
||||
_lifetimeWorkOverruns,
|
||||
snapshot.OverrunCount);
|
||||
_lifetimeOversizedProgress = SaturatingAdd(
|
||||
_lifetimeOversizedProgress,
|
||||
snapshot.OversizedProgressCount);
|
||||
|
||||
if (_maximumWorkFrameStage is null
|
||||
|| snapshot.ElapsedMilliseconds > _maximumWorkFrameMilliseconds)
|
||||
{
|
||||
_maximumWorkFrameMilliseconds = snapshot.ElapsedMilliseconds;
|
||||
_maximumWorkFrameStage = snapshot.LastStage;
|
||||
}
|
||||
|
||||
if (_maximumWorkOperationStage is null
|
||||
|| snapshot.MaximumOperationMilliseconds
|
||||
> _maximumWorkOperationMilliseconds)
|
||||
{
|
||||
_maximumWorkOperationMilliseconds =
|
||||
snapshot.MaximumOperationMilliseconds;
|
||||
_maximumWorkOperationStage = snapshot.MaximumOperationStage;
|
||||
}
|
||||
}
|
||||
|
||||
private static long SaturatingAdd(long left, int right) =>
|
||||
left > long.MaxValue - right ? long.MaxValue : left + right;
|
||||
|
||||
private void AdvanceRadiiReconfiguration()
|
||||
{
|
||||
if (_advancingRadiiReconfiguration)
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ public readonly record struct StreamingWorkMeterSnapshot(
|
|||
int OversizedProgressCount,
|
||||
int FailureCount,
|
||||
double ElapsedMilliseconds,
|
||||
double MaximumOperationMilliseconds,
|
||||
string? MaximumOperationStage,
|
||||
string? LastStage,
|
||||
StreamingWorkLimit LastLimit);
|
||||
|
||||
|
|
@ -163,6 +165,12 @@ public readonly record struct StreamingWorkMeterSnapshot(
|
|||
/// </summary>
|
||||
public readonly record struct StreamingWorkDiagnostics(
|
||||
StreamingWorkMeterSnapshot LastFrame,
|
||||
long LifetimeFrameOverrunCount,
|
||||
long LifetimeOversizedProgressCount,
|
||||
double MaximumFrameMilliseconds,
|
||||
string? MaximumFrameStage,
|
||||
double MaximumOperationMilliseconds,
|
||||
string? MaximumOperationStage,
|
||||
int DeferredCompletions,
|
||||
long DeferredAdoptedCpuBytes,
|
||||
double OldestDeferredAgeMilliseconds,
|
||||
|
|
@ -193,6 +201,8 @@ public sealed class StreamingWorkMeter
|
|||
private long _destinationElapsedTicks;
|
||||
private long _nonDestinationElapsedTicks;
|
||||
private long _activeOperationStart;
|
||||
private double _maximumOperationMilliseconds;
|
||||
private string? _maximumOperationStage;
|
||||
private int _operations;
|
||||
private int _completed;
|
||||
private int _yields;
|
||||
|
|
@ -303,8 +313,8 @@ public sealed class StreamingWorkMeter
|
|||
CompleteLaneTiming();
|
||||
_completed++;
|
||||
_reservationActive = false;
|
||||
_activeStage = null;
|
||||
ObserveElapsedOverrun();
|
||||
_activeStage = null;
|
||||
}
|
||||
|
||||
public void Fail()
|
||||
|
|
@ -313,8 +323,8 @@ public sealed class StreamingWorkMeter
|
|||
CompleteLaneTiming();
|
||||
_failures++;
|
||||
_reservationActive = false;
|
||||
_activeStage = null;
|
||||
ObserveElapsedOverrun();
|
||||
_activeStage = null;
|
||||
}
|
||||
|
||||
public void FinishFrame()
|
||||
|
|
@ -341,6 +351,8 @@ public sealed class StreamingWorkMeter
|
|||
_oversizedProgress,
|
||||
_failures,
|
||||
ElapsedMilliseconds(now),
|
||||
_maximumOperationMilliseconds,
|
||||
_maximumOperationStage,
|
||||
_lastStage,
|
||||
_lastLimit);
|
||||
}
|
||||
|
|
@ -428,6 +440,13 @@ public sealed class StreamingWorkMeter
|
|||
private void CompleteLaneTiming()
|
||||
{
|
||||
long raw = Math.Max(0L, _timestamp() - _activeOperationStart);
|
||||
double elapsedMilliseconds = raw * 1000.0 / _frequency;
|
||||
if (_maximumOperationStage is null
|
||||
|| elapsedMilliseconds > _maximumOperationMilliseconds)
|
||||
{
|
||||
_maximumOperationMilliseconds = elapsedMilliseconds;
|
||||
_maximumOperationStage = _activeStage;
|
||||
}
|
||||
long elapsed = raw > long.MaxValue / TimeSpan.TicksPerSecond
|
||||
? long.MaxValue
|
||||
: raw * TimeSpan.TicksPerSecond / _frequency;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue