Skip to content

Trim PyMongo 4.18 wheel size for the Agent - #25548

Merged
lu-zhengda merged 3 commits into
zhengda.lu/mongodb-9-supportfrom
eric.weaver/pymongo-size-trim
Oct 7, 2026
Merged

lu-zhengda merged 3 commits into
zhengda.lu/mongodb-9-supportfrom
eric.weaver/pymongo-size-trim

Conversation

@eric-weaver

Copy link
Copy Markdown
Contributor

What does this PR do?

Reduces the installed size of PyMongo 4.18.2 in the Agent from 3.47 MiB to about 1.9 MiB on linux x86_64, slightly below the 1.77 MiB of PyMongo 4.8.0 plus the new SRV public suffix list. This PR targets #25517.

  • Builds PyMongo from source on the Linux builders. PyPI's manylinux wheels ship _cmessage and _cbson with DWARF debug info (about 0.7 MiB on x86_64 and 1 MiB on aarch64); building with our LDFLAGS=-Wl,--strip-debug removes it. This is how 4.8.0 was already built, since it had no cp313 wheel on PyPI.
  • Removes pymongo/asynchronous/ and gridfs/ from the packaged wheel (about 0.9 MiB on every platform), along with the three lines that import pymongo.asynchronous eagerly. No integration uses AsyncMongoClient or GridFS, and the sync client does not depend on either package.

Motivation

The PyMongo upgrade in #25517 increases the Agent's on-disk size enough to fail the static quality gates. Most of the increase comes from upstream shipping both a sync and an async copy of the client since 4.9, and from unstripped extensions in the PyPI wheels.

Validated by running the builder's clean_wheel on the 4.18.2 wheel and by exercising the trimmed, stripped install against MongoDB 8.0 on linux/amd64: connect, insert, count, index creation, explain, $currentOp, $indexStats, collStats, and listDatabases, with the C extensions loaded and the mongodb+srv resolver importable. Dependency resolution needs to rerun on this branch to rebuild the wheels and update the lockfiles.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

eric-weaver and others added 2 commits October 7, 2026 13:24
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@eric-weaver eric-weaver added the qa/skip-qa Automatically skip this PR for the next QA label Oct 7, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

evalya-impact-summary

evalya impact analysis
Impact analysis: 0 selected, 0 skipped (of 0 test tasks)
Publish tasks:   2 (always emitted)
Diff (33 files):
  .builders/deps/build_dependencies.txt
  .builders/images/linux-aarch64/build_script.sh
  .builders/images/linux-x86_64/build_script.sh
  .builders/scripts/files_to_remove.toml
  .builders/scripts/lines_to_remove.toml
  .deps/builder_inputs.toml
  .deps/image_digests.json
  .deps/resolved/linux-aarch64_3.13.txt
  .deps/resolved/linux-x86_64_3.13.txt
  .deps/resolved/macos-aarch64_3.13.txt
  .deps/resolved/macos-x86_64_3.13.txt
  .deps/resolved/windows-x86_64_3.13.txt
  .github/workflows/test-all.yml
  agent_requirements.in
  kafka_actions/changelog.d/25517.added
  kafka_actions/pyproject.toml
  mongo/changelog.d/25517.added
  mongo/changelog.d/25517.changed
  mongo/datadog_checks/mongo/dbm/query_metrics.py
  mongo/datadog_checks/mongo/dbm/schemas.py
  ... and 13 more

Debug a specific task: evalya plan impact --path <path> --task <task>

Learn more about CI impact filtering

Co-authored-by: Cursor <cursoragent@cursor.com>
@lu-zhengda
lu-zhengda marked this pull request as ready for review October 7, 2026 19:53
@lu-zhengda
lu-zhengda requested review from a team as code owners October 7, 2026 19:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T19:57:36.145923Z b1da46a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1da46a230

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +15 to +16
"/pymongo/asynchronous/",
"/gridfs/",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve PyMongo's public async and GridFS modules

When a third-party or custom Agent check uses gridfs or pymongo.AsyncMongoClient, these exclusions turn the shipped pymongo==4.18.2 wheel into an incomplete distribution and make those documented imports fail. Declaring PyMongo as a dependency does not reliably repair this because package installers see the same version as already installed; the repo-wide absence of built-in call sites cannot establish that external checks do not use these public APIs. Avoid deleting these modules from the shared wheel.

Useful? React with 👍 / 👎.

@dd-octo-sts

dd-octo-sts Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file ✅
ci Validate CI configuration and code coverage settings ✅
codeowners Validate every integration has a CODEOWNERS entry ✅
config Validate default configuration files against spec.yaml ✅
dep Verify dependency pins are consistent and Agent-compatible ✅
http Validate integrations use the HTTP wrapper correctly ✅
imports Validate check imports do not use deprecated modules ✅
integration-style Validate check code style conventions ✅
jmx-metrics Validate JMX metrics definition files and config ✅
labeler Validate PR labeler config matches integration directories ✅
legacy-signature Validate no integration uses the legacy Agent check signature ✅
license-headers Validate Python files have proper license headers ✅
licenses Validate third-party license attribution list ✅
metadata Validate metadata.csv metric definitions ✅
models Validate configuration data models match spec.yaml ✅
openmetrics Validate OpenMetrics integrations disable the metric limit ✅
package Validate Python package metadata and naming ✅
qa-label Validate the pull request declares whether it needs QA for the next Agent release ✅
readmes Validate README files have required sections ✅
saved-views Validate saved view JSON file structure and fields ✅
version Validate version consistency between package and changelog ✅

View full run

@lu-zhengda
lu-zhengda merged commit 781c213 into zhengda.lu/mongodb-9-support Oct 7, 2026
50 of 54 checks passed
@lu-zhengda
lu-zhengda deleted the eric.weaver/pymongo-size-trim branch October 7, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants