Skip to content

Reduce assertion telemetry contention - #10560

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/reduce-assertion-telemetry-contention
Aug 18, 2026
Merged

Reduce assertion telemetry contention#10560
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/reduce-assertion-telemetry-contention

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

  • replace contended ConcurrentDictionary.AddOrUpdate calls with allocation-free steady-state lookup plus Interlocked.Increment
  • preserve best-effort drain semantics with atomic dictionary swaps and volatile counter reads
  • add coverage for concurrent updates/drains, telemetry opt-out behavior, reset behavior, and steady-state allocations

Performance

Standalone .NET 9 Release measurements over 5,000,000 operations (median of 7, five pre-populated assertion names):

Scenario Current Updated
Single thread 280.26 ms 101.72 ms
4 contending threads 371.49 ms 106.45 ms
Steady-state allocation 0 B 0 B

An eager GetOrAdd(key, new StrongBox<long>()) candidate was rejected because argument evaluation allocated 120 MB over the same 5,000,000 calls.

Validation

  • TestFramework unit-test project builds across all target frameworks with 0 warnings and 0 errors
  • 1,513 TestFramework unit tests pass on net8.0
  • two independent concurrency/allocation reviews completed, with all findings addressed

Closes #10559

Use atomically incremented boxed counters to avoid ConcurrentDictionary update contention while preserving best-effort drain semantics. Add concurrency, disabled-telemetry, reset, and allocation regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 11, 2026 18:08
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes assertion telemetry counters to reduce hot-path contention while preserving best-effort drain behavior.

Changes:

  • Replaces dictionary value updates with boxed atomic counters.
  • Adds concurrency, reset, opt-out, and allocation coverage.
Show a summary per file
File Description
src/TestFramework/TestFramework/Internal/TelemetryCollector.cs Implements atomic boxed counters and snapshot draining.
test/UnitTests/TestFramework.UnitTests/TelemetryCollectorTests.cs Covers counting, concurrency, draining, opt-out, and allocations.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

Comment thread src/TestFramework/TestFramework/Internal/TelemetryCollector.cs
@Evangelink
Amaury Levé (Evangelink) merged commit 1c5bf2c into main Aug 18, 2026
55 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/reduce-assertion-telemetry-contention branch August 18, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[perf-improver] Reduce TelemetryCollector.TrackAssertionCall contention on the assertion hot path

3 participants