Merged
Conversation
thomhurst
added a commit
that referenced
this pull request
Apr 18, 2026
* perf: discovery/init path cleanup (#5528 items 7-10) Scaffolding commit for PR C. Will contain: - #7 TestGroupingService: make sync, move trace logging behind guard - #8 LINQ chains in discovery/init replaced with direct loops - #9 TestSessionContext.HasFailures via atomic counter (O(1)) - #10 TestContext.Id lazy string from stored Guid or counter * perf: discovery/init path cleanup (#5528 C) - TestGroupingService: hot path now fully synchronous; trace-message emission moved behind an IsTraceEnabled guard. Eliminates the async state machine when tracing is off (the normal case). - LINQ chains replaced with direct loops in EventReceiverOrchestrator, HookDelegateBuilder, TestDiscoveryContext, TestDiscoveryService, and TestSessionCoordinator. Also switched InitializeTestCounts to accept IReadOnlyList<AbstractExecutableTest> directly, dropping the Select projection + ToList fallback. - TestSessionContext: added HasFailures backed by a lock-free failure counter incremented from TestCoordinator on Failed/Timeout/Cancelled. Replaces an O(N) AllTests.Any() traversal in the after-session hook path. - TestContext.Id: Guid is stored and the string form is materialized lazily. The registry is keyed by Guid internally; GetById(string) parses once. Removes the eager ToString allocation for tests that never access the string Id. * perf: mark TestContext._idString volatile for weak-memory safety Addresses review feedback on #5611: `_idString ??= _idGuid.ToString()` is not safe under weak memory ordering (ARM/WASM/AOT). A reader could observe a stale null even after another thread wrote the string. Mark the field volatile — reference writes are atomic, so a benign double ToString is possible but harmless; volatile fixes the staleness. * test: sync PublicAPI snapshots for TestSessionContext.HasFailures CI failed on net8.0/net9.0/net4_7 Core PublicAPI diff at line 1684 — the HasFailures property added in the prior commit was only reflected in the net10.0 snapshot. Add the same entry to the other framework variants so the PublicAPI verification passes across all TFMs. * refactor: make TestSessionContext.HasFailures internal Only consumer is HookExecutor (engine-internal) — no user-facing need to expose the failure-count gate. Dropping to `internal` shrinks the public surface, removes the PublicAPI snapshot entries across all four TFMs, and keeps the counter representation free to evolve. * perf: publish TestContext._idString via Interlocked.CompareExchange Replaces `volatile` field + `??=` with `Volatile.Read` + `CompareExchange` so only one string is ever published even if the Id format becomes non-deterministic in the future. ARM/WASM acquire semantics preserved via `Volatile.Read` on the fast path. * fix: address review feedback on engine discovery/init cleanup - TestScheduler: call MarkFailure() on circular-dep failures so HasFailures reflects them (prior O(N) AllTests scan caught these; counter-based HasFailures missed them since circular-dep tests skip the TestCoordinator lifecycle switch) - TestDiscoveryContext: BuildUniqueAssemblies/TestClasses use List+HashSet pair to guarantee first-occurrence insertion order (matches prior LINQ Distinct() contract; HashSet.CopyTo ordering is an implementation detail) - TestContext: remove unused internal RemoveById; callers now use RemoveFromRegistry() directly * docs: clarify why BuildUniqueAssemblies uses List+HashSet pair
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.
No description provided.