fix(opcua): #855 perf review 3 — weak filter-group registry; where clause validated; sharing pinned

- The filter-group registry holds groups weakly (the filter->group table is
  the only strong reference), sweeps dead entries amortised and counts only
  live shapes against the 4096 cap; filters past the cap are counted on the
  new meter otopcua.opcua.condition_events.filter_groups_unshared.
- A group validates its where clause too (restored, never-validated filters
  evaluate like validated ones).
- Test: value-equal filters cost one projection per locale set per report.

Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
Joseph Doherty
2026-11-11 14:20:19 -05:00
parent b77bb2ded1
commit 733dfe94da
4 changed files with 93 additions and 8 deletions
@@ -1701,7 +1701,8 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2, INodeManager3
}
finally
{
if (e is ConditionEventSnapshot snapshot) snapshot.ReleaseDeliveryCache();
if (e is ConditionEventSnapshot snapshot && snapshot.ReleaseDeliveryCache() is { } cache)
Interlocked.Add(ref _projectionsCreated, cache.ProjectionsCreated);
}
}
@@ -1722,6 +1723,10 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2, INodeManager3
}
private long _projectedDeliveries;
private long _projectionsCreated;
/// <summary>Shared (filter group, locales) projections created across reports (test observation: sharing happens).</summary>
internal long ProjectionsCreated => Interlocked.Read(ref _projectionsCreated);
/// <summary>Items this node manager served through the projected path (test observation: it is really taken).</summary>
internal long ProjectedDeliveries => Interlocked.Read(ref _projectedDeliveries);
@@ -1961,7 +1966,7 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2, INodeManager3
}
/// <summary>Drops the delivery cache once the walk is over (the snapshot stays referenced from the item queues).</summary>
public void ReleaseDeliveryCache() => Volatile.Write(ref _deliveryCache, null);
public EventDeliveryCache? ReleaseDeliveryCache() => Interlocked.Exchange(ref _deliveryCache, null);
}
/// <summary>