Folder event delivery: ring-buffer event queue so a full queue does not shift under Lock (large N / large QueueSize residual from #855) #870
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?
Follow-up to #855. Since #855, condition events are delivered to folder event items under the node-manager
Lock. The shared per-report projection brought N=50 stalled items at QueueSize 1000 back to p50 81–181 µs and p99 335–555 µs.Two cases stay above the pre-#855 baseline:
Cause: at a full queue, the SDK's
EventMonitoredItemQueueshifts its whole list (List.RemoveAt(0)) on every enqueue. That costs ~1 µs per item at q=1000 and ~10 µs at q=10000. GC pauses inside the Lock window make up most of the N=200 p99 tail.Fix: a ring-buffer event queue through the SDK's
IMonitoredItemQueueFactory. Measure withFolderEventDeliveryPerfTests(OTOPCUA_EVENT_PERF=1); raw rows are in the #855 work. ScadaBridge (Server-object subscriber, few or no folder items) is not affected at today's scale.Fixed, pushed to master in
363f0d81(bcde9305, review follow-up36583ee6).Change:
RingEventMonitoredItemQueueis supplied throughIMonitoredItemQueueFactory, viaRingEventQueueFactoryinOtOpcUaSdkServer.CreateMonitoredItemQueueFactory. Data-change and durable queues stay the SDK's own.Parity with the SDK 2.0.1
EventMonitoredItemQueue:IsEventRaisedFor;Disposedoes nothing.DiscardOldest and overflow-event logic stay in the SDK's
EventQueueHandler, which is unchanged.Tests: 89 parity cases, including random sequences against the SDK queue and against
EventQueueHandlerover both factories. Breaking the implementation on purpose made them fail. An independent review found no defects. It added a pin on the 1000th-newest boundary and serialised the tests that use the perf harness's process-wide switch.Same-process A/B, Lock hold in µs (p50 / p99), measured on a loaded machine:
At QueueSize 10000 the per-item cost dropped from about 10 µs to 3–5 µs. The N=200 p99 tail of a few ms (pre-#855 it was ≤ 0.35 ms) is not attributed. Earlier profiling pointed at GC pauses inside the Lock window. Re-measure on a quiet machine if that scale becomes real; ScadaBridge does not reach it today.