Skip to content

Add opt-in async-health benchmark diagnostics - #5014

Draft
mdaigle wants to merge 12 commits into
mainfrom
dev/mdaigle/perf-test-changes
Draft

mdaigle wants to merge 12 commits into
mainfrom
dev/mdaigle/perf-test-changes

Conversation

@mdaigle

@mdaigle mdaigle commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Add opt-in [AsyncHealthDiagnoser] selection on benchmark classes and methods. All 11 SQL-free calibration benchmarks are selected.
  • Observe ThreadPool responsiveness and process resources during one BenchmarkDotNet extra diagnostic iteration while preserving normal timing, memory, and threading reports.
  • Use BenchmarkDotNet 0.16.0-preview.1 in-process diagnoser hooks instead of a custom engine factory. Preserve per-case execution timeouts and fail on incomplete diagnostic windows.
  • Add bounded probe accounting, versioned raw artifacts, reporting helpers, calibration workloads, and observer/lifecycle tests.
  • Collect diagnostic sidecars through existing performance runners without separate measurement-mode configuration; retain workload-config selection and current-only pipeline runs.
  • Document observer coverage, lifecycle boundaries, limitations, and local/pipeline usage. No shipped driver public API changes.

Experiment preservation: 2026-11-13

This PR also preserves the subsequent experiments through 02d68bb1be990f50e82d2c20bee24c231fdcf831: the OpenAsyncLab TUI, SQL-only netem tooling, experimental live V2 LongRunning dispatch switch, fresh-process OpenAsync health harness, balanced V1/V2/non-pooled cold/warm coverage, comparison gates, and report generators. The switch is an opt-in experiment, not a production recommendation or a fully asynchronous connection-creation fix.

Compact reports, SVG graphs and all summary rows are checked in under OpenAsyncLab/reports/2026-11-13. This includes the 240-run authenticated WSL RTT study, the earlier 63-run Windows/negative-control study, and 40 managed/native SNI success-path execution validations. Large raw probe/log archives remain in the originating session Library rather than large Git blobs.

A separate focused PR is being prepared from main for automatic performance-pipeline execution. This PR remains the preservation branch for the broader experiments; it is not a claim that those experimental changes are ready to ship together.

Issues

No linked issue.

Testing

Latest experiment validation

  • python -B -m unittest discover -s eng\pipelines\perf\scripts\tests -p 'test_openasync*.py' -q — passed: 22 tests.
  • dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj -c Release -f net10.0 --filter 'FullyQualifiedName~OpenAsyncHealthSettingsTests|FullyQualifiedName~ThreadPoolHealthObserverTests|FullyQualifiedName~AsyncHealthTests' --nologo -v quiet — passed: 19 tests, no skips.
  • Windows and Linux Release PerformanceTests builds passed. The 20-case success-path matrix executed with real Windows SQL under both managed and native SNI (40 runs), with no pre-deadline SQL errors. This was execution validation, not a repeated performance comparison.
  • The authenticated WSL study completed 240 runs: 16 configurations, RTT 0/20/50/100/200 ms, three repetitions. The default V2 64-worker/100-ms-RTT scheduler regression reproduced in all three runs. Reports distinguish eight-second deadline cancellation from natural fifteen-second connection timeouts.
  • git diff --cached --check — passed before the preservation commit.
  • The newly extracted automatic-pipeline integration has not been validated remotely as part of this preservation update. No new net462 validation was performed.

Earlier validation (historical)

  • Release build of PerformanceTests for net10.0 passed with ReferenceType=Project.
  • All 49 performance-script Python tests passed, including real-process lifecycle and timeout checks, shell config generation/redaction, and timing-ingestion isolation.
  • All 13 focused async-health and observer unit tests passed on net10.0, with no skips.
  • Staged whitespace validation passed.
  • Azure pipelines, SQL-backed integration tests, and net462 validation had not been run locally at this earlier stage.

Full Local Calibration: 2026-11-05

All 11 benchmarks completed in 185 seconds and produced 11 validated, completed diagnostic windows with Supported coverage. Zero dropped, rejected, skipped, producer-missed, or late/outstanding probes across the run.

Settings: one process, LaunchCount=1, IterationCount=2, InvocationCount=1, WarmupCount=1, Monitoring, default 25 ms probe cadence / capacity 64 / 500 ms completion grace. Windows 11 Hyper-V, .NET 10.0.14, SDK 10.0.403, 16 logical cores. No ThreadPool limit changes.

Benchmark Timing mean (s) Probe dispatch p99 (ms) Peak pool threads Peak queue
ProbeOnly 3.005 0.248 2 0
AsyncWait 3.011 0.108 4 0
AsyncWaitAwaited 3.014 0.116 8 0
Blocking 3.019 1454.847 22 69
BlockingLongRunning 1.510 0.800 22 0
SyncOverAsync 1.512 1.062 36 0
BoundedBlockingFour 12.064 0.131 8 0
BoundedBlockingEight 6.027 0.161 11 0
LockContention 3.496 0.440 34 0
MixedOneBlocking 3.012 0.144 34 0
MixedFourBlocking 3.012 0.727 6 0

Timing means come from normal iterations; health metrics come from each case's separate diagnostic iteration. This is a short local calibration on a VM, not a statistically independent process comparison or proof of async correctness. Pool thread peaks include threads retained from earlier cases and exclude dedicated LongRunning threads. Raw reports and the full log were retained outside the checkout.

Guidelines

Please review the contribution guidelines before submitting a pull request:

Checklist

  • Tests added or updated
  • Public API changes documented (no shipped driver public API changes)
  • Verified against customer repro (not applicable; benchmark infrastructure)
  • Ensure no breaking changes introduced to the driver public API

Copilot AI balanced review requested due to automatic review settings November 6, 2026 00:59
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 6, 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 async-health observer contaminates memory/threading metrics, while incompatible summary inputs and unreachable current-only branches break reporting and per-unit orchestration.

4 open issues
What changed in this PR

Adds opt-in async-health diagnostics to SqlClient’s benchmark infrastructure, measuring ThreadPool responsiveness and process resources without changing shipped driver APIs.

Changes:

  • Adds attribute-based diagnosis, bounded probe accounting, versioned artifacts, and SQL-free calibration workloads.
  • Extends performance runners and pipelines with workload-config selection, sidecar collection, and current-only orchestration.
  • Adds observer, reporting, and lifecycle tests, plus usage and measurement-limit documentation.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft.Data.SqlClient.UnitTests.csproj Links observer sources into modern-framework unit tests.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Measurements/​ThreadPoolHealthObserverTests.cs Tests observation shutdown and grace-period behavior.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​AsyncHealthTests.cs Tests probe accounting, snapshots, failures, and options.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​runnerconfig.default.jsonc Adds observer defaults and updates timeout documentation.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​runnerconfig.connection-smoke.jsonc Adds bounded connection and contention workloads.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​README.md Introduces diagnoser selection and links detailed guidance.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Program.cs Registers calibration workloads and bounds benchmark execution.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​ThreadPoolProbeRecorder.cs Implements bounded probe accounting and snapshot copying.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​ThreadPoolHealthObserver.cs Samples ThreadPool responsiveness and process resources.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​AsyncHealthDiagnoser.cs Integrates attribute selection and diagnostic lifecycle hooks.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Measurements/​AsyncHealthCase.cs Exports versioned case measurements and failure artifacts.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Config/​Config.cs Adds observer and calibration configuration fields.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Config/​BenchmarkConfig.cs Registers diagnosis and per-case timeout handling.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​Config/​AsyncHealthOptions.cs Defines and validates observer settings.
src/​Microsoft.Data.SqlClient/​tests/​PerformanceTests/​BenchmarkRunners/​AsyncHealthCalibrationRunner.cs Adds SQL-free interference controls and lifecycle counters.
src/​Microsoft.Data.SqlClient/​tests/​Directory.Packages.props Updates BenchmarkDotNet packages for in-process hooks.
eng/​pipelines/​perf/​sqlclient-perf-pr-pipeline.yml Adds workload selection and current-only baseline suppression.
eng/​pipelines/​perf/​sqlclient-perf-pipeline.yml Passes workload configuration to platform runners.
eng/​pipelines/​perf/​sqlclient-perf-experiment.yml Adds workload selection to switch experiments.
eng/​pipelines/​perf/​scripts/​tests/​test_runner_config.py Tests alternate workload configuration selection.
eng/​pipelines/​perf/​scripts/​tests/​test_async_health.py Tests reporting, collection, isolation, and process lifecycle behavior.
eng/​pipelines/​perf/​scripts/​show_perf_results.sh Includes async-health Markdown in displayed reports.
eng/​pipelines/​perf/​scripts/​run-perf-tests.sh Adds workload selection and no-baseline orchestration branches.
eng/​pipelines/​perf/​scripts/​run-perf-tests.ps1 Adds equivalent PowerShell runner support.
eng/​pipelines/​perf/​scripts/​interleave_perf.py Collects sidecars and adds current-only execution and optional watchdogs.
eng/​pipelines/​perf/​scripts/​async_health_report.py Validates artifacts and computes health summaries and comparisons.
eng/​pipelines/​perf/​README.md Documents lifecycle boundaries, coverage rules, calibration, and usage.

Review effort: Balanced

Comment on lines +237 to +239
if (signal == BenchmarkSignal.BeforeExtraIteration)
{
_owner.StartWindow();
Comment on lines +875 to +877
} else {
$baselineExeDir = ""
$currentExeDir = Build-Variant "current" $PerfProject @()
Comment on lines +841 to +844
else
build_variant "current" "${PERF_PROJECT}"
baselineExeDir=""
currentExeDir="${REPO_ROOT}/perf-build-current"
mdaigle and others added 5 commits November 5, 2026 17:16
Generate separate JSON, CSV, and Markdown diagnostic summaries before artifact collection. Include all probe clocks and sampled resource counters without altering normal timing reports.

Co-authored-by: Copilot App <[email protected]>
Add the pipeline-injected connection property when absent, matching the Linux runner. Exercise the checked-in minimal calibration config in both shell harnesses.

Co-authored-by: Copilot App <[email protected]>
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.12%. Comparing base (827c136) to head (658ff75).
⚠️ Report is 27 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (827c136) and HEAD (658ff75). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (827c136) HEAD (658ff75)
CI-SqlClient 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5014      +/-   ##
==========================================
- Coverage   73.37%   67.12%   -6.25%     
==========================================
  Files         311      307       -4     
  Lines       45304    68934   +23630     
==========================================
+ Hits        33240    46271   +13031     
- Misses      12064    22663   +10599     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 67.12% <ø> (?)

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.

mdaigle and others added 6 commits November 5, 2026 18:19
Use 32 operations with a 1500 ms wait per operation for every calibration case. Preserve scheduling differences, report workload parameters and assert completed work at iteration boundaries.

Co-authored-by: Copilot App <[email protected]>
Tag single, concurrent, and contended asynchronous connection workloads. Run three observations per async case while preserving short-window coverage and timing-only synchronous controls.

Co-authored-by: Copilot App <[email protected]>
Add a live TUI for pooled and non-pooled OpenAsync workloads, shared netem controls, and runtime-selectable V2 LongRunning dispatch. Wire Linux latency injection and provenance into performance pipelines with regression coverage.

Co-authored-by: Copilot App <[email protected]>
Archive the authenticated RTT study, compact results, and graphs alongside the playground. Add fresh-process path coverage, outcome accounting, comparison gates, and report tooling for later pipeline integration.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 21:12

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

Both entry points have unreachable current-only orchestration branches, bypassing per-unit isolation and summaries, and benchmark failures can skip artifact collection and diagnostic reporting.

4 open issues
1 resolved since last review

Review effort: Balanced

run_pass "current" "${PERF_PROJECT}"
fi

python3 "${SCRIPT_DIR}/async_health_report.py" --results-dir "${RESULTS_DIR}"

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.

2 participants