perf(worker,gateway): pin MXSTATUS_PROXY record info, dedicated event-drain thread, cap thread-pool spin
At ~240 events/s the worker burned 8-12% system CPU on wonder-app-vd03. A WPR trace put 72% of it in lmxproxy's per-event GetRecordInfoFromGuids (type library reload through the registry, amplified by WOW64 and the EDR registry filter) and 26% in the .NET Framework thread pool spinning after each per-event work item. - Worker: MxStatusProxyRecordInfoPin holds the LMXProxy ITypeLib and the MXSTATUS_PROXY IRecordInfo for the process lifetime, so oleaut32 serves the per-event lookup from cache (~1 ms -> <1 us per call). Best-effort, never fatal; status logged at handshake. - Worker: the event drain loop runs on a dedicated background thread with a synchronous wait and a synchronous pipe flush, removing the per-event thread-pool hops. - Gateway: runtimeconfig sets ThreadPool.UnfairSemaphoreSpinLimit=10 to cut PortableThreadPool spin-wait CPU. windev bench at ~242 ev/s: worker 67% -> 6.2% of one core; gateway 8.1% -> 6.9%. Worker suite 785 passed / 14 skipped (x86, windev).
This commit is contained in:
@@ -79,6 +79,16 @@ public interface IWorkerRuntimeSession : IDisposable
|
||||
/// <returns>A task that completes when the queue is signalled or the timeout elapses.</returns>
|
||||
Task WaitForEventsAsync(TimeSpan timeout, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Blocking form of <see cref="WaitForEventsAsync"/> for a drain loop that runs on its own
|
||||
/// dedicated thread. Same contract (coalesced signal, timeout is a ceiling, at most one
|
||||
/// waiter); it parks the calling thread instead of scheduling a thread-pool continuation per
|
||||
/// wake, which on .NET Framework also triggers the pool's spin-wait on every event.
|
||||
/// </summary>
|
||||
/// <param name="timeout">Maximum time to wait before the wait completes unsignalled.</param>
|
||||
/// <param name="cancellationToken">Token cancelling the wait.</param>
|
||||
void WaitForEvents(TimeSpan timeout, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Drains a pending fault from the queue, if any.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user