Skip to content

perf(mongodb): cache the per-connection topology shape#8370

Merged
BridgeAR merged 1 commit into
masterfrom
BridgeAR/2026-05-08-perf-mongo-topology
May 9, 2026
Merged

perf(mongodb): cache the per-connection topology shape#8370
BridgeAR merged 1 commit into
masterfrom
BridgeAR/2026-05-08-perf-mongo-topology

Conversation

@BridgeAR
Copy link
Copy Markdown
Member

@BridgeAR BridgeAR commented May 8, 2026

wrapConnectionCommand (mongodb >= 4) rebuilt the same five objects from this.address on every command. The Connection's address is immutable for its lifetime, so the work lands once on the first command and reuses a per-Connection envelope thereafter.

The cache lives in a module-scope WeakMap instead of a Symbol-keyed property: the Connection is a foreign object, and an own-key (even a Symbol) shows up to Reflect.ownKeys / Object.getOwnPropertySymbols, forces a hidden-class transition on first hit, and can collide with another tracer's instrumentation walking the same connection. The extra WeakMap.get is single-digit nanoseconds and the foreign object stays untouched.

The address parser tightens the previous length === 2 split to "exactly one :, non-empty parts on both sides" so non-standard addresses (random UUIDs, IPv6 forms, empty port / host halves) all collapse to the empty-options topology. synthesizeTopology is exported so the parser is unit-tested directly rather than through the mongodb integration suite.

Bench (Node 24.15 / V8 13.6, n=500 k x 7 trials, drop best+worst, warm cache, hit-only):
per-command rebuild 19.30 ns/op
cached envelope (WeakMap) 8.32 ns/op speedup: 2.32x

`wrapConnectionCommand` (mongodb >= 4) rebuilt the same five objects
from `this.address` on every command. The Connection's address is
immutable for its lifetime, so the work lands once on the first
command and reuses a per-Connection envelope thereafter.

The cache lives in a module-scope `WeakMap` instead of a Symbol-keyed
property: the Connection is a foreign object, and an own-key (even a
Symbol) shows up to `Reflect.ownKeys` / `Object.getOwnPropertySymbols`,
forces a hidden-class transition on first hit, and can collide with
another tracer's instrumentation walking the same connection. The
extra `WeakMap.get` is single-digit nanoseconds and the foreign object
stays untouched.

The address parser tightens the previous `length === 2` split to
"exactly one `:`, non-empty parts on both sides" so non-standard
addresses (random UUIDs, IPv6 forms, empty port / host halves) all
collapse to the empty-options topology. `synthesizeTopology` is
exported so the parser is unit-tested directly rather than through the
mongodb integration suite.

Bench (Node 24.15 / V8 13.6, n=500 k x 7 trials, drop best+worst,
warm cache, hit-only):
  per-command rebuild              19.30 ns/op
  cached envelope (WeakMap)         8.32 ns/op   speedup: 2.32x
@BridgeAR BridgeAR requested a review from a team as a code owner May 8, 2026 18:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Overall package size

Self size: 5.81 MB
Deduped: 6.65 MB
No deduping: 6.65 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.79%. Comparing base (5802bcb) to head (ab6cee6).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...kages/datadog-instrumentations/src/mongodb-core.js 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8370      +/-   ##
==========================================
+ Coverage   89.45%   89.79%   +0.34%     
==========================================
  Files         836      836              
  Lines       44930    44937       +7     
  Branches     8327     8327              
==========================================
+ Hits        40191    40353     +162     
+ Misses       4739     4584     -155     
Flag Coverage Δ
aiguard-integration-active 40.53% <ø> (ø)
aiguard-integration-latest 40.48% <ø> (ø)
aiguard-integration-maintenance 40.53% <ø> (ø)
aiguard-macos 35.23% <ø> (-0.09%) ⬇️
aiguard-ubuntu 35.33% <ø> (-0.09%) ⬇️
aiguard-windows 35.14% <ø> (-0.09%) ⬇️
apm-capabilities-tracing-macos 48.98% <ø> (+0.04%) ⬆️
apm-capabilities-tracing-ubuntu-active 49.01% <ø> (-0.19%) ⬇️
apm-capabilities-tracing-ubuntu-latest 48.98% <ø> (ø)
apm-capabilities-tracing-ubuntu-maintenance 49.19% <ø> (+0.18%) ⬆️
apm-capabilities-tracing-ubuntu-oldest 49.00% <ø> (ø)
apm-capabilities-tracing-windows 48.75% <ø> (-0.24%) ⬇️
apm-integrations-aerospike-18-gte.5.2.0 34.22% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-20-gte.5.5.0 34.23% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.5.12.1 34.23% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-22-gte.6.0.0 34.23% <ø> (-0.09%) ⬇️
apm-integrations-aerospike-eol- 34.14% <ø> (-0.09%) ⬇️
apm-integrations-child-process 35.25% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-18 41.09% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-20 41.11% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-22 41.11% <ø> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript-24 41.04% <ø> (-0.09%) ⬇️
apm-integrations-couchbase-18 34.41% <ø> (-0.17%) ⬇️
apm-integrations-couchbase-eol 34.51% <ø> (ø)
apm-integrations-dns 34.13% <ø> (-0.09%) ⬇️
apm-integrations-elasticsearch 34.88% <ø> (-0.08%) ⬇️
apm-integrations-http-latest 42.08% <ø> (-0.08%) ⬇️
apm-integrations-http-maintenance 42.14% <ø> (-0.08%) ⬇️
apm-integrations-http-oldest 42.14% <ø> (-0.08%) ⬇️
apm-integrations-http2 39.45% <ø> (-0.20%) ⬇️
apm-integrations-kafkajs-latest 41.00% <ø> (-0.07%) ⬇️
apm-integrations-kafkajs-oldest 41.03% <ø> (-0.09%) ⬇️
apm-integrations-net 34.82% <ø> (-0.09%) ⬇️
apm-integrations-next-11.1.4 29.03% <ø> (-0.08%) ⬇️
apm-integrations-next-13.2.0 30.72% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.10.2.0.and.lt.11 22.99% <ø> (ø)
apm-integrations-next-gte.11.0.0.and.lt.13 30.73% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.13.0.0.and.lt.14 30.97% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.14.0.0.and.lte.14.2.6 30.79% <ø> (-0.08%) ⬇️
apm-integrations-next-gte.14.2.7.and.lt.15 30.81% <ø> (-0.06%) ⬇️
apm-integrations-next-gte.15.0.0 30.86% <ø> (-0.08%) ⬇️
apm-integrations-oracledb 34.52% <ø> (-0.09%) ⬇️
apm-integrations-prisma-18-gte.6.16.0.and.lt.7.0.0 34.86% <23.07%> (-0.08%) ⬇️
apm-integrations-prisma-latest-all 35.18% <23.07%> (-0.08%) ⬇️
apm-integrations-restify 36.32% <ø> (-0.09%) ⬇️
apm-integrations-sharedb 33.81% <ø> (-0.09%) ⬇️
apm-integrations-tedious 34.32% <ø> (-0.09%) ⬇️
appsec-express 51.91% <ø> (-0.09%) ⬇️
appsec-fastify 48.59% <ø> (-0.07%) ⬇️
appsec-graphql 48.90% <ø> (-0.07%) ⬇️
appsec-integration-active 36.81% <14.28%> (-0.01%) ⬇️
appsec-integration-latest 36.78% <14.28%> (-0.01%) ⬇️
appsec-integration-maintenance 36.80% <14.28%> (-0.01%) ⬇️
appsec-integration-oldest 36.80% <14.28%> (-0.01%) ⬇️
appsec-kafka 41.39% <ø> (-0.07%) ⬇️
appsec-ldapjs 40.65% <ø> (-0.07%) ⬇️
appsec-lodash 40.76% <ø> (-0.07%) ⬇️
appsec-macos 55.75% <ø> (-0.06%) ⬇️
appsec-mongodb-core 45.02% <23.07%> (-0.08%) ⬇️
appsec-mongoose 45.87% <23.07%> (-0.08%) ⬇️
appsec-mysql 47.92% <ø> (-0.07%) ⬇️
appsec-next-latest-11.1.4 29.15% <ø> (-0.08%) ⬇️
appsec-next-latest-13.2.0 30.86% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.10.2.0.and.lt.11 28.66% <ø> (ø)
appsec-next-latest-gte.11.0.0.and.lt.13 30.84% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.13.0.0.and.lt.14 31.09% <ø> (-0.08%) ⬇️
appsec-next-latest-gte.14.0.0.and.lte.14.2.6 30.93% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.14.2.7.and.lt.15 30.93% <ø> (-0.09%) ⬇️
appsec-next-latest-gte.15.0.0 30.93% <ø> (-0.09%) ⬇️
appsec-next-oldest-11.1.4 29.16% <ø> (-0.08%) ⬇️
appsec-next-oldest-13.2.0 31.14% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.10.2.0.and.lt.11 28.78% <ø> (ø)
appsec-next-oldest-gte.11.0.0.and.lt.13 30.86% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.13.0.0.and.lt.14 31.33% <ø> (-0.08%) ⬇️
appsec-next-oldest-gte.14.0.0.and.lte.14.2.6 31.17% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.14.2.7.and.lt.15 31.17% <ø> (-0.09%) ⬇️
appsec-next-oldest-gte.15.0.0 31.17% <ø> (-0.09%) ⬇️
appsec-node-serialize 39.97% <ø> (-0.07%) ⬇️
appsec-passport 43.63% <ø> (-0.08%) ⬇️
appsec-postgres 47.51% <ø> (-0.09%) ⬇️
appsec-sourcing 39.31% <ø> (-0.07%) ⬇️
appsec-stripe 41.41% <ø> (-0.08%) ⬇️
appsec-template 40.13% <ø> (-0.07%) ⬇️
appsec-ubuntu 55.83% <ø> (-0.07%) ⬇️
appsec-windows 55.69% <ø> (-0.06%) ⬇️
debugger-ubuntu-active 43.17% <ø> (ø)
debugger-ubuntu-latest 43.12% <ø> (ø)
debugger-ubuntu-maintenance 43.18% <ø> (ø)
debugger-ubuntu-oldest 43.62% <ø> (ø)
instrumentations-instrumentation-bluebird 29.25% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-body-parser 36.86% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-child_process 34.74% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-cookie-parser 31.09% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express 31.31% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.21% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-express-session 36.55% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-fs 28.94% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-generic-pool 29.86% <ø> (ø)
instrumentations-instrumentation-http 36.22% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-knex 29.22% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-light-my-request 36.48% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mongoose 30.25% <23.07%> (-0.08%) ⬇️
instrumentations-instrumentation-multer 36.65% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-mysql2 34.72% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport 40.27% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-http 40.05% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-passport-local 40.53% <ø> (-0.08%) ⬇️
instrumentations-instrumentation-pg 34.27% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise 29.19% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-promise-js 29.19% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-q 29.22% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-url 29.19% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-when 29.21% <ø> (-0.09%) ⬇️
instrumentations-integration-esbuild-active 19.24% <14.28%> (+<0.01%) ⬆️
instrumentations-integration-esbuild-latest 19.22% <14.28%> (+<0.01%) ⬆️
instrumentations-integration-esbuild-maintenance 19.24% <14.28%> (+<0.01%) ⬆️
instrumentations-integration-esbuild-oldest 19.23% <14.28%> (+<0.01%) ⬆️
llmobs-ai 37.69% <ø> (-0.08%) ⬇️
llmobs-anthropic 37.75% <ø> (-0.08%) ⬇️
llmobs-bedrock 36.44% <ø> (?)
llmobs-google-genai 36.77% <ø> (-0.08%) ⬇️
llmobs-langchain 36.49% <ø> (-0.07%) ⬇️
llmobs-openai 40.52% <ø> (-0.08%) ⬇️
llmobs-sdk-active 45.33% <ø> (-0.09%) ⬇️
llmobs-sdk-latest 45.26% <ø> (-0.09%) ⬇️
llmobs-sdk-maintenance 45.33% <ø> (-0.09%) ⬇️
llmobs-sdk-oldest 45.31% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 36.92% <ø> (-0.08%) ⬇️
openfeature-macos 37.91% <ø> (+<0.01%) ⬆️
openfeature-ubuntu 37.98% <ø> (ø)
openfeature-unit-active 48.51% <ø> (ø)
openfeature-unit-latest 48.35% <ø> (ø)
openfeature-unit-maintenance 48.51% <ø> (ø)
openfeature-unit-oldest 48.51% <ø> (ø)
openfeature-windows 37.78% <ø> (+0.05%) ⬆️
platform-core 37.27% <ø> (ø)
platform-esbuild 40.61% <ø> (ø)
platform-instrumentations-misc 30.69% <ø> (ø)
platform-integration-active 46.92% <ø> (-0.01%) ⬇️
platform-integration-latest 46.88% <ø> (-0.01%) ⬇️
platform-integration-maintenance 46.93% <ø> (+<0.01%) ⬆️
platform-integration-oldest 47.09% <ø> (ø)
platform-shimmer 42.29% <ø> (ø)
platform-unit-guardrails 36.12% <ø> (ø)
platform-webpack 20.36% <15.38%> (+<0.01%) ⬆️
plugins-azure-durable-functions 36.91% <ø> (+0.16%) ⬆️
plugins-azure-event-hubs 34.75% <ø> (ø)
plugins-azure-service-bus 35.22% <ø> (ø)
plugins-bullmq 40.12% <ø> (-0.10%) ⬇️
plugins-cassandra 34.66% <ø> (-0.08%) ⬇️
plugins-cookie 26.65% <ø> (ø)
plugins-cookie-parser 26.46% <ø> (ø)
plugins-crypto 27.69% <ø> (ø)
plugins-dd-trace-api 34.67% <ø> (-0.09%) ⬇️
plugins-express-mongo-sanitize 26.59% <ø> (ø)
plugins-express-session 26.42% <ø> (ø)
plugins-fastify 38.63% <ø> (-0.08%) ⬇️
plugins-fetch 34.96% <ø> (-0.08%) ⬇️
plugins-fs 35.00% <ø> (-0.11%) ⬇️
plugins-generic-pool 25.58% <ø> (ø)
plugins-google-cloud-pubsub 42.36% <ø> (-0.06%) ⬇️
plugins-grpc 37.40% <ø> (-0.08%) ⬇️
plugins-handlebars 26.63% <ø> (ø)
plugins-hapi 36.52% <ø> (-0.09%) ⬇️
plugins-hono 36.81% <ø> (-0.08%) ⬇️
plugins-ioredis 35.10% <ø> (-0.09%) ⬇️
plugins-knex 26.31% <ø> (ø)
plugins-langgraph 34.38% <ø> (-0.09%) ⬇️
plugins-ldapjs 24.20% <ø> (ø)
plugins-light-my-request 26.06% <ø> (ø)
plugins-limitd-client 29.49% <ø> (-0.15%) ⬇️
plugins-lodash 25.65% <ø> (ø)
plugins-mariadb 36.01% <ø> (-0.03%) ⬇️
plugins-memcached 34.76% <ø> (-0.09%) ⬇️
plugins-microgateway-core 35.65% <ø> (-0.09%) ⬇️
plugins-modelcontextprotocol-sdk 33.66% <ø> (-0.09%) ⬇️
plugins-moleculer 37.48% <ø> (-0.09%) ⬇️
plugins-mongodb 35.95% <100.00%> (-0.04%) ⬇️
plugins-mongodb-core 35.55% <53.84%> (-0.05%) ⬇️
plugins-mongoose 35.44% <92.30%> (-0.05%) ⬇️
plugins-multer 26.42% <ø> (ø)
plugins-mysql 35.48% <ø> (-0.09%) ⬇️
plugins-mysql2 35.77% <ø> (-0.09%) ⬇️
plugins-node-serialize 26.69% <ø> (ø)
plugins-opensearch 34.41% <ø> (-0.09%) ⬇️
plugins-passport-http 26.47% <ø> (ø)
plugins-pino 31.19% <ø> (-0.09%) ⬇️
plugins-postgres 33.71% <ø> (-0.11%) ⬇️
plugins-process 27.69% <ø> (ø)
plugins-pug 26.65% <ø> (ø)
plugins-redis 35.16% <ø> (-0.03%) ⬇️
plugins-router 39.10% <ø> (+0.04%) ⬆️
plugins-sequelize 25.36% <ø> (ø)
plugins-test-and-upstream-amqp10 35.00% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-amqplib 40.23% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-apollo 35.87% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-avsc 34.34% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-bunyan 30.57% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-connect 37.19% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-graphql 36.78% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-koa 36.78% <ø> (-0.08%) ⬇️
plugins-test-and-upstream-protobufjs 34.55% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-rhea 40.24% <ø> (-0.09%) ⬇️
plugins-undici 35.69% <ø> (-0.08%) ⬇️
plugins-url 27.69% <ø> (ø)
plugins-valkey 34.77% <ø> (-0.09%) ⬇️
plugins-vm 27.69% <ø> (ø)
plugins-winston 31.08% <ø> (-0.22%) ⬇️
plugins-ws 38.19% <ø> (-0.22%) ⬇️
profiling-macos 42.67% <ø> (-0.12%) ⬇️
profiling-ubuntu 43.08% <ø> (-0.07%) ⬇️
profiling-windows 39.98% <ø> (-0.07%) ⬇️
serverless-aws-sdk-latest-aws-sdk 34.65% <ø> (-0.16%) ⬇️
serverless-aws-sdk-latest-bedrockruntime 32.99% <ø> (-0.36%) ⬇️
serverless-aws-sdk-latest-client 22.38% <ø> (ø)
serverless-aws-sdk-latest-dynamodb 35.61% <ø> (-0.17%) ⬇️
serverless-aws-sdk-latest-eventbridge 28.77% <ø> (-0.08%) ⬇️
serverless-aws-sdk-latest-kinesis 38.55% <ø> (-0.14%) ⬇️
serverless-aws-sdk-latest-lambda 35.80% <ø> (-0.17%) ⬇️
serverless-aws-sdk-latest-s3 33.76% <ø> (-0.14%) ⬇️
serverless-aws-sdk-latest-serverless-peer-service 39.92% <ø> (-0.16%) ⬇️
serverless-aws-sdk-latest-sns 39.65% <ø> (-0.29%) ⬇️
serverless-aws-sdk-latest-sqs 38.93% <ø> (-0.15%) ⬇️
serverless-aws-sdk-latest-stepfunctions 34.38% <ø> (-0.17%) ⬇️
serverless-aws-sdk-latest-util 47.71% <ø> (ø)
serverless-aws-sdk-oldest-aws-sdk 34.75% <ø> (?)
serverless-aws-sdk-oldest-bedrockruntime 33.27% <ø> (?)
serverless-aws-sdk-oldest-client 22.75% <ø> (ø)
serverless-aws-sdk-oldest-dynamodb 35.68% <ø> (?)
serverless-aws-sdk-oldest-eventbridge 28.81% <ø> (-0.08%) ⬇️
serverless-aws-sdk-oldest-kinesis 38.68% <ø> (?)
serverless-aws-sdk-oldest-lambda 35.88% <ø> (?)
serverless-aws-sdk-oldest-s3 33.82% <ø> (?)
serverless-aws-sdk-oldest-serverless-peer-service 39.98% <ø> (?)
serverless-aws-sdk-oldest-sns 39.73% <ø> (?)
serverless-aws-sdk-oldest-sqs 38.82% <ø> (?)
serverless-aws-sdk-oldest-stepfunctions 34.45% <ø> (?)
serverless-aws-sdk-oldest-util 48.03% <ø> (ø)
serverless-azure-functions-eventhubs 38.40% <ø> (ø)
serverless-azure-functions-servicebus 38.46% <ø> (ø)
serverless-lambda 32.76% <ø> (-0.08%) ⬇️
test-optimization-cucumber-latest-7.0.0 50.44% <ø> (+0.12%) ⬆️
test-optimization-cucumber-latest-latest 53.05% <ø> (+0.12%) ⬆️
test-optimization-cucumber-oldest-7.0.0 50.35% <ø> (+0.12%) ⬆️
test-optimization-cypress-latest-12.0.0-commonJS 48.25% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-12.0.0-esm 48.28% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-14.5.4-commonJS 48.10% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-14.5.4-esm 48.13% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-commonJS 48.60% <ø> (+0.07%) ⬆️
test-optimization-cypress-latest-latest-esm 48.63% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-commonJS 48.29% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-12.0.0-esm 48.32% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-14.5.4-commonJS 48.14% <ø> (+0.07%) ⬆️
test-optimization-cypress-oldest-14.5.4-esm 48.17% <ø> (+0.07%) ⬆️
test-optimization-jest-latest-latest 54.78% <ø> (+0.04%) ⬆️
test-optimization-jest-latest-oldest 53.60% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-latest 54.82% <ø> (+0.08%) ⬆️
test-optimization-jest-oldest-oldest 53.56% <ø> (+0.08%) ⬆️
test-optimization-mocha-latest-latest 53.33% <ø> (+0.05%) ⬆️
test-optimization-mocha-latest-oldest 50.94% <ø> (+0.11%) ⬆️
test-optimization-mocha-oldest-latest 53.39% <ø> (+0.08%) ⬆️
test-optimization-mocha-oldest-oldest 50.88% <ø> (+0.08%) ⬆️
test-optimization-playwright-latest-latest-playwright-active-test-span 44.24% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-latest-playwright-atr 43.00% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-latest-playwright-efd 43.38% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-final-status ?
test-optimization-playwright-latest-latest-playwright-impacted-tests 42.93% <ø> (ø)
test-optimization-playwright-latest-latest-playwright-reporting 42.42% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-latest-playwright-test-management 44.61% <ø> (+0.10%) ⬆️
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.30% <ø> (+0.28%) ⬆️
test-optimization-playwright-latest-oldest-playwright-atr 43.21% <ø> (+0.11%) ⬆️
test-optimization-playwright-latest-oldest-playwright-efd 43.43% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-final-status 43.50% <ø> (+0.08%) ⬆️
test-optimization-playwright-latest-oldest-playwright-impacted-tests 42.98% <ø> (ø)
test-optimization-playwright-latest-oldest-playwright-reporting 42.49% <ø> (+0.09%) ⬆️
test-optimization-playwright-latest-oldest-playwright-test-management 44.68% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-latest-playwright-active-test-span 44.25% <ø> (+0.28%) ⬆️
test-optimization-playwright-oldest-latest-playwright-atr 43.04% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-efd 43.39% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-final-status 43.48% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-latest-playwright-impacted-tests 42.97% <ø> (ø)
test-optimization-playwright-oldest-latest-playwright-reporting 42.44% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-latest-playwright-test-management 44.62% <ø> (+0.10%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.34% <ø> (+0.28%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-atr 43.25% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-efd 43.44% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-final-status 43.54% <ø> (+0.11%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-impacted-tests 43.02% <ø> (ø)
test-optimization-playwright-oldest-oldest-playwright-reporting 42.50% <ø> (+0.09%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-test-management 44.70% <ø> (+0.10%) ⬆️
test-optimization-selenium-latest 45.62% <ø> (+0.07%) ⬆️
test-optimization-selenium-oldest 45.12% <ø> (+0.07%) ⬆️
test-optimization-testopt-active 46.98% <ø> (+0.13%) ⬆️
test-optimization-testopt-latest 46.94% <ø> (+0.13%) ⬆️
test-optimization-testopt-maintenance 46.98% <ø> (+0.13%) ⬆️
test-optimization-testopt-oldest 47.85% <ø> (+0.14%) ⬆️
test-optimization-vitest-latest 50.95% <ø> (+0.11%) ⬆️
test-optimization-vitest-oldest 47.68% <ø> (+0.33%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-prod-us1-3
Copy link
Copy Markdown

datadog-prod-us1-3 Bot commented May 8, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 86.57% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ab6cee6 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented May 8, 2026

Benchmarks

Benchmark execution time: 2026-05-08 19:02:58

Comparing candidate commit ab6cee6 in PR branch BridgeAR/2026-05-08-perf-mongo-topology with baseline commit 5802bcb in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1730 metrics, 114 unstable metrics.

@BridgeAR BridgeAR merged commit c05e122 into master May 9, 2026
902 checks passed
@BridgeAR BridgeAR deleted the BridgeAR/2026-05-08-perf-mongo-topology branch May 9, 2026 00:21
This was referenced May 9, 2026
rochdev pushed a commit that referenced this pull request May 13, 2026
`wrapConnectionCommand` (mongodb >= 4) rebuilt the same five objects
from `this.address` on every command. The Connection's address is
immutable for its lifetime, so the work lands once on the first
command and reuses a per-Connection envelope thereafter.

The cache lives in a module-scope `WeakMap` instead of a Symbol-keyed
property: the Connection is a foreign object, and an own-key (even a
Symbol) shows up to `Reflect.ownKeys` / `Object.getOwnPropertySymbols`,
forces a hidden-class transition on first hit, and can collide with
another tracer's instrumentation walking the same connection. The
extra `WeakMap.get` is single-digit nanoseconds and the foreign object
stays untouched.

The address parser tightens the previous `length === 2` split to
"exactly one `:`, non-empty parts on both sides" so non-standard
addresses (random UUIDs, IPv6 forms, empty port / host halves) all
collapse to the empty-options topology. `synthesizeTopology` is
exported so the parser is unit-tested directly rather than through the
mongodb integration suite.

Bench (Node 24.15 / V8 13.6, n=500 k x 7 trials, drop best+worst,
warm cache, hit-only):
  per-command rebuild              19.30 ns/op
  cached envelope (WeakMap)         8.32 ns/op   speedup: 2.32x
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.

2 participants