Skip to content

perf(loader): use synchronous iitm hooks when available#8942

Merged
juan-fernandez merged 7 commits into
masterfrom
juan-fernandez/iitm-sync-loader-hooks
Jun 25, 2026
Merged

perf(loader): use synchronous iitm hooks when available#8942
juan-fernandez merged 7 commits into
masterfrom
juan-fernandez/iitm-sync-loader-hooks

Conversation

@juan-fernandez

@juan-fernandez juan-fernandez commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Uses module.registerHooks() from dd-trace/register.js when the runtime supports the synchronous import-in-the-middle loader path. Unsupported runtimes keep the existing module.register('./loader-hook.mjs') async fallback.

The sync path reuses the same loader include/exclude setup as the async path, preserves the ESM rewriter path for non-require loads, and skips loader-level rewriting for CommonJS require loads so the existing _compile rewriter handles CJS once instead of nesting wrappers.

Motivation

Vitest Test Optimization with isolate: true starts many worker processes, and each process pays loader initialization cost. On supported Node versions, the synchronous iitm loader path reduces that worker startup overhead without adding Vitest-specific loader narrowing.

Benchmark

Benchmarked with Node 24.17.0 and Vitest 4.1.9 (latest) in a local demo project with 200 generated test files and 2 zero-delay tests per file, for 400 total tests. The suite used isolate: true, pool: forks, npm test -- --reporter=dot, and a local HTTP intake to verify Test Optimization payloads. Each row reports the median of 7 measured runs after 1 warmup.

Compared origin/master (ea50dc683) against this PR (8030bd7b8).

dd-trace checkout No-trace median Traced median Median overhead Overhead reduction vs master % overhead reduction vs master
Current master 4.46s 21.75s 17.29s baseline baseline
Current PR 4.60s 14.12s 9.51s 7.78s 45.0%

Local intake validation stayed correct: every traced run reported all 400 test events to the Test Optimization intake.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.42105% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@e0132cc). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
loader-hook.mjs 88.88% 4 Missing ⚠️
...g-instrumentations/src/helpers/rewriter/loader.mjs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #8942   +/-   ##
=========================================
  Coverage          ?   92.39%           
=========================================
  Files             ?      885           
  Lines             ?    50758           
  Branches          ?    10007           
=========================================
  Hits              ?    46899           
  Misses            ?     3859           
  Partials          ?        0           
Flag Coverage Δ
aiguard-integration-active 41.73% <ø> (?)
aiguard-integration-latest 41.61% <ø> (?)
aiguard-integration-maintenance 41.69% <ø> (?)
aiguard-macos 34.56% <ø> (?)
aiguard-ubuntu 34.71% <ø> (?)
apm-capabilities-tracing-macos 48.23% <93.75%> (?)
apm-capabilities-tracing-ubuntu-latest 48.40% <93.75%> (?)
apm-capabilities-tracing-ubuntu-oldest 48.45% <93.75%> (?)
apm-capabilities-tracing-windows 48.22% <93.75%> (?)
apm-integrations-aerospike-18-gte.5.2.0 33.09% <ø> (?)
apm-integrations-aerospike-20-gte.5.5.0 33.11% <ø> (?)
apm-integrations-aerospike-22-gte.5.12.1 33.11% <ø> (?)
apm-integrations-aerospike-22-gte.6.0.0 33.11% <ø> (?)
apm-integrations-aerospike-eol- 33.01% <ø> (?)
apm-integrations-child-process 34.02% <ø> (?)
apm-integrations-confluentinc-kafka-javascript-18 40.03% <ø> (?)
apm-integrations-confluentinc-kafka-javascript-22 40.05% <ø> (?)
apm-integrations-confluentinc-kafka-javascript-24 39.94% <ø> (?)
apm-integrations-couchbase-18 33.38% <ø> (?)
apm-integrations-couchbase-eol 33.15% <ø> (?)
apm-integrations-dns 32.95% <ø> (?)
apm-integrations-elasticsearch 34.14% <ø> (?)
apm-integrations-http-latest 41.96% <ø> (?)
apm-integrations-http-maintenance 42.05% <ø> (?)
apm-integrations-http-oldest 41.98% <ø> (?)
apm-integrations-http2 39.08% <ø> (?)
apm-integrations-kafkajs-latest 40.08% <ø> (?)
apm-integrations-kafkajs-oldest 40.16% <ø> (?)
apm-integrations-next-11.1.4 36.30% <ø> (?)
apm-integrations-next-12.3.7 36.30% <ø> (?)
apm-integrations-next-13.0.0 29.10% <ø> (?)
apm-integrations-next-13.2.0 29.14% <ø> (?)
apm-integrations-next-13.5.11 29.27% <ø> (?)
apm-integrations-next-14.0.0 29.16% <ø> (?)
apm-integrations-next-14.2.35 29.16% <ø> (?)
apm-integrations-next-14.2.6 29.16% <ø> (?)
apm-integrations-next-14.2.7 29.16% <ø> (?)
apm-integrations-next-15.0.0 29.16% <ø> (?)
apm-integrations-next-15.4.0 29.23% <ø> (?)
apm-integrations-next-latest 29.27% <ø> (?)
apm-integrations-oracledb 33.97% <ø> (?)
apm-integrations-prisma-latest-all 34.22% <ø> (?)
apm-integrations-restify 35.62% <ø> (?)
apm-integrations-sharedb 32.55% <ø> (?)
apm-integrations-tedious 33.89% <ø> (?)
appsec-express 51.30% <ø> (?)
appsec-fastify 48.07% <ø> (?)
appsec-graphql 47.75% <ø> (?)
appsec-integration-active 36.10% <ø> (?)
appsec-integration-latest 36.10% <ø> (?)
appsec-integration-maintenance 36.16% <ø> (?)
appsec-integration-oldest 36.16% <ø> (?)
appsec-kafka 40.27% <ø> (?)
appsec-ldapjs 39.80% <ø> (?)
appsec-lodash 39.72% <ø> (?)
appsec-macos 57.16% <ø> (?)
appsec-mongodb-core 43.89% <ø> (?)
appsec-mysql 47.08% <ø> (?)
appsec-next-latest-11.1.4 27.39% <ø> (?)
appsec-next-latest-12.3.7 27.40% <ø> (?)
appsec-next-latest-13.0.0 29.18% <ø> (?)
appsec-next-latest-13.2.0 29.20% <ø> (?)
appsec-next-latest-13.5.11 29.29% <ø> (?)
appsec-next-latest-14.0.0 29.22% <ø> (?)
appsec-next-latest-14.2.6 29.22% <ø> (?)
appsec-next-latest-14.2.7 29.22% <ø> (?)
appsec-next-latest-15.0.0 29.22% <ø> (?)
appsec-next-latest-latest 29.26% <ø> (?)
appsec-next-oldest-11.1.4 27.44% <ø> (?)
appsec-next-oldest-12.3.7 29.24% <ø> (?)
appsec-next-oldest-13.0.0 29.24% <ø> (?)
appsec-next-oldest-13.2.0 29.49% <ø> (?)
appsec-next-oldest-13.5.11 29.59% <ø> (?)
appsec-next-oldest-14.0.0 29.53% <ø> (?)
appsec-next-oldest-14.2.35 29.53% <ø> (?)
appsec-next-oldest-14.2.6 29.53% <ø> (?)
appsec-next-oldest-14.2.7 29.53% <ø> (?)
appsec-next-oldest-15.0.0 29.53% <ø> (?)
appsec-next-oldest-latest 27.60% <ø> (?)
appsec-node-serialize 39.01% <ø> (?)
appsec-passport 42.64% <ø> (?)
appsec-stripe 40.53% <ø> (?)
appsec-template 39.30% <ø> (?)
appsec-ubuntu 57.27% <ø> (?)
appsec-windows 57.10% <ø> (?)
debugger-ubuntu-active 43.35% <2.27%> (?)
debugger-ubuntu-latest 43.35% <2.27%> (?)
debugger-ubuntu-maintenance 43.47% <2.27%> (?)
debugger-ubuntu-oldest 43.77% <2.27%> (?)
instrumentations-instrumentation-ai 45.53% <ø> (?)
instrumentations-instrumentation-aws-sdk 45.11% <ø> (?)
instrumentations-instrumentation-bluebird 27.61% <ø> (?)
instrumentations-instrumentation-body-parser 35.64% <ø> (?)
instrumentations-instrumentation-child_process 33.32% <ø> (?)
instrumentations-instrumentation-connect 48.51% <ø> (?)
instrumentations-instrumentation-cookie-parser 29.51% <ø> (?)
instrumentations-instrumentation-couchbase-18 46.23% <ø> (?)
instrumentations-instrumentation-couchbase-eol 46.23% <ø> (?)
instrumentations-instrumentation-crypto 27.58% <ø> (?)
instrumentations-instrumentation-express 29.71% <ø> (?)
instrumentations-instrumentation-express-mongo-sanitize 29.62% <ø> (?)
instrumentations-instrumentation-express-multi-version 41.80% <ø> (?)
instrumentations-instrumentation-express-session 35.47% <ø> (?)
instrumentations-instrumentation-fastify 48.47% <ø> (?)
instrumentations-instrumentation-fetch 45.21% <ø> (?)
instrumentations-instrumentation-fs 27.29% <ø> (?)
instrumentations-instrumentation-generic-pool 27.49% <ø> (?)
instrumentations-instrumentation-hono 28.82% <ø> (?)
instrumentations-instrumentation-http 37.91% <ø> (?)
instrumentations-instrumentation-http-client-options 37.52% <ø> (?)
instrumentations-instrumentation-kafkajs 49.19% <ø> (?)
instrumentations-instrumentation-knex 27.60% <ø> (?)
instrumentations-instrumentation-koa 46.11% <ø> (?)
instrumentations-instrumentation-light-my-request 35.29% <ø> (?)
instrumentations-instrumentation-mongoose 28.71% <ø> (?)
instrumentations-instrumentation-multer 35.32% <ø> (?)
instrumentations-instrumentation-mysql2 33.43% <ø> (?)
instrumentations-instrumentation-openai-lifecycle 46.21% <ø> (?)
instrumentations-instrumentation-otel-sdk-trace 25.46% <ø> (?)
instrumentations-instrumentation-passport 39.25% <ø> (?)
instrumentations-instrumentation-passport-http 38.95% <ø> (?)
instrumentations-instrumentation-passport-local 39.40% <ø> (?)
instrumentations-instrumentation-pg 33.16% <ø> (?)
instrumentations-instrumentation-promise 27.56% <ø> (?)
instrumentations-instrumentation-promise-js 27.56% <ø> (?)
instrumentations-instrumentation-q 27.59% <ø> (?)
instrumentations-instrumentation-restify 47.75% <ø> (?)
instrumentations-instrumentation-router 43.64% <ø> (?)
instrumentations-instrumentation-stripe 28.10% <ø> (?)
instrumentations-instrumentation-url 27.41% <ø> (?)
instrumentations-instrumentation-when 27.57% <ø> (?)
instrumentations-instrumentation-zlib 27.46% <ø> (?)
instrumentations-integration-esbuild-0.16.12-active 24.69% <ø> (?)
instrumentations-integration-esbuild-0.16.12-latest 24.69% <ø> (?)
instrumentations-integration-esbuild-0.16.12-maintenance 18.73% <ø> (?)
instrumentations-integration-esbuild-0.16.12-oldest 18.72% <ø> (?)
instrumentations-integration-esbuild-latest-latest 24.69% <ø> (?)
instrumentations-integration-esbuild-latest-maintenance 18.73% <ø> (?)
instrumentations-integration-esbuild-latest-oldest 18.72% <ø> (?)
llmobs-ai 35.10% <ø> (?)
llmobs-anthropic 36.52% <ø> (?)
llmobs-bedrock 36.01% <ø> (?)
llmobs-google-genai 35.95% <ø> (?)
llmobs-openai-oldest 39.50% <ø> (?)
llmobs-sdk-active 43.36% <ø> (?)
llmobs-sdk-latest 43.36% <ø> (?)
llmobs-sdk-maintenance 43.47% <ø> (?)
llmobs-vertex-ai 35.63% <ø> (?)
master-coverage 92.39% <93.42%> (?)
openfeature-macos 37.48% <ø> (?)
openfeature-ubuntu 37.62% <ø> (?)
openfeature-unit-active 50.00% <ø> (?)
openfeature-unit-latest 50.00% <ø> (?)
openfeature-unit-maintenance 50.36% <ø> (?)
openfeature-unit-oldest 50.36% <ø> (?)
openfeature-windows 37.36% <ø> (?)
platform-core 46.47% <ø> (?)
platform-esbuild 18.67% <ø> (?)
platform-instrumentations-misc 29.57% <ø> (?)
platform-integration-active 47.24% <75.00%> (?)
platform-integration-latest 47.23% <72.36%> (?)
platform-integration-oldest 47.33% <ø> (?)
platform-shimmer 47.50% <ø> (?)
platform-unit-guardrails 44.42% <ø> (?)
platform-webpack 18.31% <ø> (?)
plugins-aws-durable-execution-sdk-js 32.82% <ø> (?)
plugins-axios 35.46% <ø> (?)
plugins-azure-cosmos 35.79% <ø> (?)
plugins-azure-event-hubs 34.82% <ø> (?)
plugins-azure-service-bus 35.33% <ø> (?)
plugins-body-parser 36.55% <ø> (?)
plugins-bullmq 39.43% <ø> (?)
plugins-cassandra 33.74% <ø> (?)
plugins-cookie 40.72% <ø> (?)
plugins-cookie-parser 40.55% <ø> (?)
plugins-crypto 42.71% <ø> (?)
plugins-dd-trace-api 33.17% <ø> (?)
plugins-express-mongo-sanitize 40.60% <ø> (?)
plugins-express-session 40.46% <ø> (?)
plugins-fastify 37.76% <ø> (?)
plugins-fetch 34.52% <ø> (?)
plugins-fs 33.60% <ø> (?)
plugins-generic-pool 40.02% <ø> (?)
plugins-google-cloud-pubsub 41.32% <ø> (?)
plugins-grpc 36.47% <ø> (?)
plugins-handlebars 40.60% <ø> (?)
plugins-hapi 35.76% <ø> (?)
plugins-hono 35.87% <ø> (?)
plugins-ioredis 34.23% <ø> (?)
plugins-jest 27.03% <ø> (?)
plugins-knex 40.06% <ø> (?)
plugins-langgraph 32.30% <ø> (?)
plugins-ldapjs 39.02% <ø> (?)
plugins-light-my-request 40.16% <ø> (?)
plugins-limitd-client 27.91% <ø> (?)
plugins-lodash 40.21% <ø> (?)
plugins-mariadb 35.07% <ø> (?)
plugins-memcached 33.62% <ø> (?)
plugins-microgateway-core 34.70% <ø> (?)
plugins-modelcontextprotocol-sdk 32.26% <ø> (?)
plugins-mongodb 35.83% <ø> (?)
plugins-mongodb-core 35.36% <ø> (?)
plugins-mongoose 34.51% <ø> (?)
plugins-multer 40.52% <ø> (?)
plugins-mysql 34.55% <ø> (?)
plugins-mysql2 34.89% <ø> (?)
plugins-nats 36.25% <ø> (?)
plugins-node-serialize 40.44% <ø> (?)
plugins-opensearch 33.52% <ø> (?)
plugins-passport-http 40.33% <ø> (?)
plugins-pino 29.82% <ø> (?)
plugins-postgres 34.60% <ø> (?)
plugins-process 42.71% <ø> (?)
plugins-pug 40.72% <ø> (?)
plugins-redis 34.25% <ø> (?)
plugins-router 38.20% <ø> (?)
plugins-sequelize 39.98% <ø> (?)
plugins-test-and-upstream-amqplib 39.09% <ø> (?)
plugins-test-and-upstream-apollo 34.77% <ø> (?)
plugins-test-and-upstream-avsc 33.66% <ø> (?)
plugins-test-and-upstream-bunyan 29.04% <ø> (?)
plugins-test-and-upstream-connect 36.26% <ø> (?)
plugins-test-and-upstream-graphql 35.92% <ø> (?)
plugins-test-and-upstream-koa 35.81% <ø> (?)
plugins-test-and-upstream-protobufjs 33.89% <ø> (?)
plugins-test-and-upstream-rhea 39.03% <ø> (?)
plugins-undici 34.96% <ø> (?)
plugins-url 42.71% <ø> (?)
plugins-valkey 33.72% <ø> (?)
plugins-vm 42.71% <ø> (?)
plugins-winston 29.71% <ø> (?)
plugins-ws 37.01% <ø> (?)
profiling-macos 43.02% <ø> (?)
profiling-ubuntu 43.40% <ø> (?)
profiling-windows 40.86% <ø> (?)
serverless-aws-sdk-latest-aws-sdk 33.06% <ø> (?)
serverless-aws-sdk-latest-bedrockruntime 31.91% <ø> (?)
serverless-aws-sdk-latest-dynamodb 33.93% <ø> (?)
serverless-aws-sdk-latest-eventbridge 27.10% <ø> (?)
serverless-aws-sdk-latest-kinesis 37.09% <ø> (?)
serverless-aws-sdk-latest-lambda 34.33% <ø> (?)
serverless-aws-sdk-latest-s3 32.29% <ø> (?)
serverless-aws-sdk-latest-sqs 37.71% <ø> (?)
serverless-aws-sdk-latest-stepfunctions 32.93% <ø> (?)
serverless-aws-sdk-latest-util 46.87% <ø> (?)
serverless-aws-sdk-oldest-aws-sdk 33.18% <ø> (?)
serverless-aws-sdk-oldest-bedrockruntime 32.00% <ø> (?)
serverless-aws-sdk-oldest-dynamodb 34.02% <ø> (?)
serverless-aws-sdk-oldest-eventbridge 27.18% <ø> (?)
serverless-aws-sdk-oldest-kinesis 37.26% <ø> (?)
serverless-aws-sdk-oldest-lambda 34.43% <ø> (?)
serverless-aws-sdk-oldest-s3 32.42% <ø> (?)
serverless-aws-sdk-oldest-serverless-peer-service 39.34% <ø> (?)
serverless-aws-sdk-oldest-sqs 37.79% <ø> (?)
serverless-aws-sdk-oldest-util 47.64% <ø> (?)
serverless-azure-functions-eventhubs 38.37% <ø> (?)
serverless-azure-functions-servicebus 38.42% <ø> (?)
serverless-lambda 34.32% <ø> (?)
test-optimization-cucumber-latest-7.0.0 49.79% <ø> (?)
test-optimization-cucumber-latest-latest 52.49% <ø> (?)
test-optimization-cucumber-oldest-7.0.0 49.87% <ø> (?)
test-optimization-cypress-latest-12.0.0-commonJS 47.64% <ø> (?)
test-optimization-cypress-latest-12.0.0-esm 48.60% <ø> (?)
test-optimization-cypress-latest-14.5.4-commonJS 48.89% <ø> (?)
test-optimization-cypress-latest-14.5.4-esm 47.27% <ø> (?)
test-optimization-cypress-latest-latest-commonJS 48.62% <ø> (?)
test-optimization-cypress-latest-latest-esm 48.96% <ø> (?)
test-optimization-cypress-oldest-12.0.0-commonJS 49.05% <ø> (?)
test-optimization-cypress-oldest-12.0.0-esm 48.82% <ø> (?)
test-optimization-cypress-oldest-14.5.4-commonJS 48.72% <ø> (?)
test-optimization-cypress-oldest-14.5.4-esm 48.87% <ø> (?)
test-optimization-jest-latest-latest 55.19% <ø> (?)
test-optimization-jest-latest-oldest 49.78% <ø> (?)
test-optimization-jest-oldest-latest 55.24% <ø> (?)
test-optimization-jest-oldest-oldest 54.14% <ø> (?)
test-optimization-mocha-latest-latest 53.45% <ø> (?)
test-optimization-mocha-latest-oldest 51.03% <ø> (?)
test-optimization-mocha-oldest-latest 53.56% <ø> (?)
test-optimization-playwright-latest-latest-playwright-active-test-span 44.10% <ø> (?)
test-optimization-playwright-latest-latest-playwright-atr 42.91% <ø> (?)
test-optimization-playwright-latest-latest-playwright-efd 43.33% <ø> (?)
test-optimization-playwright-latest-latest-playwright-impacted-tests 42.86% <ø> (?)
test-optimization-playwright-latest-latest-playwright-reporting 42.95% <ø> (?)
test-optimization-playwright-latest-latest-playwright-test-management 44.41% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.06% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-atr 42.97% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-efd 43.26% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-final-status 43.30% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-impacted-tests 42.79% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-reporting 42.74% <ø> (?)
test-optimization-playwright-latest-oldest-playwright-test-management 44.58% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-active-test-span 44.32% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-atr 42.98% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-efd 43.38% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-final-status 43.44% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-impacted-tests 42.94% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-reporting 43.00% <ø> (?)
test-optimization-playwright-oldest-latest-playwright-test-management 44.48% <ø> (?)
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.15% <ø> (?)
test-optimization-playwright-oldest-oldest-playwright-efd 43.32% <ø> (?)
test-optimization-playwright-oldest-oldest-playwright-final-status 43.41% <ø> (?)
test-optimization-playwright-oldest-oldest-playwright-impacted-tests 42.87% <ø> (?)
test-optimization-playwright-oldest-oldest-playwright-reporting 42.80% <ø> (?)
test-optimization-playwright-oldest-oldest-playwright-test-management 44.44% <ø> (?)
test-optimization-selenium-latest 45.39% <ø> (?)
test-optimization-selenium-oldest 44.98% <ø> (?)
test-optimization-testopt-active 48.12% <75.00%> (?)
test-optimization-testopt-latest 48.11% <72.36%> (?)
test-optimization-testopt-maintenance 47.99% <46.87%> (?)
test-optimization-testopt-oldest 49.29% <ø> (?)
test-optimization-vitest-latest 49.93% <72.36%> (?)
test-optimization-vitest-oldest 48.05% <46.87%> (?)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dd-octo-sts

dd-octo-sts Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.34 MB
Deduped: 7.41 MB
No deduping: 7.41 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

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

@datadog-official

datadog-official Bot commented Jun 16, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@pr-commenter

pr-commenter Bot commented Jun 16, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-25 16:13:28

Comparing candidate commit 39e7df0 in PR branch juan-fernandez/iitm-sync-loader-hooks with baseline commit e0132cc in branch master.

📊 Benchmarking dashboard

Found 2 performance improvements and 2 performance regressions! Performance is the same for 1948 metrics, 13 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:startup-with-tracer-everything-esm-24

  • 🟥 instructions [+180.0M instructions; +292.2M instructions] or [+3.087%; +5.012%]
  • 🟩 max_rss_usage [-15.449MB; -9.316MB] or [-7.076%; -4.267%]

scenario:startup-with-tracer-everything-esm-26

  • 🟥 instructions [+174.8M instructions; +284.1M instructions] or [+3.162%; +5.138%]
  • 🟩 max_rss_usage [-11.648MB; -6.885MB] or [-5.341%; -3.157%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-113.183ms; +170.459ms] or [-4.368%; +6.579%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-175.830ms; +173.348ms] or [-7.082%; +6.982%]

scenario:appsec-control-20

  • unstable execution_time [-127.194ms; +133.929ms] or [-7.382%; +7.773%]

scenario:appsec-control-24

  • unstable execution_time [-90050.386µs; +89586.319µs] or [-7.513%; +7.475%]

scenario:appsec-control-26

  • unstable execution_time [-99.114ms; +96.747ms] or [-8.355%; +8.155%]

scenario:debugger-line-probe-with-snapshot-default-20

  • unstable max_rss_usage [-8.868MB; +12.847MB] or [-4.907%; +7.110%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-315.512ms; +392.530ms] or [-6.515%; +8.105%]
  • unstable execution_time [-316.780ms; +394.867ms] or [-6.443%; +8.031%]

scenario:plugin-graphql-long-with-depth-and-collapse-off-24

  • unstable cpu_user_time [-255.720ms; +278.708ms] or [-5.557%; +6.056%]
  • unstable execution_time [-269.042ms; +303.553ms] or [-5.495%; +6.200%]
  • unstable max_rss_usage [-29.297MB; +38.835MB] or [-5.226%; +6.928%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-16.777MB; +6.535MB] or [-11.628%; +4.530%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-4026.712KB; +4213.379KB] or [-5.065%; +5.300%]

BridgeAR added a commit that referenced this pull request Jun 17, 2026
The startup variants load the fixture through CommonJS require, which goes
through require-in-the-middle and never registers the iitm ESM loader. That
loader is what the synchronous module.registerHooks work changes from an
off-thread async loader to an in-thread sync one, so the suite reported no
movement for that change: nothing put the loader on a measured path.

with-tracer-everything-esm registers the loader via
--import ../../../register.js and imports the same fixture through ESM, so every
dependency and its transitive graph flow through the loader's resolve/load hooks.
The fixture's index.mjs reads the same dependencies as index.js, so the dependency
list stays single-sourced in package.json.

Refs: #8942
@juan-fernandez
juan-fernandez marked this pull request as ready for review June 17, 2026 15:19
@juan-fernandez
juan-fernandez requested review from a team as code owners June 17, 2026 15:19
@juan-fernandez
juan-fernandez requested review from tlhunter and removed request for a team June 17, 2026 15:19

@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: 36603d5fd3

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread loader-hook.mjs Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 32305737e1

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
dd-octo-sts Bot pushed a commit that referenced this pull request Jun 18, 2026
The startup variants load the fixture through CommonJS require, which goes
through require-in-the-middle and never registers the iitm ESM loader. That
loader is what the synchronous module.registerHooks work changes from an
off-thread async loader to an in-thread sync one, so the suite reported no
movement for that change: nothing put the loader on a measured path.

with-tracer-everything-esm registers the loader via
--import ../../../register.js and imports the same fixture through ESM, so every
dependency and its transitive graph flow through the loader's resolve/load hooks.
The fixture's index.mjs reads the same dependencies as index.js, so the dependency
list stays single-sourced in package.json.

Refs: #8942
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/iitm-sync-loader-hooks branch 2 times, most recently from 26fa3f4 to 5c1803c Compare June 18, 2026 13:17
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 5c1803c141

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread loader-hook.mjs
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 9565485494

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread register.js Outdated
BridgeAR
BridgeAR previously approved these changes Jun 18, 2026

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, just left a nit

@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

BridgeAR
BridgeAR previously approved these changes Jun 18, 2026

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like it!

@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 10ae71a0df

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mainly LGTM

Comment thread register.js Outdated
Comment thread register.js Outdated
Comment thread packages/datadog-instrumentations/test/helpers/rewriter/loader.spec.mjs Outdated
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 8030bd7b82

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread register.js
@juan-fernandez
juan-fernandez requested a review from BridgeAR June 25, 2026 14:44
@juan-fernandez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 78100e6ed7

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Do not silently fall back to the async loader on Node versions where the synchronous loader should work. If sync hook registration fails or returns false on those versions, surface the failure so regressions are visible in CI.

Preserve the async fallback when require(esm) is explicitly disabled with --no-require-module, because that mode prevents the CJS preloader from requiring loader-hook.mjs.

Validation: git diff --check; ./node_modules/.bin/eslint register.js packages/dd-trace/test/register.spec.js; ./node_modules/.bin/mocha packages/dd-trace/test/register.spec.js; npm run lint:codeowners:ci; node --import ./register.js -e "console.log('register ok')"
@juan-fernandez
juan-fernandez force-pushed the juan-fernandez/iitm-sync-loader-hooks branch from 78100e6 to 39e7df0 Compare June 25, 2026 15:57
@juan-fernandez
juan-fernandez merged commit cf3c50c into master Jun 25, 2026
805 of 806 checks passed
@juan-fernandez
juan-fernandez deleted the juan-fernandez/iitm-sync-loader-hooks branch June 25, 2026 16:15
This was referenced Jun 25, 2026
pabloerhard pushed a commit that referenced this pull request Jun 26, 2026
The startup variants load the fixture through CommonJS require, which goes
through require-in-the-middle and never registers the iitm ESM loader. That
loader is what the synchronous module.registerHooks work changes from an
off-thread async loader to an in-thread sync one, so the suite reported no
movement for that change: nothing put the loader on a measured path.

with-tracer-everything-esm registers the loader via
--import ../../../register.js and imports the same fixture through ESM, so every
dependency and its transitive graph flow through the loader's resolve/load hooks.
The fixture's index.mjs reads the same dependencies as index.js, so the dependency
list stays single-sourced in package.json.

Refs: #8942
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