fix(diag): probe-owned inbound depth counter - SingleReader channels have no Count

The first armed ACDREAM_PROBE_NET launch died at exit 4 one second into
the world: the [net-tick] line read _inboundQueue.Reader.Count, but the
queue is built with SingleReader=true and that channel implementation
throws NotSupportedException from Count. The net thread now increments
and the frame thread decrements a probe-owned Interlocked counter
instead; behavior with the probe off is untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-29 08:56:17 +02:00
parent 534bacbc23
commit d6a2e595c8

View file

@ -995,6 +995,8 @@ public sealed class WorldSession : IDisposable
while (_inboundQueue.Reader.TryRead(
out PooledInboundDatagram datagram))
{
if (NetDiagnostics.ProbeNet)
Interlocked.Decrement(ref _probeInboundDepth);
try
{
ProcessDatagram(datagram.Memory);
@ -1034,6 +1036,10 @@ public sealed class WorldSession : IDisposable
private int _probeBudgetBreaks;
private int _probeSendWindow;
private int _probeAckWindow;
// Probe-owned queue depth: the SingleReader channel's Reader.Count
// throws NotSupportedException, so the net thread increments on
// enqueue and the frame thread decrements on dequeue instead.
private int _probeInboundDepth;
/// <summary>
/// #260 probe: accumulate per-Tick cadence facts and emit one
@ -1067,7 +1073,7 @@ public sealed class WorldSession : IDisposable
int acks = Interlocked.Exchange(ref _probeAckWindow, 0);
Console.WriteLine(
$"[net-tick] in/s={_probeProcessedWindow / windowSeconds:F0}"
+ $" q={_inboundQueue.Reader.Count}"
+ $" q={Volatile.Read(ref _probeInboundDepth)}"
+ $" budget-breaks={_probeBudgetBreaks}"
+ $" maxgap={maxGapMs:F0}ms"
+ $" out/s={sends / windowSeconds:F0}"
@ -1145,6 +1151,8 @@ public sealed class WorldSession : IDisposable
new PooledInboundDatagram(
queuedBuffer,
result.Length));
if (ownershipTransferred && NetDiagnostics.ProbeNet)
Interlocked.Increment(ref _probeInboundDepth);
}
catch (System.Net.Sockets.SocketException ex)
{