Repository navigation
Redesign NodeManager publication, routing and lifetime ownership - #4982
Merged
Merged
Conversation
…shared lock Since #4757 every data change took MasterNodeManager's retired-generation lock twice per monitored item (capture and release of the source-emission lease, with a dispatch-state allocation and LINQ scans each time) and IsReadyToPublish took it again. Since #4834 every delivery also takes the node manager's operation-lifetime lock two to three times per item (BeginNodeManagerOperation, CompleteNodeManagerOperation and the value-read-authorization lookup). With 50 sessions x 15 subscriptions x 600 items these locks serialized delivery onto about one core. - Source-emission leases are counted per processor on a per-node-manager state kept in a ConditionalWeakTable while business emissions are enabled and no drain waits; the cutoff and drains keep using the lock and count both kinds. - IsSourceEmissionAllowed reads the state's flag without the lock. - Node-manager operation admission counts per processor; disposal publishes its flag and then sums the counts. - Value-read-authorization lookups read the thread-safe table without the lock, guarded by a version counter around a replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#4834 rechecks the exact source (attribute reads, namespace defaults, role permissions and access restrictions) on every delivery for every item, which alone costs about 5 us per notification. Without a registered Value read authorizer the verdict only depends on inputs the item's role-permission cache already tracks (identity, session, role-permission version, local generation) plus the namespace-default generation, the endpoint, security mode, transport and the node's access restrictions, so a good verdict is kept with those keys. Items whose variable has a registered authorizer still run the full check and the policy on every delivery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Node-manager disposal: operations still admitted after disposal started (nested ones and the teardown callback) are counted under the lock instead of in a per-processor slot. A slot entered after a drain check had summed it could otherwise let cleanup run while the nested operation was still active. - Source emissions: a reserved cutoff closes the lock-free admission path, so an emission admitted while the cutoff publishes its routes observes the routes and the cutoff flag together under the lock, also across managers. - Monitored reads: nodes that serve access restrictions or role permissions through read callbacks are rechecked on every delivery instead of reusing a cached grant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…espace defaults uncached - Source emissions: every cutoff reservation and release moves a version that a lock-free admission reads before its first gate check and again after it is counted, and the gate reads the reservation before the flag. An emitter that pauses between the checks while a cutoff reserves, publishes and releases is rejected, even though the reservation is released again at the recheck. - Monitored reads: a read verdict is only reused while the namespace defaults are stored values. The metadata node is resolved without awaiting when the verdict is created, and a read callback on one of its default properties, present then or attached later, retires the verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ocable namespace defaults as dynamic - IsSourceEmissionAllowed reads the business-emission flag without the lock only while no cutoff is reserved. During publication it answers under the lock, so readiness observes the cutoff together with the routes it publishes. - A read verdict is only reused while every namespace default property is static: no value or user-access-level read callback, and current read access in both access levels. A revoked read access or an OnReadUserAccessLevel callback (present from the start or attached later) fails delivery closed again, as the per-delivery check did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rdict A verdict cached while the namespace had no metadata kept passing after metadata was linked later through a Server/Namespaces reference, which moves no defaults generation; the registry only notices that link on lookup. Reuse now resolves the metadata node (or its absence) again and requires the same node with static defaults. A cached registry hit or miss does not enumerate the namespaces, so this costs one lookup per delivery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onitored item MonitoredNode2 kept a ServerSystemContext copy and an OperationContext per monitored item (refreshed on a permission generation change and every five minutes), so a server with 50 sessions x 15 subscriptions x 600 items held 450,000 of them although the context only depends on the session. MonitoredReadAuthorization.GetSubscriberContext now returns one OperationContext per session (per item for a sessionless item), reused until the effective identity, the notification authorization epoch (the identity refresh generation for a custom session) or the accepted endpoint changes. Its per-node-manager system context copy comes from the context's existing copy cache, so a notification allocates no context. A replaced context still retires the item's cached permission verdicts, which are keyed by it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
P2 intermediate foundation: reject incompatible metadata before durable decisions, preserve serving registrations, and keep unpinned state lookup live. Explicit staging and selector/reference removal remain P2 work.
…(stacked on #4982) (#5002) Stacked on #4982: targets `marcschier-nodemanager-redesign-e24`. ## Problem On #4982 the `native-read` harness scenario (o6 native workers, 10 × 100 single-value Reads in flight) runs 16–21 % below master. The server ends the window with a 2.4–2.9 GB heap (master: 25 MB) and 4–8× the GC pause time. `browse` shows the same effect at a smaller scale: a 100–184 MB heap vs 60 MB. Every Read in this scenario is served by two `AsyncCustomNodeManager`s, so `OperationContext.GetSystemContext` gets a second template. Real clients hit the same case with one Read that spans namespaces, e.g. `Server` object nodes plus application nodes. Master keeps the second copy in a small immutable list. #4982 creates a `SystemContextCache` per request for it: a `ConditionalWeakTable<ServerSystemContext, ServerSystemContext>` plus a `Lock`. That is about 14 % of sampled allocation bytes. Each table has a finalizable container and keeps its entries in dependent handles. A `--trace-profile gc` trace shows the result: | per gen0 GC | master | #4982 | |---|---:|---:| | mark dependentHandles | 2.0 ms (0.3 KB) | 82.2 ms (25 MB) | | mark newFinalizeQueue | 0.1 ms | 21.8 ms (15 MB) | | plan+relocate+compact | 0.7 ms | 11.8 ms | ## Change - **Ordinary request contexts** are disposed at the end of their service request. They now keep the copies after the first in an immutable, lock-free linked list. - It is unbounded, so copies stay stable for any number of templates (`AlternatingLargeTemplateSetsReuseEachCopy`). - New entries are added with a compare-and-swap; a caller that loses the race scans the list again. Concurrent callers therefore share one copy per template (`ConcurrentLargeTemplateSetKeepsOneCopyPerTemplate`). - Nothing in it is finalizable or tracked by a GC handle. - **Shared subscriber contexts** (`EnableWeakSystemContextCache`) are retained by sessions and monitored items. They keep the weakly keyed table unchanged, so retired templates can still be collected while those contexts live. - **One behaviour change, for review:** a live *ordinary* request context now holds a replaced template's copy until it is disposed, i.e. until its request ends. The former `ReplacedTemplateIsNotRetainedByOperationCache` test now runs against a subscriber context (`ReplacedTemplateIsNotRetainedBySubscriberContextCache`). A new `ReplacedTemplateIsReleasedWhenRequestContextIsDisposed` covers the ordinary case. ## Results Paired harness runs, alternating master (6503d3c), #4982 (acbae3a) and this branch. Each value is the median of 3 rounds; runs with competing load on the host were discarded. Server GC (`SERVER_DOTNET_gcServer=1`); for `sub`, `DOTNET_gcServer=1` as well. | Scenario | master | #4982 | this PR | |---|---:|---:|---:| | `native-read` req/s | 697,361 | 549,132 | 669,219 | | `native-read` server CPU / request | 22.6 µs | 29.1 µs | 22.3 µs | | `native-read` server bytes / request | 2,401 | 2,620 | 2,266 | | `native-read` server heap at end | 25–28 MB | 2,393–2,874 MB | 22–23 MB | | `browse` req/s · heap | 51,181 · 57–65 MB | 54,504 · 110–164 MB | 58,802 · 60–66 MB | | `read` 100 nodes req/s · CPU | 66,258 · 226 µs | 67,996 · 218 µs | 68,733 · 218 µs | | `sub` 50 × 15 × 600 classic · delivered · CPU/notification | 25.6 % · 39.8 µs | 98.5 % · 3.8 µs | 98.3 % · 4.0 µs | An earlier round with a first version of this change gave the same picture: `native-read` 703k req/s vs 593k on #4982 and 722k on master. Context and the full three-way measurement are in #4869. ## Tests - `Opc.Ua.Server.Tests` (net10.0): 10,566 passed, 6 skipped, 8 failed. The 8 failures are the file-link tests (`FileLinksRejectReadWriteAndCopy`, `LinkedDirectoryRejectsAllOperations`, `RecursiveOperationsRejectLinkedDescendantsBeforeMutation`, `ConstructorRejectsLinkedRootAndAncestors`, `OperationsRejectReplacedRootAncestor`). They fail identically on unmodified #4982 on this Windows host (symlink privileges). - net48 was not run locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 of 7 tasks
This was referenced Nov 6, 2026
marcschier
pushed a commit
that referenced
this pull request
Nov 6, 2026
Stacked on #5005. Part of #5003. ## Problem Under load, Publish responses wait for their subscription. Decoded on arrival, the waiting notifications survive every gen0 collection with Workstation GC (gen0 budget about 8 MB). The messages get promoted while they wait, and then keep their notifications alive after the dispatch too. Cutting bytes per event did not help (#5005): what limits delivery is how much survives, not how much is allocated. ## Change `DataChangeNotification` and `EventNotificationList` bodies stay raw bytes in a pooled buffer until first read. `ExtensionObject` resolves them transparently, so no code that reads notifications changes. After the dispatch, `MessageProcessor` drops the decoded value, so a promoted message no longer keeps it alive. - New option: `ManagedSessionOptions.DeferNotificationDecoding` and `ManagedSessionBuilder.WithoutDeferredNotificationDecoding`, **on by default** for the V2 engine. Please check that default; it is easy to make opt-in. - `ServiceMessageContext.DeferNotificationBodies` is what the decoder reads. The classic engine leaves it off: its message cache keeps every decoded body, so it gains nothing (measured below). - `Opc.Ua.Types` gets `InternalsVisibleTo Opc.Ua.Client` for the release call. ### Behaviour changes - **Malformed notification body:** it no longer fails the whole Publish response. It is logged with the existing `DecodeEncodeableRecovered` message and not delivered, and the message is still acknowledged. Reading it finds no value; its bytes stay available through `TryGetAsBinary`. - **After the dispatch:** reading the `ExtensionObject` of a dispatched V2 message finds no value. Handlers get the decoded notifications, not this object, so they are not affected. ### Safeguards - A length the input cannot satisfy, or above `MaxMessageSize`, is rejected before renting. - Forward-only streams decode eagerly, as do decoders with namespace or server mappings. - A body in a message that is dropped undispatched is not returned to the pool; the GC collects it. ## Results Paired rotated runs, 3 per side, runs overlapping other load discarded. Workstation GC client. The server is #4982 + #5002 for both sides, because master's server cannot carry this load; baseline is that plus #5005. | Scenario | Delivered, baseline | Delivered, this PR | |---|---|---| | Events, 50 sessions × 15 subscriptions, managed | 71.2 % (67.7–89.4) | **97.4 %** (97.3–97.8) | | Same, `PoolNotifications` | 78.0 % (75.6–78.2) | **99.6 %** (99.3–100) | | Same, classic client (off) | 46.2 % (44.6–46.2) | 43.8 % (38.6–50.7) | | Data changes, 50 sessions × 15 subscriptions (#4869 command) | 70.9 % (69.3–71.3) | 74.8 % (70.2–74.9) | | Data changes, 10 sessions × 15 subscriptions | 100 % | 100 % | | Data changes, 2 sessions | 100 % | 100 % | | Events at 1000/s, 10 sessions × 15 subscriptions | 100 % | 99.8 % | - Events, managed: survived per gen0 GC falls from about 4.3 MB to 1.0 MB, and p50 latency from about 3.7 s to about 0.6 s. - Below saturation there is no measurable cost beyond 1–2 % more client allocation per notification for the copy into the buffer (245→248 B, 412→422 B). - Data changes at the #4869 command: client working set 620→475 MB. ## Not addressed The client is still paused about 12 s of the 15 s window at this load: GCs are shorter but more frequent because more is delivered. A heap dump shows about 4,300 dirty cards from long-lived per-Publish and per-subscription state, walked twice per GC, as the likely floor. That was not tested by changing it, and is follow-up work. ## Testing - New `DeferredExtensionObjectBodyTests` (16) and `DeferredBodyIsDispatchedAndDroppedAfterHandlerAsync`, plus an integration test for the option on both engines. - Locally on net10.0: all of `Opc.Ua.Types.Tests` and `Opc.Ua.Subscriptions.Tests`; the Subscription, MonitoredItem and ManagedSession subset of `Opc.Ua.Client.Tests`. - Locally on net48: `BinaryDecoder` and deferred body tests, `SubscriptionTests`, and `AcknowledgementProviderIntegrationTests`. These passed except `NativeSplitPublishMetadataSurvivesPartitionForwardingAsync(False)`, the flake fixed by #5013. They ran before the last small `ManagedSession` constructor change and rebase; only the net10.0 Client subset was re-run after the first, and `SubscriptionTests` after the second. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
marcschier
pushed a commit
that referenced
this pull request
Nov 7, 2026
## Summary The review follow-ups in #4982 slowed event delivery by about 10 % and added 50 % to the bytes per event, on the per-item permission check. This PR removes both costs. The event path is back on par with the build before those follow-ups (a33e0f5). There were two separate causes: 1. **A source-node lookup per item.** `GetOrAddEventPermissionAsync` called `FindNodeInAddressSpaceAsync` for every monitored item of every event. Each call allocates a `NodeHandle`, which was 31.7 % of all event bytes. All items of a delivery now share one memoized lookup. A retained delivery starts a new lookup, because the instance may have been replaced while it waited. 2. **A larger cached verdict.** The verdict grew to nine words, and reading it copied the struct through the GC write barrier, once out of the cache and once into the async state machine. That was 13 % of on-CPU samples, with no change in bytes, so the first fix alone did not show it. The verdict is now a class, and current verdicts are answered in a synchronous path that keeps the permission context on the stack. The authorization inputs are unchanged. A cached verdict is still bound to the session, identity, generations, routing snapshot and source-node instance. Anything other than a current cached verdict goes through the existing async validation, including its recheck after a suspension. The synchronous path awaits nothing, so it checks the restrictions once and recaptures the context once. ## Results `lt-events` and `lt-events500`, paired A/B on a 24-core machine with `--client classic`, medians. | Scenario | Metric | #4982 head | Lookup fix only | a33e0f5 | This PR | |---|---|---:|---:|---:|---:| | Full rate | Events/s | 2,760 | 2,838 | 2,999 | 3,034 | | Full rate | CPU per event | 2.88 ms | 2.65 ms | 2.45 ms | 2.47 ms | | Full rate | Bytes per event | 218 KB | 146 KB | 145 KB | 145 KB | | 500 events/s | Bytes per event | 266 KB | 196 KB | 195 KB | 195 KB | The columns come from three pairings: #4982 head vs lookup fix (3 rounds), and a33e0f5 vs each later build (4 rounds each). The a33e0f5 and "This PR" columns are from the same run. "Lookup fix only" events/s and CPU are from its run against a33e0f5 (3,105 events/s and 2.37 ms on the a33e0f5 side), so compare those two rows within a pairing, as throughput varies between runs. ## Tests - `EventSourceNodeIsLookedUpOncePerEventAsync` asserts one lookup per event across several items. - `CachedEventPermissionHonorsRestrictionsAndInvalidationOnNativeSessionAsync` uses a real session, because mocked sessions have no endpoint and never reach the synchronous path. Removing the restriction check from that path makes this test fail. - Before the rebase, 2,283 server tests passed with 5 skipped and 0 failed (event, monitored item, permission, condition and subscription filter), run before the new native-session test was added. - After the rebase onto master, `MonitoredNode2Tests` passes on net10.0, and `Opc.Ua.Server` builds on all targets. The benchmarks ran before the rebase. `MonitoredNode.cs` was unchanged between the #4982 head and master, so I did not repeat them. The synchronous path also changed afterwards from `IsCompletedSuccessfully` to a `Status` check, for net48 compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
marcschier
added a commit
that referenced
this pull request
Nov 7, 2026
Follow-up to #4982, now on master at 4a78fe7. The measurements below were taken before that merge, against the head of #4982 (3c82292). ## Why Each data change in `MonitoredNode2` allocated an item array, a dictionary of attribute values, a snapshot object and a channel waiter. This happens inside the node manager write path, so monitored writes spent more than half of their bytes here. ## Change One commit per step: 1. **Shared item array:** all changes for a node share one cached array of its data change items. Adding or removing an item, or disposing the node, invalidates the array, and it is rebuilt on the next change. A snapshot still delivers to the items captured when the change was admitted. 2. **Value slot:** the Value attribute is read once into its own snapshot field. The dictionary is only used for other attributes. The general path stays for non-Value attributes, the subscriber re-read and async reads. 3. **Channel drain:** the consumer drains the channel on each wake-up and waits with an uncancellable token, so `BoundedChannel` reuses its waiter instead of allocating one per wait. Dispose completes the writer before it cancels the consumer, so an idle consumer still stops. 4. **Snapshot reuse:** delivered snapshots go back to a small per-node pool and are cleared first. 5. **Tests:** `MonitoredNode2FanOutTests`. 6. **Public dictionary:** `DataChangeMonitoredItems` stays public and mutable, so the first read of it switches that node to a fresh copy of the items for every change. Server code uses an internal lookup and keeps the cached array. The channel keeps its capacity of 2 and its wait-when-full behaviour, so order and back-pressure are unchanged. There is no public API or wire change. The node manager write semaphore stays. ## Test New `MonitoredNode2FanOutTests` (9 cases): - Value is read once for all items. - Mixed attributes each receive only their own attribute. - An index range item does not change the value other items see. - 50 changes queued behind a blocked consumer arrive in order. - Items added or removed during delivery. - Direct changes to the public dictionary take effect on the next change. - Dispose stops an idle consumer. `Opc.Ua.Server.Tests` filtered to monitored node, data change, atomic emission, monitored item, value read authorization and index range tests on net10.0, on the rebased branch: 1470 passed, 0 failed, 5 skipped. I have not run the full suite locally. ## Measurement ServerLoadHarness, `--scenario sub --subs 1 --nodes 100 --writers 20 --security none --client classic`. Paired A/B with alternating order, 3 rounds, runs with foreign CPU load discarded; medians, #4982 → this PR: | scenario | values/s | CPU µs/value | bytes/value | lock contention | |---|---|---|---|---| | 1 session | 439k → 662k (+51 %) | 12.4 → 10.2 (−18 %) | 1606 → 721 (−55 %) | 14 → 10 | | 10 sessions | 369k → 562k (+52 %) | 22.8 → 20.2 (−11 %) | 1757 → 725 (−59 %) | 9 → 14 | | 10 sessions at an equal capped rate (`--write-interval 5`, 126k/s) | equal | 24.3 → 22.3 (−8 %) | 1790 → 763 (−57 %) | 54 → 78 | - The CPU ranges of the capped case overlap (24.0–26.4 vs 21.9–24.2), so treat −8 % as a tendency. - These runs measure the server fan-out. The client receives about 0.2 % of the values, about 1k notifications/s per session on both builds, because the monitored items keep only the latest value per publish cycle. They don't show end-to-end delivery. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
This was referenced Nov 8, 2026
marcschier
pushed a commit
that referenced
this pull request
Nov 8, 2026
) ## Why Since #4982 the CTT regression run ([ctt.yml run 42436745255](https://github.com/OPCFoundation/UA-.NETStandard/actions/runs/42436745255)) has two new failures in p18: `A & C Acknowledge/initialize.js` (CreateMonitoredItems returns BadNodeIdUnknown) and `A & C Refresh2/Err_002.js` (cascade). The NodeManager lifetime redesign changed the order in which the reference server registers its namespaces. In `--ctt` mode Alarms moved from ns=7 to ns=10, and the CTT settings hardcode `ns=7;s=Alarms.*`. We keep the new order and update the CTT configuration. Current `ConsoleReferenceServer --ctt` table: 2 ReferenceServer, 3/4 MemoryBuffer, 5/6 Boiler, 7 FileSystem/Temp, 8/9 Data, 10/11 Alarms, 12/13 GDS, 14 Diagnostics. ## Changes - `samples/UAReferenceServer.ctt.xml`: the alarm input nodes go from ns=7 to ns=10. Structure001 goes from `ns=3;i=2897` (the 1.5.378 Data namespace) to `ns=8;i=2897`. The cached NamespaceArray matches the current table. No other settings changed. - `ReferenceServerTests.NamespaceTableKeepsOrder` pins the namespace order of the reference server, so the next reorder fails a unit test instead of a CTT run. The test fixture has no FileSystem or GDS, so Alarms is at ns=9 there; the remarks explain the difference. - The CI project itself lives in the private CTT repository: OPCFoundation/UA-.NETStandard-CTT#2 (master378 keeps ns=7 through its overrides). ## Verification - Read the NamespaceArray of a local `ConsoleReferenceServer --ctt -a` and confirmed that `ns=10;s=Alarms.AnalogSource`, `SetpointSource`, `BooleanSource` and `ns=8;i=2897` resolve. - `ReferenceServerTests`: 61/61 pass on net10.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
marcschier
pushed a commit
that referenced
this pull request
Nov 8, 2026
# Description Since #4982, about half of master CI runs fail in `test-macos-net10.0 (17/18) - wot-other-integration`. The tests don't hang. The leg runs `Opc.Ua.WotCon.Tests` with `TestCategory=Integration`, excluding `Materialization`, sequentially, and the 45-minute per-project ceiling (`$PerProjectTimeoutMinutes`) kills it while tests are still passing. Each live test creates new RSA, P256 and P384 certificates, which is slow on macOS. Measured macOS test time per class (TRX of passing run 42394584570 on a1a3d48, 385 tests, 2486 s test time): | Class | Tests | Seconds | |---|---:|---:| | WotLegacyNativeAdmissionLiveTests | 123 | 615 | | WotRegistryIdentityLiveTests(False) | 57 | 551 | | WotRegistryIdentityLiveTests(True) | 57 | 491 | | WotRegistryProjectionLiveTests | 66 | 403 | | WotSelectedDependenciesLiveTests | 24 | 131 | | WotConfiguredOptionsTests | 21 | 118 | | everything else | 37 | ~140 | #4991 moved `WotRegistryIdentityLiveTests` into `wot-other-identity-integration`. On its own master run (42476750357), the remaining `wot-other-integration` still took **1782 s (29.7 min) of test time plus 856 s of build**: 271 tests, with `WotLegacyNativeAdmissionLiveTests` at 816 s. That leaves little margin on a slow runner. This PR moves `Opc.Ua.WotCon.Tests.WotLegacy*` (`WotLegacyNativeAdmissionLiveTests`, `WotLegacyTypeBindingLiveTests`, `WotLegacyMaterializationLiveTests`) into a new macOS-only entry, `wot-other-legacy-integration`. Windows, Linux and net48 are unchanged. Expected macOS test time per entry, from the 42476750357 TRX (the a1a3d48 numbers are in parentheses): | Entry | Tests | Expected | |---|---:|---:| | wot-other-integration | 144 | ~14 min (~13 min) | | wot-other-identity-integration | 114 | ~17–20 min (17.4 min) | | wot-other-legacy-integration | 127 | ~14 min (10.6 min) | ## Verification - `dotnet test --list-tests` on each filter: original = 385, and other 144 + identity 114 + legacy 127 = 385. The unique-name union equals the original set, and no name appears in two parts. - `get-ci-matrix.ps1`: 102 PR entries and 210 full entries, both under the 256 limit. The macOS WotCon entries are now `wot-materialization-core`, `-integration`, `-live-events`, `wot-other-core`, `wot-other-integration`, `wot-other-identity-integration` and `wot-other-legacy-integration`. - `CiMatrixScriptTests` (35 tests) pass, extended to require the new shard and to check that each `WotLegacy*` class is routed to exactly one shard. I didn't add per-fixture certificate caching: it would change the setup of every live test, which goes beyond this CI fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 10, 2026
marcschier
pushed a commit
that referenced
this pull request
Nov 10, 2026
## Problem The 2.0.2 promotion run (https://github.com/OPCFoundation/UA-.NETStandard/actions/runs/42814158478) failed in its first step: ``` The specified global.json file 'global.json' does not exist ``` The promote job in `release.yml` deliberately checks out nothing until it has validated the candidate run, and then checks out only the candidate's SHA. #4982 changed `Setup .NET 10.0` from `dotnet-version: '10.0.403'` to `global-json-file: global.json`, but the step still runs first, while the workspace is empty. Nothing was pushed or tagged. ## Fix Move `Setup .NET 10.0` to right after `Check out the candidate commit`. Now it reads the candidate's own `global.json`. The step installs an SDK and runs no repository code, so the rule that no repository code runs before the candidate checkout still holds. The only `dotnet` calls in the job are the `dotnet nuget push` steps, which come later. The same change goes to master and to `release/2.0`. A dispatched run uses the workflow from the branch it is started on, so the `release/2.0` PR is the one that unblocks 2.0.2. ## After merge Start the promotion again with the same candidate run, `release_run_id=42783219726` and channel `stable`. Do the dry run first. The candidate build does not need to be redone. ## Verification - `git diff` shows only the step move and the comment, and the file keeps CRLF line endings. - The step can only be exercised by a `release.yml` dispatch, so the dry run after merge is the real check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
marcschier
pushed a commit
that referenced
this pull request
Nov 10, 2026
## Problem The 2.0.2 promotion run (https://github.com/OPCFoundation/UA-.NETStandard/actions/runs/42814158478) failed in its first step: ``` The specified global.json file 'global.json' does not exist ``` The promote job in `release.yml` deliberately checks out nothing until it has validated the candidate run, and then checks out only the candidate's SHA. #4982 changed `Setup .NET 10.0` from `dotnet-version: '10.0.403'` to `global-json-file: global.json`, but the step still runs first, while the workspace is empty. Nothing was pushed or tagged. ## Fix Move `Setup .NET 10.0` to right after `Check out the candidate commit`. Now it reads the candidate's own `global.json`. The step installs an SDK and runs no repository code, so the rule that no repository code runs before the candidate checkout still holds. The only `dotnet` calls in the job are the `dotnet nuget push` steps, which come later. The same change goes to master and to `release/2.0`. A dispatched run uses the workflow from the branch it is started on, so the `release/2.0` PR is the one that unblocks 2.0.2. ## After merge Start the promotion again with the same candidate run, `release_run_id=42783219726` and channel `stable`. Do the dry run first. The candidate build does not need to be redone. ## Verification - `git diff` shows only the step move and the comment, and the file keeps CRLF line endings. - The step can only be exercised by a `release.yml` dispatch, so the dry run after merge is the real check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
marcschier
added a commit
that referenced
this pull request
Nov 22, 2026
…plicit (#5011) # Description Unify NodeManager capture, writer, prepared changes, and results around one lifecycle. Track exact generations separately from shared resources across routing, events, readiness, historian bindings, and retirement. Add verified recovery for retained cleanup, and coordinate directory cursor cleanup and concurrent disposal. Pass revocable admission explicitly through durable decisions, readiness, and AddNodes/DeleteNodes callbacks. Scope each permit to one callback and prevent a completed readiness initializer from borrowing an ancestor's admission. Preserve request routing pins, exact-generation recovery, and independent callers' ability to wait. Keep narrow ambient adapters for the released namespace-getter, session-close, and virtual-lookup contracts. Hosted DI exposes the optional callback lifecycle without changing the primary `INodeManagerLifecycle` contract. WoT retains its explicit `callerContext` and supports both ordinary and readiness-aware capture. Use exact-session lookup for stock activation; preserve dispatch fallback for custom managers and enumeration for reconciliation (F7). Retain xRegistry direct and DI composition with a supplied projection host and refresh strategy. Move server-free lifecycle cases to direct fixtures while retaining the hosted ownership and drain controls (F10). Remove the superseded 2.x Server, Runtime NodeSet, and WoT compatibility surfaces approved in #5129. Keep strong live inspection handles and supported read images; snapshot reconstruction requires the exact original generation. See `docs/NodeManagers.md` for migration and usage. ## Related Issues - Relates to #4931 and builds on #4982. - Incorporates the explicit callback admission follow-up from #5143. - Implements the compatibility disposition in #5129. The remaining performance gates are tracked in #4931, not closed by this PR. ## --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marcschier
pushed a commit
that referenced
this pull request
Dec 1, 2026
…NodeManager lifecycle qualification (#5214) **This PR clears every `dotnet format` finding in Opc.Ua.Types, Opc.Ua.Server, Opc.Ua.WotCon.Server, Opc.Ua.Server.Tests and Opc.Ua.WotCon.Tests.** After it, `dotnet format <project> --verify-no-changes` and `dotnet format analyzers <project> --verify-no-changes` exit 0 for all five projects. It also records the release qualification gates for the NodeManager lifecycle redesign (tracking issue #4931). ### dotnet format cleanup - **121 findings fixed in 49 files.** - Whitespace: 78. - Import order: 11. - RCS0009 blank lines before doc comments: 28. - RCS1139/RCS1142 doc tags: 3. - Final newline: 1. - **Formatting only, no code change.** The changes are whitespace, `using` order, blank lines and doc comments. Where the fixer generated empty `<summary>` or `<typeparam>` tags, I filled them in by hand. - **Builds stay clean.** Release builds of Opc.Ua.Server.Tests and Opc.Ua.WotCon.Tests (net10.0, including src) show 0 warnings and 0 errors. - **Overlap with #5212:** one file, `WotAtomicPublicationNativeTests.RetainedInputs.cs`, is also changed there. The two PRs change different lines (373–383 here, 191 there), so they merge cleanly. - **The first run also reported 42 CA1001, CA1859 and CA2012 findings, but they weren't real.** They came from a restore that the net48 test builds had left behind: - The messages name `ILogger` without its namespace. - They ask for concrete return types on interface implementations such as `ILogger.CreateLogger` and `IXRegistryProjectionStrategy.CreateResourceFile`. After a clean `dotnet restore UA.slnx`, the analyzer pass reports none, so no source changed for them. - **Why they had built up:** no CI job runs `dotnet format`, so findings accumulate unnoticed. Adding a `--verify-no-changes` step to CI would keep these projects clean. ### Release qualification (NodeManager lifecycle redesign) The gates cover #4982, #5011 (`d8e5e29cd`) and the follow-ups #5168, #5169, #5182, #5183 and #5206, tested on master `567363fad`. **Every gate passed. The runs found no product failure and no regression.** Full results, commands and per-file tables: [`perf/results/qualification-2026-11-30.md`](https://github.com/OPCFoundation/UA-.NETStandard/blob/romanett/qualification-gates-n2/perf/results/qualification-2026-11-30.md). | Gate | Result | |---|---| | Stress Contract + Integration (net10.0) | 45/45 passed (39 Contract + 6 Integration, the #5011 selection) | | Stress ChaosTCP, seed 5011 | 6/6 passed | | Stress subscription conformance, without LongRunning (extra) | 154/154 passed | | Release analyzer builds: Types, Server, WotCon.Server (all TFMs); Server.Tests and WotCon.Tests (net10.0, net48) | 0 warnings, 0 errors | | `dotnet format` on the same 5 projects | All findings fixed (see above). 0 were in `NodeManager/Lifecycle/` or `NodeManagerGeneration.cs`, and 4 came from #4982/#5011. | | Scoped lifecycle coverage (not the overall matched comparison), `233b3930e` → master (Server.Tests NodeManager namespace, net10.0) | Lines 87.18 % → 89.67 %, branches 78.86 % → 81.92 %. Tests 2,041 → 2,670, all passing. | - **No net48 stress run:** the stress project has no net48 target. With `CustomTestTarget=net48` it becomes a placeholder with no tests. - **Lifecycle not stressed:** the stress categories don't add, reload or remove a NodeManager under traffic. The 2,670 NodeManager-namespace tests from the coverage gate cover the lifecycle itself. - **One untested path:** no test reaches `LifecycleWriter`'s "failed after a durable decision" refusal (lines 598–602). It is the only behaviour path among the coverage drops. ### Proposed text for #4931 ("Qualification and performance") Sub-items for the open item "Freeze and qualify the follow-up source". The item itself stays unchecked: it asks for an overall matched CI coverage comparison, and this PR only has the scoped lifecycle comparison. I haven't edited the issue. ```markdown - [ ] Freeze and qualify the follow-up source on master `567363fad`, which includes #5168, #5169, #5182, #5183 and #5206 ([results](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/perf/results/qualification-2026-11-30.md), PR #5214). Still open: the overall matched CI coverage comparison, and the final net48/net10 managed and non-Windows NativeAOT verdicts on the final revision. - Stress, net10.0. Contract + Integration: 45/45 (39 Contract + 6 Integration, the #5011 selection). ChaosTCP seed 5011: 6/6. Subscription conformance stress without LongRunning: 154/154. The stress project has no net48 target. - Analyzers: Release builds of Opc.Ua.Types, Opc.Ua.Server and Opc.Ua.WotCon.Server (all TFMs) and Server.Tests/WotCon.Tests (net10.0, net48): 0 warnings. - `dotnet format`: all 121 style findings in those five projects are fixed. 0 were in `NodeManager/Lifecycle/` or `NodeManagerGeneration.cs`, and 4 came from #4982/#5011. `dotnet format --verify-no-changes` and `dotnet format analyzers --verify-no-changes` now pass on all five. The first run also showed 42 CA1001/CA1859/CA2012 findings, but they came from a stale net48 restore and are gone after a clean restore. - Scoped lifecycle coverage only (not the overall matched comparison), `233b3930e` → master (Opc.Ua.Server.Tests NodeManager namespace, net10.0): lines 87.18 % → 89.67 %, branches 78.86 % → 81.92 %. Lifecycle tests 2,041 → 2,670, all passing. Per-file drops are in guard, compatibility and exception boilerplate. The largest are `IDynamicNodeManagerBatchHost` (branches −14.7) and `INodeManagerReadinessNotification` (branches −16.7). - Not run: overall matched CI coverage, Soak, LongRunning stress, net11.0 stress. ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redesign NodeManager publication, routing and lifetime ownership
Description
This PR replaces the runtime NodeManager lifecycle machinery with a model that has one writer, explicit request views and per-generation lifetime. NodeManagers can still be added, reloaded and removed while the server runs. The difference is that every request, MonitoredItem, binding and continuation point now knows which exact generation it depends on. Retiring a generation therefore no longer needs global drains, a global binding semaphore or per-sample global locks.
Why
Over time, the lifecycle code grew into a set of mechanisms that interlock and that every server pays for, including servers that never reload a NodeManager:
(1,1)binding semaphore around everyActivateSessionand every Create/Modify/DeleteMonitoredItems call.TryCaptureSourceEmission(source-emission leases).These mechanisms caused real defects:
NodeBrowsersubclasses such asDirectoryBrowser;DrainPendingwas written without the lock;IReadOnlyListcontract was inconsistent.The locks also caused the data-change delivery regression tracked in #4869. Most of the remaining fixes treated symptoms. This PR changes the underlying ownership model instead.
Design
Generations and slots. A
NodeManagerSlotis the stable identity of a logical registration. Each committed add or reload publishes a newNodeManagerGenerationin that slot.slot.TryGetCurrent(...)captures the manager and its generation together.Explicit request views. Each request pins one immutable routing view on its
OperationContext. Pinning uses a striped, per-processor counter, so there is no global request drain. Requests that are already admitted finish on their pinned view.Single writer.
LifecycleWriter,ChangePreparer,AddressSpacePublisherandGenerationReconcilerreplace the old batch host:Committed means committed. After the swap, failures are reported on
LifecycleResult.IssuesandCleanupFailureand do not roll the commit back.RetryReconciliationAsyncretries only the stages that have not finished: application publication, reference callbacks, bindings, MonitoredItem recovery, readiness, identity policy and notifications. Each stage is checkpointed.Independent retirement. The
GenerationReclaimerretires each generation once that generation's own view epochs and admitted work have drained. A blocked generation does not delay unrelated ones.LifecycleResult.Retiredreports retirement separately from commit.Binding records instead of the binding semaphore. Session activation and all-events MonitoredItems bind to generations through binding records. These records join an in-flight bind or reuse a finished one. Retirement seals the records before it enumerates them.
MonitoredItem handoff. A reload uses either
Migrate(the default) orInvalidate:Migratemoves compatible items to the new generation and keeps their ids. An item whose node was removed or is incompatible gets oneBadNodeIdUnknown.Invalidategives every itemBadNodeIdUnknown.Items track the exact source generation. A source release that fails keeps its ownership until a retry succeeds.
Continuation points are validated, not retained. Browse and history continuation points hold a weak reference to the generation that issued them. Once that generation's gate closes,
BrowseNextandHistoryReadreturnBadContinuationPointInvalid.IBrowseContinuationDependenciesis removed, and lazy browsers such asDirectoryBrowserpage normally again.Copy-on-write type tables. A type-table snapshot shares the registration graph until the first write. Capture no longer copies the table while holding the serving lock.
Lock-free delivery path.
OperationContextper session instead of one per MonitoredItem. In the 50 × 15 × 600 workload this replaces 450,000 contexts.What changes
Server core (
src/Opc.Ua.Server/NodeManager,Server,Subscription)Lifecycle/:LifecycleWriter,ChangePreparer,AddressSpacePublisher,GenerationReconciler,GenerationReclaimer;IPreparedChanges,LifecycleChange,IRequestRouting,NodeManagerReadinessScope,LifecycleWaitDiagnostics;NodeManagerGeneration,StripedCounter,MonitoredReadVerdict,ConditionRefreshTarget,INodeManagerMonitoredItemSourceandIMonitoredItemGenerationBinding.MasterNodeManager.BindingAdmission,RequestManagerLifecycleExtension(the global request drain),INodeManagerMonitoredItemLifecycle,IDetachableMonitoredItemand the rollback protocol for recovering monitored items.MasterNodeManagernow handles namespace registration and the cleanup of external references across replacement generations.Historian, alias names and the GDS
StagedHistorianProviderRegistrystages historian bindings for a candidate and releases them on abort. A historian that serves requests but is not owned by the candidate is never disposed.Historizethat borrows a default historian keeps working after the owning manager reloads or is removed.ApplicationsNodeManageralias names run through the lifecycle, including background refresh in the hosted GDS.Consumers moved to the new API
Fixes from review on #4921 and #4982
DeleteNodes).CommitAsync, or a failed decision, disposes the candidate and drains its operation.CI and tooling
global.json.Breaking changes and migration
INodeManagerLifecycle.ApplyAsync([LifecycleChange.Add/Reload/Remove(...)]). For a durable decision, useBeginAsync→PrepareAsync→CommitAsync(decideAsync, publishCommittedState).[Obsolete], and each message names its replacement.NodeManagerBatchResultremains as a compatibility view ofLifecycleResult.MigrateandInvalidate. The obsoleteGracefulis an alias forMigrate, because retained generations are no longer supported. The obsoleteImmediateis an alias forInvalidate.OperationContextis needed for lifecycle calls. Services, Methods, event sources, sessions and hosted-service callbacks all use the same context-free transaction. A nested lifecycle mutation inside the decision callback is rejected.InitialFactories.IBrowseContinuationDependenciesandTryGetContinuationDependencieswere removed. A continuation point from a retired generation returnsBadContinuationPointInvalid. Seedocs/migrate/2.0.x/node-states.md.INodeManagerMonitoredItemLifecycle,IDetachableMonitoredItemandIHistorianContinuationDependencies.Performance
These are five alternating A/B pairs on the #4869
subworkload (50 sessions × 15 subscriptions × 600 nodes, encrypted, 100 ms publishing, 150 ms writes), Release build, median of the pairs:Delivery is still below the historical ~93 %, so #4869 stays open. Event delivery at scale (#4979) recovers from about 100 to about 3,000 generated events/s.
Type-table snapshot capture with 16,384 registered types drops from 26.8 ms / 4.6 MB to 0.017 ms / 5.2 KB. The copy moves to the first write; it is not removed.
docs/Benchmarks.mdhas the full tables, with the caveat that the reference SHAs and machines differ between runs.Related Issues