perf(worker): memoize event frame size at enqueue; drain stops sizing under the STA's lock

This commit is contained in:
Joseph Doherty
2026-08-15 17:27:47 -04:00
parent b5ea6bb461
commit 58d97ad4e8
3 changed files with 263 additions and 15 deletions
+5 -1
View File
@@ -541,7 +541,11 @@ is bounded on **two** axes because no diagnostics command may be session-fatal:
maximum less a 64 KiB envelope/reply-wrapper reserve, and the size decision
happens inside the event queue's lock, so an event is dequeued only once it is
known to fit. An event that does not fit stays at the head of the queue and is
never lost.
never lost. Each event's serialized size is *measured* once at enqueue, outside
that lock, and stored beside it: the drain only compares memoized numbers, so a
large drain never walks messages under the lock the STA needs to enqueue the
next COM callback. The memoized size cannot go stale because an enqueued event
is never mutated again (WRK-11).
Truncation is reported in the reply's existing `DiagnosticMessage`
("N events returned, M remain; repeat DrainEvents for the rest") rather than in a