Cap .NET thread-pool spin (UnfairSemaphoreSpinLimit) on the ScadaBridge host #146
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mirror of mxaccessgw#237; details there. On wonder-app-vd03,
ZB.MOM.WW.ScadaBridge.Hostshowed 229k context switches in a WPR trace at ~240 MxGateway events/s. In the gateway, the same pattern was PortableThreadPool spin-waiting (Sleep(0)), which mxaccessgw capped withSystem.Threading.ThreadPool.UnfairSemaphoreSpinLimit=10(mxaccessgw 659bb831). Confirm the cause here, apply the setting, measure, and document it.Applied in
b47002b4(main @d4d5be3b). The Host csproj now shipsSystem.Threading.ThreadPool.UnfairSemaphoreSpinLimit=10as a RuntimeHostConfigurationOption, the same setting as mxaccessgw 659bb831. It is present in the published runtimeconfig.json, which the Docker image copies. A Host test pins the value. To override or revert on one host without rebuilding, setDOTNET_ThreadPool_UnfairSemaphoreSpinLimit(70 is the runtime default, 0 turns the spin off). This is documented in Component-Host.md under Runtime thread-pool settings. A synthetic local benchmark (macOS, about 185 events/s) showed roughly half the involuntary context switches and CPU at 10 compared with 70. That is directional only. The vd03 WPR before/after measurement, which would confirm the cause here, is still to be done at the next vd03 deploy.