perf(opcua): #870 ring-buffer event monitored-item queue
Since #855 condition events are queued to folder event items under the node manager Lock. At a full DiscardOldest queue the SDK's EventQueueHandler dequeues the head of EventMonitoredItemQueue, a List.RemoveAt(0) shift of the whole queue (~1 us/item at QueueSize 1000, ~10 us at 10000). OtOpcUaSdkServer.CreateMonitoredItemQueueFactory now wraps the SDK factory in RingEventQueueFactory: event queues are RingEventMonitoredItemQueue (O(1) discard), data-change queues, durable requests and disposal go to the SDK factory unchanged. A factory set through StandardServer.MonitoredItemQueueFactory is used as-is. The SDK queue is storage only (decompiled 2.0.1): DiscardOldest, overflow-event positions and discarded/overflow counters live in EventQueueHandler, which is unchanged. The ring reproduces QueueSize 0 initial + BadInternalError enqueue, drop-oldest at Count == QueueSize, FIFO dequeue, SetQueueSize keep-newest / keep-oldest, the newest-1000 duplicate window via IsEventRaisedFor, no-op Dispose. RingEventMonitoredItemQueueParityTests drive both queues, and the SDK EventQueueHandler over both factories, with the same random sequences. FolderEventDeliveryPerfTests gains Ring_vs_sdk_event_queue (A/B in one process via the internal OtOpcUaSdkServer.RingEventQueues switch). Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
@@ -217,7 +217,7 @@ Two things to know before relying on any of this:
|
||||
replay off `Lock` one event per hold of a per-item gate, and withholds older deferred events from THAT item only
|
||||
(re-sent condition, or Retain=true of one omitted because NOT retained — never one omitted by ACL). Item state is a
|
||||
`ConditionalWeakTable` keyed by the item; cuts clear when the deferral count hits 0. Tests:
|
||||
`ConditionRefreshDeferralWireTests`. ⚠️ **Since #855 folder items are delivered per item too:** at every notifier we own, `DeliverConditionEventAsync` serves the `MonitoredNode2`'s attached items itself (`DeliverToNotifierItems`: audit guard → `INodeManager3.ValidateEventRolePermissions` per event, UNCACHED → item gate/cut → `QueueEvent`), never through the SDK channel — so no notifier of ours defers, a flood under `Lock` defers nothing, and folder refreshes (`RefreshDirectItems`, flag on AND off) share the #854 cut. The deferral queue + cut remain as the safety net; an event whose walk suspends is marked deferred BEFORE suspending. Tests produce deferral with `NotifierStall` (the `NotifierDeliveryStall` probe) — holding a folder item's SDK lock now blocks the reporter. `FolderConditionRefreshWireTests`; `docs/plans/2026-11-11-folder-event-per-item-delivery.md`. Folder events follow Part 3's shape —
|
||||
`ConditionRefreshDeferralWireTests`. ⚠️ **Since #855 folder items are delivered per item too:** at every notifier we own, `DeliverConditionEventAsync` serves the `MonitoredNode2`'s attached items itself (`DeliverToNotifierItems`: audit guard → `INodeManager3.ValidateEventRolePermissions` per event, UNCACHED → item gate/cut → `QueueEvent`), never through the SDK channel — so no notifier of ours defers, a flood under `Lock` defers nothing, and folder refreshes (`RefreshDirectItems`, flag on AND off) share the #854 cut. The deferral queue + cut remain as the safety net; an event whose walk suspends is marked deferred BEFORE suspending. Tests produce deferral with `NotifierStall` (the `NotifierDeliveryStall` probe) — holding a folder item's SDK lock now blocks the reporter. `FolderConditionRefreshWireTests`; `docs/plans/2026-11-11-folder-event-per-item-delivery.md`. Because that queueing runs under `Lock`, event item queues are `RingEventMonitoredItemQueue` (#870, supplied by `OtOpcUaSdkServer.CreateMonitoredItemQueueFactory` via `RingEventQueueFactory`; data-change queues stay the SDK's) — the SDK queue's discard-oldest was a `List.RemoveAt(0)` per stalled item per report. It is storage only (overflow events + DiscardOldest live in the SDK's unchanged `EventQueueHandler`); parity pinned by `RingEventMonitoredItemQueueParityTests` — re-check them on an SDK bump. Folder events follow Part 3's shape —
|
||||
`ReceiveEvents` on EventType + SourceNode (SDK check, kept first) AND our decision; non-condition events on a
|
||||
folder item fail closed under enforcement. Tests: `FolderEventFloodWireTests`. Overflow WITH the ACL doing work (#838
|
||||
item 2) — denied condition interleaved, folder + `i=2253` items, non-publishing client, concurrent Read, grant revoked
|
||||
|
||||
Reference in New Issue
Block a user