Skip to content

PERF: Add pooled lifecycle scenarios to PR reports - #821

Draft
Gaurav Sharma (bewithgaurav) wants to merge 1 commit into
mainfrom
bewithgaurav/pooling-perf-scenarios
Draft

Gaurav Sharma (bewithgaurav) wants to merge 1 commit into
mainfrom
bewithgaurav/pooling-perf-scenarios

Conversation

@bewithgaurav

Copy link
Copy Markdown
Collaborator

Work Item / Issue Reference

GitHub Issue: #754


Summary

Adds two prewarmed pooled connection lifecycle scenarios to the PR Performance Report:

  • 1,000 sequential checkout/check-in cycles
  • 1,000 checkout/check-in cycles across ten ready workers

Both measure Connection.close() and exclude physical-connection and thread startup from the timed window. This catches fixed lifecycle costs that the existing single-connect scenario misses and aggregates sub-millisecond per-connection changes above the report's 1 ms absolute floor.

The scenarios add approximately 16 seconds per SQL leg across the report's warmup and five measured base/candidate pairs. SQL Server 2022 and 2025 legs run in parallel.

Validation on a local macOS profiling build against SQL Server 2022:

  • 177 tests passed, 10 skipped
  • Sequential workload: 1,115.9 ms for 1,000 cycles
  • Parallel workload: 230.2 ms for 1,000 cycles

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 25, 2026 18:23
@github-actions github-actions Bot added the pr-size: medium Moderate update size label Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

PR Performance Report

✅ No regression detected

No consistent slowdowns detected across all 2 environments.

0 IMPROVEMENTS 0 SLOWDOWNS 2/2 ENVIRONMENTS

Coverage: 2 of 2 environments completed. Advisory result; does not block merging.

Performance diagnostics

Phase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed.

No affected phases or call-count changes were recorded.

All database tasks and timings

Unix / SQL Server 2022

Database task Before After Paired change Result
Connection opening 11.007 ms 10.910 ms -0.4% no signal
SELECT queries 1.135 ms 1.072 ms -5.9% no signal
Row insertion 31.824 ms 32.206 ms +0.6% no signal
Executemany inserts 136.809 ms 135.272 ms -2.0% no signal
Fetch-all queries 119.235 ms 119.126 ms -1.0% no signal
Row-by-row fetching 12.534 ms 12.915 ms +1.9% no signal
Batched row fetching 110.925 ms 111.055 ms -0.0% no signal
Transaction commit and rollback 100.616 ms 100.151 ms -0.4% no signal
Arrow row fetching 89.438 ms 90.954 ms +2.4% no signal
100,000-row insertion 418.179 ms 400.911 ms -5.3% no signal
Row fetching in batches of 100 108.714 ms 109.968 ms +2.4% no signal
Row fetching in batches of 10,000 134.114 ms 137.267 ms +4.1% no signal
Repeated positional queries 31.230 ms 30.463 ms +0.8% no signal
Repeated named-parameter queries 32.769 ms 32.941 ms +0.7% no signal
Legacy 100,000-row insertion 321.931 ms 308.012 ms -5.2% no signal
Insertion with explicit input sizes 427.213 ms 431.482 ms +1.0% no signal
Joined aggregation queries 187.480 ms 187.880 ms +0.2% no signal
Large joined-result fetching 175.346 ms 175.363 ms -0.0% no signal
1.2-million-row fetching 3518.098 ms 3513.249 ms +1.0% no signal
Common table expression queries 5.722 ms 5.595 ms -2.2% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.318 ms 1.295 ms -0.2% no signal
Pooled connection checkout and return 633.679 ms 632.244 ms -0.1% no signal
Concurrent pooled checkout and return 418.005 ms 421.314 ms +0.1% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 96.081 ms 96.602 ms +0.7% no signal
SELECT queries 1.097 ms 1.078 ms -1.8% no signal
Row insertion 31.745 ms 31.957 ms +0.6% no signal
Executemany inserts 131.262 ms 131.030 ms -1.0% no signal
Fetch-all queries 120.072 ms 118.753 ms -1.9% no signal
Row-by-row fetching 12.573 ms 12.550 ms +0.3% no signal
Batched row fetching 109.678 ms 108.987 ms -1.2% no signal
Transaction commit and rollback 102.351 ms 103.172 ms +0.8% no signal
Arrow row fetching 88.281 ms 88.907 ms -1.8% no signal
100,000-row insertion 410.256 ms 401.060 ms -2.3% no signal
Row fetching in batches of 100 107.283 ms 107.488 ms -1.7% no signal
Row fetching in batches of 10,000 140.139 ms 125.846 ms -10.7% no signal
Repeated positional queries 30.261 ms 30.302 ms +0.1% no signal
Repeated named-parameter queries 32.694 ms 32.553 ms -0.6% no signal
Legacy 100,000-row insertion 309.132 ms 313.325 ms +2.6% no signal
Insertion with explicit input sizes 451.621 ms 443.823 ms -2.7% no signal
Joined aggregation queries 164.465 ms 165.538 ms +0.1% no signal
Large joined-result fetching 181.631 ms 183.298 ms +1.0% no signal
1.2-million-row fetching 3503.076 ms 3465.834 ms -0.3% no signal
Common table expression queries 5.305 ms 5.353 ms +0.0% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.382 ms 1.386 ms +1.5% no signal
Pooled connection checkout and return 629.117 ms 635.813 ms +0.0% no signal
Concurrent pooled checkout and return 419.785 ms 429.126 ms +1.3% no signal
Build and measurement details

ADO build 178247

PR head: 71514430487e23a91fad2e55310784894452540b
Base: d849a09119c831d945521d5333cfb9bdb6e0561d
Measured merge: 53d72ba213b269d13e7ed7a8ca80554d81f9e16d

  • Unix / SQL Server 2022: Python 3.12.3, x86_64, SQL 16.0.4295.3; 5 paired comparisons and 1 warmup.
  • Unix / SQL Server 2025: Python 3.12.3, x86_64, SQL 17.0.5005.3; 5 paired comparisons and 1 warmup.

A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent.

The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes.

Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency.

Raw samples and logs are attached to the ADO run as profiler-* artifacts.

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.

Copilot review overview

🟡 Changes recommended

Three moderate review findings remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds sequential and concurrent prewarmed pooled connection lifecycle benchmarks to PR performance reports.

Changes:

  • Adds pooled checkout/check-in workloads.
  • Registers and reports both scenarios.
  • Adds orchestration tests and documentation.
File Reviewed changes
tests/​test_036_profiler_ci.py Tests workload registration and execution contracts; per-worker call distribution needs stronger validation.
profiler/​core.py Routes pooled scenarios through connection-string execution.
eng/​profiler_benchmarks/​workloads.py Implements sequential and concurrent lifecycle benchmarks; timing instrumentation and repeated imports require correction.
eng/​profiler_benchmarks/​report.py Adds scenario names and report labels.
eng/​profiler_benchmarks/​README.md Documents the expanded benchmark suite.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +168 to +171
def _connect_close(connection_string):
from mssql_python import connect

connect(connection_string).close()
@github-actions

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

84%


📈 Total Lines Covered: 9400 out of 11083
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 62.6%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 79.3%
mssql_python.pybind.connection.connection_pool.cpp: 82.3%
mssql_python.pybind.connection.connection.cpp: 83.1%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.fetch_temporal.hpp: 92.1%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

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

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants