Skip to content

PYTHON-5977 APM/logging hot-path optimizations - #2968

Draft
NoahStapp wants to merge 5 commits into
mongodb:mainfrom
NoahStapp:BF-44986
Draft

PYTHON-5977 APM/logging hot-path optimizations#2968
NoahStapp wants to merge 5 commits into
mongodb:mainfrom
NoahStapp:BF-44986

Conversation

@NoahStapp

@NoahStapp NoahStapp commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PYTHON-5977

Changes in this PR

The changes introduced by PYTHON-5903, PYTHON-5846, PYTHON-5745, and PYTHON-5676 caused small but measurable regressions for low-latency, high operation count workloads such as the DSI locust_ping benchmark. Much of this is due to constructing telemetry objects even when APM/logging is disabled and other similar changes that lie on the hot path for such workloads.

This PR attempts to optimize all of those regressions away and return performance to its point before their addition.

Test Plan

Standard test suite, benchmarks.

Results of a simple ping workload benchmark:

Metric PR main main vs PR
Throughput 10,634/s 6,567/s −38.8%
Mean latency 752 µs 1,219 µs +62%
p50 ~170 µs ~800 µs ~4–5× worse
p99 ~5,000 µs ~7,000 µs +40%

Checklist

Checklist for Author

  • [ ] Did you update the changelog (if necessary)?
  • [ ] Is there test coverage?
  • [ ] Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@codecov-commenter

codecov-commenter commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.37398% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pymongo/_telemetry.py 89.47% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants