From cb672ea0602d8aa3780fcdfc34037eab82c43fa5 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 28 Nov 2026 09:13:48 -0500 Subject: [PATCH] docs(grpc-data): re-measure per-condition memory with GC memory info (#929) The X0 node-only harness used a GC.GetTotalMemory(true) delta, which on .NET 10 counts committed-but-free GC regions. Switched it to the L2 Measure() method (full blocking GC, HeapSizeBytes - FragmentedBytes, settled working set): 79,085 B heap / ~90 KB WS per OffNormal condition (GetTotalMemory still reads 158,169 B, reproducing the old 160,997). Plan 5.5, X0/A3/A4-docs evidence and the BytesPerCondition comment corrected; the default (160,000 B from the L2 in-server worst case) is unchanged. --- ...pc-data-connections-history-alarms-plan.md | 39 ++++++++++++------- docs/plans/evidence/grpc-data-ext/A3.md | 7 +++- docs/plans/evidence/grpc-data-ext/A4-docs.md | 2 +- docs/plans/evidence/grpc-data-ext/X0.md | 12 +++++- .../evidence/grpc-data-ext/harness/Program.cs | 19 ++++++++- .../ProjectedConditionAccess.cs | 2 +- 6 files changed, 58 insertions(+), 23 deletions(-) diff --git a/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md b/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md index 9c518385b..cb0b9a788 100644 --- a/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md +++ b/docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md @@ -65,7 +65,7 @@ found while verifying M1 (row M1). | N8 G0 deferral consequences | Accepted | Recorded-v1-client gate repeated at H2, A2 and A3 exits; §1.1: #915's soak should run on an X0-or-later build | | **Revision 4 (settled offline)** | | | | B5 interception point | Settled: works | §5.6 step 1 — NM implements `ICallAsyncNodeManager`; SDK 2.0.1 dispatch traced (validation's `FindMethodState` holds `Lock` only for the lookup; per-manager `CallAsync` awaited with `ConfigureAwait(false)`); A3 not blocked | -| N5 node count | Settled: 48–49 nodes, ≈ 157 KiB each (was "~21") | §5.5 recomputed: 10,000 / 49 ≈ 204; `MaxConditions` 1,000; host caps 122,500 nodes / 400 MiB | +| N5 node count | Settled: 48–49 nodes, ≈ 157 KiB each (was "~21"; the bytes were a `GC.GetTotalMemory` artifact — #929 re-measured ≈ 77 KiB node-only, see §5.5) | §5.5 recomputed: 10,000 / 49 ≈ 204; `MaxConditions` 1,000; host caps 122,500 nodes / 400 MiB | | `state_known` field | Settled: does not exist; named additions (revised in revision 5 by T1/T2) | §5.1: `_conditionStateKnown`, `MarkConditionsKnown`, driver signal / per-driver timer, scripted inputs-established | | Event re-gating, Galaxy keying, build reporting, opc-plc alarms, alarm-tag export | Settled from code/SDK | §5.4, §6, §4.3, A02, §5.2 (+ second pre-existing v1 defect) | | Remaining live items | Listed | §9.3 L1–L5 with pass criteria | @@ -191,7 +191,7 @@ has accepted the call. | Namespaces (N4) | `NM:117-118` `RegisteredNamespaceUris` (Raw, UNS, mapped/raw, mapped/uns); `NM:283-284` `RealmOf` folds every index but 0/2 into Uns | A fifth URI `mapped/conditions` is a registration change; it must be classified before `RealmOf` | | Stable source id (N3) | `SourceSamplePublisher.cs:32-33` (`":"`), emitted in `Metadata.stable_source_id` at `LocalExportCatalog.Compilation.cs:92,123` | Not usable as a condition dedupe key (discloses RawPath); pre-existing disclosure on UNS reference variables (#916) | | SDK Call dispatch (B5) | Decompiled SDK 2.0.1: `StandardServer.CallAsync` → `MasterNodeManager.CallAsync` → `NodeManagerServiceDispatcher.CallAsync` (validation via `FindMethodState`, short `lock (Lock)`, then per-manager `IAsyncNodeManager.CallAsync`); `AsyncNodeManagerAdapter.CallAsync` forwards to `ICallAsyncNodeManager` when the wrapped manager implements it; `CustomNodeManager2` (NM's base) implements `INodeManager3` only and its sync `Call`/`GetMethodCalls` skip `Processed` items | NM implements `ICallAsyncNodeManager`; imported-condition calls are claimed and awaited with no `Lock` held (§5.6) | -| Condition subtree (N5) | `NM:2461-2475` (optional `ConfirmedState`/`Confirm`/`ShelvingState`/`MaxTimeShelved` before `Create`), `ApplicationAlarmConditions.cs:7-11` (Alarm / OffNormal / Discrete) | Counted with SDK 2.0.1: 48 / 49 / 48 nodes, ≈ 157 KiB retained each (§5.5) | +| Condition subtree (N5) | `NM:2461-2475` (optional `ConfirmedState`/`Confirm`/`ShelvingState`/`MaxTimeShelved` before `Create`), `ApplicationAlarmConditions.cs:7-11` (Alarm / OffNormal / Discrete) | Counted with SDK 2.0.1: 48 / 49 / 48 nodes, ≈ 157 KiB retained each (§5.5; corrected by #929 to ≈ 77 KiB node-only) | | Event delivery path (§5.4) | Decompiled SDK 2.0.1 `MonitoredItem.QueueEvent(EventFieldList)` enqueues by reference; `Subscription.ConstructMessage` moves queued lists into `EventNotificationList` by reference; a select-clause modify rebuilds queued lists via `GetEventFields` with `Handle` = the original event; `OtOpcUaSdkServer.cs:746,768` already rewrites every Publish/Republish via `ProjectedNotificationRewriter` (`WarmStandby.cs:917`), which today passes event payloads through untouched | A marked `EventFieldList` subclass survives to Publish/Republish; the rewriter is extended to events | | Native/scripted state signals (N1) | Native `Quality = BadWaitingForInitialData` at materialise (`NM:2527`), driven Good via `WriteAlarmQuality` (`NM:1480`); `RestoreCarryOver` (`NM:2727`); scripted re-assert only for non-normal conditions (`ScriptedAlarmHostActor.cs:491`); scripted cold start re-derives Active from a `ReadTag`-seeded cache (`ScriptedAlarmEngine.cs:440-461`, `StatusNeverPushed` `:58-67`, `WorstInputStatus` `:1325`); existing driver signals: Galaxy `IGalaxyAlarmFeed.InitialSnapshotCompleted` (`:38`), OpcUaClient ConditionRefresh sweep (`OpcUaClientDriver.cs:2552`); `IAlarmSource` implementers: Galaxy, OpcUaClient, MTConnect, FOCAS, AbCip, Heidenhain; SDK `SetActiveState` stamps `TransitionTime = Now` on every call (`NM:1364` calls it per projection) | `_conditionStateKnown` + `MarkConditionsKnown` deltas + driver signal / per-driver timer + inputs-established; origin-owned activation marker (§5.1, §5.6) | | Alarm-bearing tags (N3, §5.2) | `AddressSpaceComposer.cs:978-985` (#896: no UNS value Variable for an alarm-bearing backing tag); `AddressSpaceComposer.cs:835-850` (alarm tags are in `RawTags`); `LocalExportCatalog.Compilation.cs:120-130` (no Alarm filter) | UNS placement address is a reserved reference id with no node; v1 exports alarm-bearing raw tags as dead Variables (pre-existing defect) | @@ -758,23 +758,28 @@ SDK 2.0.1 (scratch harness, §9.3) gives: | `OffNormalAlarmType` | **49** | 2 objects, 39 variables, 8 methods | | `DiscreteAlarmType` | **48** | 2 objects, 38 variables, 8 methods | -`Quality`, `BranchId` and `Comment` are present. The retained managed size measured **≈ 157 KiB per condition** (160,997 B -for `OffNormal`, 2,000 instances, `GC.GetTotalMemory(true)` delta, excluding NM's own indexes). **Memory, not node count, is -the binding limit.** The origin already pays the same per condition for its own local copy. +`Quality`, `BranchId` and `Comment` are present. The retained managed size of the node tree alone is **≈ 77 KiB per +condition** (79,085 B for `OffNormal`, 2,000 instances, retained heap `HeapSizeBytes − FragmentedBytes` after a full blocking +GC; ≈ 90 KB of settled working set; excluding NM's own indexes; re-measured for #929, X0 evidence). Revision 4's +"≈ 157 KiB (160,997 B)" was a `GC.GetTotalMemory(true)` delta, which on .NET 10 also counts committed-but-free GC regions +(the same harness still reports 158,169 B that way) — it was inflated ≈ 2×. The in-server worst case measured by L2 +(node tree + NM indexes + identifiers + EventId registry + placements + runner records) is **111,715 B heap / 158,629 B working +set**, and `BytesPerCondition` = **160,000 B** is set from that (A3 evidence, "L2 worst-case memory"). **Memory, not node +count, is the binding limit.** The origin already pays the same node-tree cost per condition for its own local copy. Arithmetic: - with v1's `MaxProjectionNodes` default of 10,000 (`RemoteNamespaceMapping.cs:29`), 10,000 / 49 ≈ **204** conditions would exhaust a mapping (revision 3's "≈ 476 at 21 nodes" was wrong); -- 10,000 imported conditions would retain ≈ 1.5 GiB. +- 10,000 imported conditions would retain ≈ 1.5 GiB (at the L2 160,000 B each). Defaults (conditions get their **own** budget; worst case is 49 nodes): -| Setting | Default | Nodes | Memory (≈ 157 KiB each) | +| Setting | Default | Nodes | Memory (L2 `BytesPerCondition` 160,000 B each) | |---|---|---|---| | `RemoteNamespaceMapping.MaxConditions` | **1,000** per mapping | 49,000 | ≈ 153 MiB | | `DataConnections:MaxImportedConditionNodes` (host) | **122,500** per consumer node (= 2,500 × 49) | 122,500 | — | -| `DataConnections:MaxImportedConditionBytes` (host) | **400 MiB** per consumer node (≈ 2,500 × 157 KiB = 384 MiB, rounded) | — | 400 MiB | +| `DataConnections:MaxImportedConditionBytes` (host) | **400,000,000 B** per consumer node (= 2,500 × 160,000 B ≈ 381 MiB) | — | ≈ 381 MiB | - Conditions are charged **once per `condition_key`**, not per placement. They do **not** consume `MaxProjectionNodes`, which stays for folders and variables; placement folders charge it as ordinary projected folders. @@ -790,14 +795,16 @@ Defaults (conditions get their **own** budget; worst case is 49 nodes): node's mappings exceeds `MaxImportedConditionNodes`. - Whether 1,000 per mapping / 2,500 per node covers real exports is live measurement L5 (§9.3). The defaults are tunable and sized from the measured memory cost, not from a guessed plant size. -- **What the 157 KiB excludes (m-T7):** +- **What the node-only figure (≈ 77 KiB; "157 KiB" before #929) excludes (m-T7):** - NM's indexes; - the `c1./` identifier strings on 48–49 nodes; - the per-condition EventId registry; - placement sets. - **L2 is the authority:** `MaxImportedConditionBytes` is set from the L2 measurement (per-condition in-server bytes × 2,500), - and the 400 MiB above is a provisional default until L2 passes. + **L2 is the authority:** `MaxImportedConditionBytes` is set from the L2 measurement (per-condition in-server bytes × 2,500). + L2 passed at the A3 exit: the larger of its heap and settled-working-set figures, max of three runs, rounded up, is + 160,000 B, so the default is 400,000,000 B. The ≈ 40 KiB gap between the node-only heap (≈ 77 KiB) and L2's heap + (≈ 109 KiB) is the excluded state above plus the worst-case placements, EventId slots and event-queue entries. **Stream mechanics.** @@ -1385,7 +1392,7 @@ Use two-state id selection via `SimpleAttributeOperand(type, [X, Id])`, as the C | Acks fail on busy alarms because the precondition moves | A2 | Origin-owned activation marker, bumped only on a new occurrence (T3) | | RawPath disclosure to UNS-only principals | A1 | Realm-local placements; keyed `condition_key`; property test; pre-existing `stable_source_id` disclosure is #916 | | Imported-condition method path regresses local methods | A3 | Claimed items only (`Processed`), `base.Call` unchanged for the rest; lock-freedom gate; existing `ConditionMethodEventTests` stay green | -| Imported-condition memory (≈ 157 KiB each) | A3 | Own budget sized from the counted cost; byte cap 400 MiB per consumer node; L2 confirms in-server | +| Imported-condition memory (≈ 77 KiB node-only, 160,000 B in-server worst case) | A3 | Own budget sized from the counted cost; byte cap 400,000,000 B (≈ 381 MiB) per consumer node; L2 confirmed in-server | | v1 unsoaked in service (G0 deferred, #915) | all | Per-phase live gates; deploy notes record the risk until #915 passes | ### 9.3 Settled offline vs. needs a live run @@ -1393,7 +1400,7 @@ Use two-state id selection via `SimpleAttributeOperand(type, [X, Id])`, as the C **Settled offline in revision 4** (no server needed): - the SDK 2.0.1 Call dispatch trace (decompiled with `ilspycmd` from the pinned package); - the event-delivery path; -- condition node counts (48/49/48) and retained bytes (≈ 157 KiB); +- condition node counts (48/49/48) and retained bytes (≈ 157 KiB in revision 4; ≈ 77 KiB after the #929 re-measure); - snapshot-copy cost (≈ 1.7–2.9 µs per condition); - the Galaxy ack-identity keying; - the absence of node build reporting; @@ -1401,8 +1408,10 @@ Use two-state id selection via `SimpleAttributeOperand(type, [X, Id])`, as the C - alarm-bearing tag export shape (#896). The counts, bytes and copy timing come from a scratch harness: a console project referencing `OPCFoundation.NetStandard.Opc.Ua.Server` -2.0.1 that builds each condition type with NM's optional children, walks `GetChildren`, measures a `GC.GetTotalMemory(true)` -delta over 2,000 instances, and times the snapshot field copy. It is not in the repo; X0 task 4 commits it as evidence. +2.0.1 that builds each condition type with NM's optional children, walks `GetChildren`, measures the retained heap over +2,000 instances, and times the snapshot field copy. X0 task 4 committed it as evidence (`docs/plans/evidence/grpc-data-ext/harness/`). +It first measured a `GC.GetTotalMemory(true)` delta; #929 switched it to the L2 method (full blocking GC, +`HeapSizeBytes − FragmentedBytes`, settled working set) and the figure halved. **Live measurements** — each runs on docker-dev unless stated, and each has a pass criterion: diff --git a/docs/plans/evidence/grpc-data-ext/A3.md b/docs/plans/evidence/grpc-data-ext/A3.md index ccac46fab..8b49f81a4 100644 --- a/docs/plans/evidence/grpc-data-ext/A3.md +++ b/docs/plans/evidence/grpc-data-ext/A3.md @@ -300,6 +300,8 @@ regions at baseline). Per the plan, `MaxImportedConditionBytes` is now set from **205,665** (the managed-heap figure, the larger of the two) and the default `DataConnections:MaxImportedConditionBytes` = 205,665 × 2,500 = **514,162,500 B (≈ 490 MiB)** (was 400 MiB). `MaxConditions` (1,000 per mapping) needs no lowering. Nearly all of it is the SDK condition node + children (X0's node-only figure was 160,997); the A3b EventId registry adds ~1 KB. +(Superseded: these figures and X0's were `GC.GetTotalMemory` deltas — see round 2's L2 below and #929, which re-measured the +node-only retained heap at 79,085 B.) ## Live — run `a3b-cond-3` (build `82ecc116`, clean tree) — PASS @@ -658,7 +660,7 @@ Worst case (2 placements per condition, all 8 EventId slots filled, 3 event item **L2: PASS** (both ≤ 200 MiB in every run). `BytesPerCondition` = the larger of the two per-condition figures, max of three runs, rounded up: 158,629 → **160,000** (was 230,000); `MaxImportedConditionBytes` default = 160,000 × 2,500 = **400,000,000 B (≈ 381 MiB)** (was ≈ 548 MiB). The X0 node-only figure (160,997) and A3b's 197.4 MiB were taken with `GetTotalMemory` too and are -likely inflated the same way (not re-measured here). +likely inflated the same way (not re-measured here; #929 re-measured X0: 79,085 B node-only heap, X0 evidence). ## Gates (round 2, at `b884db5f`) @@ -693,7 +695,8 @@ Active/Acknowledged; `passed: true`. Teardown: no run-labelled containers or net - File: the `GrpcDataConditionStreamTests.Overflow_before_the_snapshot_is_drained_resets_the_stream` load sensitivity (above). - The plan's L2 / X0 figures (≈ 157–161 KiB per condition node, §5.5 table) came from `GC.GetTotalMemory` and are likely - inflated by the same region accounting; the plan's §5.5 table was not edited (evidence only). + inflated by the same region accounting; the plan's §5.5 table was not edited (evidence only). Done in #929: the X0 harness + now uses the L2 method (79,085 B node-only heap vs 158,169 B by `GetTotalMemory`), and §5.5 cites L2's 160,000 B. # A3 — Verification review round 2 diff --git a/docs/plans/evidence/grpc-data-ext/A4-docs.md b/docs/plans/evidence/grpc-data-ext/A4-docs.md index a547cb2d8..6936cb541 100644 --- a/docs/plans/evidence/grpc-data-ext/A4-docs.md +++ b/docs/plans/evidence/grpc-data-ext/A4-docs.md @@ -32,7 +32,7 @@ The sources were the code at `91438049` and the evidence logs X0–A3. The plan | # | Plan says | Code does (evidence) | |---|---|---| | D1 | §5.6 step 2(c): one per-node semaphore (default 8) bounds remote method calls. | 8 per node **and** 4 per connection inside them. A dispatch with < 250 ms of budget left is `BadTimeout`, unsent (`ImportedConditionMethods.cs:63-79`, `:247`, `:270`; A3b review S4). | -| D2 | §5.5 / §6: `MaxImportedConditionBytes` 400 MiB, ≈ 157 KiB (160,997 B) per condition. | `BytesPerCondition` = 160,000. The default is 400,000,000 B ≈ 381 MiB (`ProjectedConditionAccess.cs:58-61`, `DataConnectionOptions.cs:25`; A3 round-2 L2 measured the retained heap, not `GC.GetTotalMemory`). #929 re-measures the plan's figures. | +| D2 | §5.5 / §6: `MaxImportedConditionBytes` 400 MiB, ≈ 157 KiB (160,997 B) per condition. | `BytesPerCondition` = 160,000. The default is 400,000,000 B ≈ 381 MiB (`ProjectedConditionAccess.cs:58-61`, `DataConnectionOptions.cs:25`; A3 round-2 L2 measured the retained heap, not `GC.GetTotalMemory`). #929 re-measured the plan's figures: node-only 79,085 B heap (X0 harness, now on the L2 method); §5.5 corrected, default unchanged. | | D3 | §6 metrics list `…conditions.refresh_required`. | Not present (`OtOpcUaTelemetry.cs:233-265` has `unsignalled`, `partition_overflows`, `items`, `resyncs`, `capacity_rejections`, `condition_methods`, `marks_discarded`). A4 diagnostics work; TODO 2. | | D4 | §5.4/§5.5: demand per connection the caller could see. | Demand is node-wide: the first admitted event item opens every condition-bearing connection, and the per-event gate still decides visibility (A3a deviation 2). | | D5 | §6: local visibility uses "the Subscribe grant on the `RemoteNamespaceMapping` scope". | `Subscribe` on the **placement folder's** scope, within a current mapping of the placement's realm that grants `AlarmSubscribe`, not `AlarmRead` (`ProjectedConditionAccess.cs:170-190`; A3 Runtime gate tests). Narrower than the mapping scope, and consistent with it. | diff --git a/docs/plans/evidence/grpc-data-ext/X0.md b/docs/plans/evidence/grpc-data-ext/X0.md index 2c4d0035a..5c310ad38 100644 --- a/docs/plans/evidence/grpc-data-ext/X0.md +++ b/docs/plans/evidence/grpc-data-ext/X0.md @@ -51,8 +51,16 @@ optional children NM adds before `Create()`: `ConfirmedState`, `Confirm`, `Shelv `Quality`, `BranchId` and `Comment` are present. -Retained size is ≈ 157 KiB per condition (160,997 B). It was measured on 2,000 `OffNormal` instances as a -`GC.GetTotalMemory(true)` delta. +Retained size is ≈ 77 KiB per condition: **79,085 B** managed heap, ≈ 90 KB settled working set (re-measured 2026-11-28 for +#929, three runs: heap 79,085 / 79,085 / 79,085 B, working set 90,284 / 90,144 / 90,038 B). It is measured on 2,000 +`OffNormal` instances as the change in `HeapSizeBytes − FragmentedBytes` of the last full blocking GC (after forced +compacting collections), with the working set sampled until it settles — the same `Measure()` as the L2 harness. + +- **Correction (#929).** X0 originally reported ≈ 157 KiB (160,997 B), a `GC.GetTotalMemory(true)` delta. On .NET 10 (GC + regions) that call also counts committed-but-free region space (A3 round 2 showed +92 vs +218 MiB for the same state); the + harness still logs it for comparison and it reads 158,169 B, i.e. ≈ 2× the retained heap. +- `BytesPerCondition` (160,000 B) is unaffected: it comes from the L2 in-server worst case (111,715 B heap / 158,629 B + working set, A3 round 2), which already used this method. Node-only ≈ 77 KiB of L2's ≈ 109 KiB heap is the SDK node tree. - It excludes NM's indexes, the `c1.` identifier strings, the EventId registry and placement sets (m-T7). - L2 (A3 exit) is the authority for `MaxImportedConditionBytes`. diff --git a/docs/plans/evidence/grpc-data-ext/harness/Program.cs b/docs/plans/evidence/grpc-data-ext/harness/Program.cs index 28605d4b2..34c475dc0 100644 --- a/docs/plans/evidence/grpc-data-ext/harness/Program.cs +++ b/docs/plans/evidence/grpc-data-ext/harness/Program.cs @@ -18,18 +18,33 @@ static class P { int total = Count(ctx, alarm, kinds); Console.WriteLine($"{name}: total={total} ({string.Join(", ", kinds.Select(k => k.Key + "=" + k.Value))}); Quality={(alarm.Quality!=null)} BranchId={(alarm.BranchId!=null)} Comment={(alarm.Comment!=null)}"); } + // #929: GC.GetTotalMemory counts committed-but-free regions on .NET 10. Use the last full blocking GC's + // HeapSizeBytes - FragmentedBytes plus a settled working set: the same method as the L2 harness's Measure() + // (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests/ImportedConditionMemoryMeasurementTests.cs). + static (long Heap, long WorkingSet) Measure() { + for (int i = 0; i < 3; i++) { GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true); GC.WaitForPendingFinalizers(); } + GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true); + var info = GC.GetGCMemoryInfo(GCKind.FullBlocking); + using var p = System.Diagnostics.Process.GetCurrentProcess(); p.Refresh(); long ws = p.WorkingSet64; + var settle = System.Diagnostics.Stopwatch.StartNew(); + while (settle.Elapsed < TimeSpan.FromSeconds(10)) { + Thread.Sleep(500); p.Refresh(); long next = p.WorkingSet64; bool stable = Math.Abs(next - ws) < 1024 * 1024; ws = next; if (stable) break; } + return (info.HeapSizeBytes - info.FragmentedBytes, ws); + } static void Main() { var ctx = new SystemContext((ITelemetryContext)null) { NodeIdFactory = new Ids(), NamespaceUris = new NamespaceTable() }; ctx.NamespaceUris.Append("urn:a"); ctx.NamespaceUris.Append("urn:b"); Run("AlarmConditionState", p => new AlarmConditionState(p), ctx); Run("OffNormalAlarmState", p => new OffNormalAlarmState(p), ctx); Run("DiscreteAlarmState", p => new DiscreteAlarmState(p), ctx); - var keep = new List(); long before = GC.GetTotalMemory(true); + var keep = new List(); var (heap0, ws0) = Measure(); long before = GC.GetTotalMemory(true); for (int i = 0; i < 2000; i++) { var parent = new FolderState(null); var a = new OffNormalAlarmState(parent); a.ConfirmedState = new TwoStateVariableState(a); a.Confirm = new AddCommentMethodState(a); a.ShelvingState = new ShelvedStateMachineState(a); a.MaxTimeShelved = new PropertyState.Implementation(a); a.Create(ctx, new NodeId("c"+i, 2), new QualifiedName("c"+i, 2), new LocalizedText("c"+i), true); keep.Add(a); } - long after = GC.GetTotalMemory(true); Console.WriteLine($"retained bytes/condition (2000, OffNormal, no address-space indexes): {(after-before)/2000}"); GC.KeepAlive(keep); + var (heap1, ws1) = Measure(); long after = GC.GetTotalMemory(true); + Console.WriteLine($"retained bytes/condition (2000, OffNormal, no address-space indexes): heap {(heap1-heap0)/2000} (GCMemoryInfo), " + + $"working set {(ws1-ws0)/2000} (settled); GC.GetTotalMemory delta {(after-before)/2000} (not used, #929)"); GC.KeepAlive(keep); var conds = keep.Cast().ToArray(); var recs = new object[conds.Length]; for (int w = 0; w < 3; w++) { var sw = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < conds.Length; i++) { var c = conds[i]; recs[i] = (c.NodeId, c.ActiveState?.Id?.Value, c.AckedState?.Id?.Value, c.ConfirmedState?.Id?.Value, diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ProjectedConditionAccess.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ProjectedConditionAccess.cs index 18292622f..f479d7432 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ProjectedConditionAccess.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ProjectedConditionAccess.cs @@ -93,7 +93,7 @@ public sealed record ProjectedConditionOptions(TimeSpan Linger, int MaxImportedC /// /// Retained managed bytes per imported condition, measured by the A3 L2 harness (1,000 conditions in one mapping on a /// running SDK 2.0.1 server: node + children + ids + registry/indexes + EventId registry + verdict cache; X0's - /// node-only harness measured 160,997). A3b review S5: the WORST case — two placements, every EventId slot, three + /// node-only harness retains 79,085 B on the same method, #929 — its original 160,997 was a GC.GetTotalMemory delta). A3b review S5: the WORST case — two placements, every EventId slot, three /// event items, the runner's Live + Buffer records. A3 review round 2: measured with the retained heap /// (GCMemoryInfo, not GC.GetTotalMemory, which counted ~125 MiB of committed-but-free regions) and the /// settled working set, 8 EventId slots (§5.6): max of three runs = 158,629 B (working set; heap 111,715 B), rounded up.