Skip to content

[Perf] Capture async-health signals within the performance benchmarks - #5068

Draft
mdaigle wants to merge 47 commits into
mainfrom
dev/mdaigle/automatic-openasync-perf-coverage
Draft

mdaigle wants to merge 47 commits into
mainfrom
dev/mdaigle/automatic-openasync-perf-coverage

Conversation

@mdaigle

@mdaigle mdaigle commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Capture async scheduler health inside the existing BenchmarkDotNet perf flow for four OpenAsyncBurst.OpenQueryClose states: Empty, Warm, Oversubscribed (16 pool slots), and NonPooled. There is no standalone sweep, production driver/API change, or new pipeline trigger. Existing benchmarks remain uninstrumented.

  • The standard OpenAsyncBurst config requests 100 ms of added SQL RTT. The harness applies the configured delay on Linux only; other platforms run unshaped. Health artifacts report requested and applied values separately. Runners that omit AdditionalRttMilliseconds request zero delay.
  • The standard runnerconfig.jsonc controls the remaining settings. There is no separate preset or queue selector. Jobs support PerRunner isolation by default or PerCase; the burst runner uses PerCase. The standard config gives the burst runner a ten-minute case timeout. Configure the pool version separately.
  • Work counts are defined on the benchmark. Empty runs one cold wave of 64 workers. Warm, Oversubscribed, and NonPooled use 16 waves with 20, 5, and 1 operations per worker, respectively. The same definition drives execution, BDN normalization, and diagnostic metadata. Source baselines build and run their own perf harness. New cases without a baseline report only current health metrics. Package baselines still build the candidate harness against the selected package.
  • The diagnoser observes Startup (including fixture work) and ExtraIteration (workload only), not timing iterations. It preserves raw probes, resource samples, queue/open timestamps and outcomes. First-worker records survive ordinary-record truncation. Schema 3 keeps four displayed metrics plus completeness fields; schema 2 remains readable.
  • The report takes independent maxima across matching phases and repetitions without pooling percentiles. Rows sort by dispatch p99 percentage delta. Current dispatch p99 is green below 1 ms, yellow from 1 through 10 ms inclusive, red above 10 ms, or unknown when missing. Sampling qualifications are separate. The runners retain their original fail-fast behavior; the async-health report is generated after successful benchmark execution and any timing comparison.
  • Linux shaping requires a local TCP SQL endpoint and tc permission. The helper adds 50 ms each way, refuses foreign queues, checks matched traffic and drops, and removes only its owned rules. Unsupported Linux shaping fails explicitly. BDN uses the in-process lifecycle hooks in the test-only preview package and skips extra JIT preparation without reducing configured iterations.

See async-health.md for the protocol, configuration, and evidence limits. The benchmark uses fixed per-case work counts rather than a sampling profile. Driver UnitTests and its dependencies are unchanged. The perf harness is validated by running the benchmarks and generating the report.

Issues

Related to #5014. Its experiment branch remains unchanged.

Testing

On 507f17234, driver UnitTests built with no BenchmarkDotNet dependency, and the perf harness built and ran all four workloads against local Windows SQL. The report contained four rows backed by eight diagnostic windows.

$tests = 'src\Microsoft.Data.SqlClient\tests'
dotnet build (Join-Path $tests 'UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj') -c Debug -f net10.0 -p:ReferenceType=Project --nologo -v quiet
# Passed: 0 warnings/errors.
dotnet build (Join-Path $tests 'PerformanceTests\Microsoft.Data.SqlClient.PerformanceTests.csproj') -c Release -f net10.0 -p:ReferenceType=Project --nologo -v quiet
# Passed: 0 warnings/errors.
# From the current results directory, with RUNNER_CONFIG, DATATYPES_CONFIG, and PERF_BENCHMARK=OpenAsyncBurst set:
dotnet $dll
# Passed: all four workloads.
python -B (Join-Path $scripts 'benchmark_health_report.py') --results-dir $temp.FullName
# Passed: four Markdown rows.

Earlier validation:

On 44691b1af8a09a9f05256858bb4a65beab79e716:

$p = 'src\Microsoft.Data.SqlClient\tests\PerformanceTests\Microsoft.Data.SqlClient.PerformanceTests.csproj'
dotnet build $p -c Release -f net10.0 -p:ReferenceType=Project -o artifacts\rtt-policy-current --nologo -v quiet
# Passed: 0 warnings/errors.
dotnet build $p -c Release -f net10.0 -p:ReferenceType=Package -p:MdsPackageVersion=7.1.2 -o artifacts\rtt-policy-baseline --nologo -v quiet
# Passed: 0 warnings/errors.
python -B -m unittest discover -s eng\pipelines\perf\scripts\tests -p test_runner_config.py -q
# Passed: all 5 existing tests.
  • dotnet artifacts\rtt-policy-current\PerformanceTests.dll and dotnet artifacts\rtt-policy-baseline\PerformanceTests.dll with PERF_LIST_BENCHMARKS=json, also run under /opt/dotnet/dotnet in Ubuntu WSL: both builds selected 100 ms for Linux and 0 ms for Windows with both the stock template and an older config explicitly asking for 0. An unrelated runner retained its own setting.
  • dotnet <current PerformanceTests.dll> from a fresh artifact directory with PERF_BENCHMARK=OpenAsyncBurst and a temporary integrated-auth SQL config explicitly asking for 100 ms: all four Windows BDN processes exited successfully and recorded zero applied delay.
  • In a disposable Linux network namespace, the netem.py start and stop commands passed using the RTT read from the compiled harness, on a loopback TCP echo target. Evidence showed 50 ms per direction and confirmed cleanup. This was not a new authenticated Linux SQL run.

Earlier: 38 focused unit tests passed on d6c8bfad. Perf run 193740 passed with all four workloads at 100 ms on an earlier revision. No fresh pipeline run was queued for the platform-policy change.

  • Tests added or updated (perf coverage runs in the benchmark harness; driver UnitTests are unchanged)
  • Public API changes documented (not applicable; driver unchanged)
  • Verified against customer repro (earlier local reproduction; no driver fix claimed)
  • Ensure no breaking changes introduced (production behavior unchanged; perf runner settings documented)

Guidelines

Please review the contribution guidelines before submitting a pull request:

Build one candidate-owned harness against both drivers and retain matched regression, baseline-debt and invalid-evidence outcomes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mdaigle
mdaigle requested a review from a team as a code owner November 13, 2026 21:36
Copilot AI balanced review requested due to automatic review settings November 13, 2026 21:36
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 13, 2026
@mdaigle mdaigle added this to the 8.1.0-preview1 milestone Nov 13, 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.

🟡 Changes recommended

Sequential package comparisons in both scripts can reuse baseline binaries for the current pass, hiding candidate regressions, and the health build fails for the specified preview baseline because required dependency overrides are missing.

3 open issues
What changed in this PR

Adds a bounded OpenAsync health phase before BenchmarkDotNet in SqlClient’s existing performance runners, without changing production driver code or pipeline triggers. This is separate from the broader experiments in #5014.

Changes:

  • Adds 20 workload cases with three paired repetitions, using the same harness against candidate and baseline drivers.
  • Introduces matched regression gating, raw evidence, summaries, and optional Linux network-delay testing; default runs add no delay.
  • Integrates both runners, increases timeout defaults, and adds tests and documentation.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft.Data.SqlClient.UnitTests.csproj Links harness sources into modern .NET unit tests.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Measurements/​ThreadPoolProbeRecorderTests.cs Tests bounded probe accounting.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Measurements/​ThreadPoolHealthObserverTests.cs Tests observer failure and incomplete evidence.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Measurements/​OpenAsyncHealthSettingsTests.cs Tests workload-setting validation.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Measurements/​OpenAsyncHealthRecorderTests.cs Tests outcome retention and counter snapshots.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​OpenAsyncHealth/​Program.cs Adds the standalone command-line entrypoint.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​OpenAsyncHealth/​OpenAsyncHealth.csproj Supports source and package driver references.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Microsoft.Data.SqlClient.PerformanceTests.csproj Excludes standalone harness sources from BenchmarkDotNet.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​ThreadPoolProbeRecorder.cs Records probe timing and missing callbacks.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​ThreadPoolHealthObserver.cs Samples scheduling and process resources.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​OpenAsyncHealthRecorder.cs Retains operation outcomes and counters.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​OpenAsyncHealthExperiment.cs Executes bounded connection workloads.
eng/​pipelines/​perf/​sqlclient-perf-pr-pipeline.yml Adds 30 minutes to the PR timeout default.
eng/​pipelines/​perf/​sqlclient-perf-pipeline.yml Adds 30 minutes to the standard timeout default.
eng/​pipelines/​perf/​sqlclient-perf-experiment.yml Adds 30 minutes to the experiment timeout default.
eng/​pipelines/​perf/​scripts/​tests/​test_openasync_health.py Tests evidence validation, comparisons, and orchestration.
eng/​pipelines/​perf/​scripts/​tests/​test_openasync_health_runners.py Tests both runner integrations and exit handling.
eng/​pipelines/​perf/​scripts/​tests/​test_openasync_health_process.py Adds opt-in executable lifecycle tests.
eng/​pipelines/​perf/​scripts/​tests/​test_openasync_health_netem.py Tests network-rule ownership and cleanup.
eng/​pipelines/​perf/​scripts/​run-perf-tests.sh Runs health coverage before Linux benchmarks.
eng/​pipelines/​perf/​scripts/​run-perf-tests.ps1 Runs health coverage before Windows benchmarks.
eng/​pipelines/​perf/​scripts/​openasync_health.py Builds, pairs, validates, and reports health runs.
eng/​pipelines/​perf/​scripts/​netem.py Adds optional SQL-only loopback delay.
eng/​pipelines/​perf/​README.md Documents automatic coverage and timeout changes.
eng/​pipelines/​perf/​openasync-health.md Explains workloads, gates, artifacts, and limitations.

Review effort: Balanced

@mdaigle
mdaigle marked this pull request as draft November 13, 2026 22:14
Observe marked BDN workloads in extra iterations, run burst regression cases automatically, and build matched candidate benchmark sources against source baselines.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:48
@mdaigle mdaigle changed the title [Perf] Automatically run matched OpenAsync health coverage [Perf] Add async-health diagnoser, automated measurements, and regression benchmarks Nov 16, 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.

🔵 Needs a closer look

The new performance gates and BDN lifecycle changes need human review of authenticated SQL pipeline runs on Linux and Windows, since SQL-free checks do not establish end-to-end measurement validity for this revision.

1 open issue
2 resolved since last review

Review effort: Balanced

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.55%. Comparing base (17bef7b) to head (507f172).
⚠️ Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5068      +/-   ##
==========================================
+ Coverage   68.99%   70.55%   +1.55%     
==========================================
  Files         314      315       +1     
  Lines       45857    70159   +24302     
==========================================
+ Hits        31638    49499   +17861     
- Misses      14219    20660    +6441     
Flag Coverage Δ
CI-SqlClient ?
sqlclient-pr 70.55% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Remove the standalone pre-benchmark sweep and network shaping. Record startup/warmup and extra-iteration queue/open/outcome signals in the perf tests, retaining missing work and resource evidence.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 19:12
@paulmedynski paulmedynski changed the title [Perf] Add async-health diagnoser, automated measurements, and regression benchmarks [Perf] Add async-health diagnoser, automated measurements, and regression benchmarks [workflow replay] Nov 16, 2026
@paulmedynski paulmedynski changed the title [Perf] Add async-health diagnoser, automated measurements, and regression benchmarks [workflow replay] [Perf] Add async-health diagnoser, automated measurements, and regression benchmarks Nov 16, 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.

🟡 Changes recommended

The oversubscribed benchmark may never create pool waiters, leaving the advertised waiter-wakeup regression untested, and the PR description claims health checks and gates that are not implemented.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread eng/pipelines/perf/async-health.md Resolved
@mdaigle mdaigle changed the title [Perf] Add async-health diagnoser, automated measurements, and regression benchmarks [Perf] Capture async-health signals within the performance benchmarks Nov 16, 2026
Skip preview-only automatic JIT tier-promotion workload, retaining configured warmups and measurement counts. Reserve collection grace inside the pipeline task budget and retain partial per-unit logs and timings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 23:56

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.

🔵 Needs a closer look

Human assessment is needed because multi-warmup timing includes setup and cleanup between batches, potentially distorting the reported workload throughput.

2 open issues

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Host-wide Linux traffic shaping and BDN preview lifecycle changes need human validation of authenticated SQL/pipeline execution, timeout/cancellation, and owned-rule cleanup on the latest revision, since supplied Linux smoke evidence covers only TCP echo.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because the string-based switch lookup bypasses compiler checks in UnitTests and can silently treat a missing or renamed member as an unavailable V2 path.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Privileged Linux traffic shaping and preview BenchmarkDotNet lifecycle changes require human review because the final revision lacks fresh authenticated SQL validation covering execution, cancellation, and cleanup on the actual perf host.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because the pairing key treats the deliberately changed switch flag as a mismatch, leaving baseline and current rows unmatched with all performance deltas reported as N/A.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because changing benchmark working directories can break relative certificate paths in existing connection strings and cause connection validation failures.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Privileged Linux network shaping and cross-runner lifecycle/cancellation changes require human validation, especially timeout cleanup and baseline/current execution, because the latest revision lacks fresh authenticated Linux SQL testing and shaping smoke checks used TCP echo instead.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because matching includes the intentionally changed connection-pool flag, producing unmatched health rows with N/A deltas instead of a V1/V2 comparison.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Privileged Linux traffic shaping, cancellation cleanup, and preview BDN lifecycle changes require human validation because the latest revision lacks a fresh authenticated Linux SQL run.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Privileged Linux traffic shaping and cancellation cleanup depend on preview lifecycle hooks, and the latest revision lacks fresh authenticated Linux validation, requiring human review of runtime evidence.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Preview BDN lifecycle hooks and privileged Linux shaping require targeted human runtime validation because latest-revision authenticated Linux SQL execution and failure/cancellation cleanup remain unverified.

No open issues 🎉

Review effort: Balanced

mdaigle and others added 2 commits November 24, 2026 14:29
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Preview BDN lifecycle/cancellation hooks and privileged Linux traffic-control rollback require human validation because current-revision authenticated Linux SQL and cancellation/cleanup evidence is missing.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

The preview BDN lifecycle and privileged Linux network cleanup affect the shared perf flow, but the final revision lacks authenticated Linux SQL end-to-end validation of shaping, cancellation cleanup, and retained diagnostics.

No open issues 🎉

Review effort: Balanced

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.

🔵 Needs a closer look

Human validation is needed because the final revision lacks authenticated Linux SQL verification of privileged traffic shaping, BDN preview integration, and cancellation cleanup.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because untested privileged queue-installation and cleanup failure paths could leave root queues behind, disrupting later runs and other clients.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

4 participants