feat(streaming): enforce typed completion queues
Replace the flat deferred list, priority scan, unload bypass, and count-only execution cap with exact destination/control/unload/Near/Far FIFOs behind one typed frame meter. Price worker results before adoption, retain exact retry identity, reject stale generations without payload retention, and publish queue pressure through lifecycle diagnostics. Tests: dotnet build AcDream.slnx -c Release --no-restore; dotnet test AcDream.slnx -c Release --no-restore (8138 passed, 5 skipped)
This commit is contained in:
parent
ac45cb1bd7
commit
b8f6317fe1
15 changed files with 1261 additions and 336 deletions
|
|
@ -159,7 +159,13 @@ public readonly record struct StreamingWorkDiagnostics(
|
|||
long DeferredAdoptedCpuBytes,
|
||||
double OldestDeferredAgeMilliseconds,
|
||||
int PendingPublications,
|
||||
int PendingRetirements);
|
||||
int PendingRetirements,
|
||||
int WorkerCompletionBacklog,
|
||||
int DestinationBacklog,
|
||||
int ControlBacklog,
|
||||
int UnloadBacklog,
|
||||
int NearBacklog,
|
||||
int FarBacklog);
|
||||
|
||||
/// <summary>
|
||||
/// Single-thread, frame-scoped admission meter. Callers reserve a known cost
|
||||
|
|
@ -180,6 +186,7 @@ public sealed class StreamingWorkMeter
|
|||
private int _failures;
|
||||
private bool _frameOverrunRecorded;
|
||||
private bool _reservationActive;
|
||||
private bool _ensuredProgressGranted;
|
||||
private string? _activeStage;
|
||||
private string? _lastStage;
|
||||
private StreamingWorkLimit _lastLimit;
|
||||
|
|
@ -207,7 +214,8 @@ public sealed class StreamingWorkMeter
|
|||
|
||||
public StreamingWorkAdmission TryReserve(
|
||||
StreamingWorkCost cost,
|
||||
string stage)
|
||||
string stage,
|
||||
bool ensureProgress = false)
|
||||
{
|
||||
cost.Validate();
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(stage);
|
||||
|
|
@ -216,7 +224,11 @@ public sealed class StreamingWorkMeter
|
|||
"The prior streaming operation has not completed.");
|
||||
|
||||
StreamingWorkLimit limit = FindLimit(cost);
|
||||
if (limit != StreamingWorkLimit.None && _operations != 0)
|
||||
bool grantEnsuredProgress =
|
||||
ensureProgress && !_ensuredProgressGranted;
|
||||
if (limit != StreamingWorkLimit.None
|
||||
&& _operations != 0
|
||||
&& !grantEnsuredProgress)
|
||||
{
|
||||
_yields++;
|
||||
_lastStage = stage;
|
||||
|
|
@ -228,14 +240,21 @@ public sealed class StreamingWorkMeter
|
|||
_operations++;
|
||||
_reservationActive = true;
|
||||
_activeStage = stage;
|
||||
_lastStage = stage;
|
||||
_lastLimit = limit;
|
||||
if (ensureProgress)
|
||||
_ensuredProgressGranted = true;
|
||||
if (limit != StreamingWorkLimit.None)
|
||||
{
|
||||
_lastStage = stage;
|
||||
_lastLimit = limit;
|
||||
_oversizedProgress++;
|
||||
return StreamingWorkAdmission.OversizedProgress;
|
||||
}
|
||||
|
||||
// Preserve the most recent constrained stage so later successful work
|
||||
// in another budget dimension cannot erase the reason this frame
|
||||
// yielded. With no constraint, retain the ordinary last-stage fact.
|
||||
if (_lastLimit == StreamingWorkLimit.None)
|
||||
_lastStage = stage;
|
||||
return StreamingWorkAdmission.Admitted;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue