perf(loader): use synchronous hooks during initialization - #9656
perf(loader): use synchronous hooks during initialization#9656BridgeAR wants to merge 2 commits into
Conversation
--import dd-trace/initialize.mjs always installed the off-thread loader, so supported runtimes still paid main-thread/loader-worker IPC during startup. Reusing the existing synchronous registration path reduced empty-process startup from 405.81 to 386.82 ms and 404.58 to 380.09 ms on Node 24.18.0 (25 alternating trials, best and worst dropped).
Overall package sizeSelf size: 7.76 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.3 | 125.43 kB | 441.68 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 |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9656 +/- ##
==========================================
- Coverage 98.53% 98.52% -0.02%
==========================================
Files 955 955
Lines 133293 133306 +13
Branches 11536 11567 +31
==========================================
- Hits 131340 131339 -1
- Misses 1953 1967 +14 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-08-03 16:02:00 Comparing candidate commit 53db9ed in PR branch Found 2 performance improvements and 2 performance regressions! Performance is the same for 2315 metrics, 39 unstable metrics.
|
Ordinary CommonJS require() entered the synchronous ESM resolve/load pipeline even though require-in-the-middle owns its instrumentation. Bypassing that redundant work reduced startup for the 21-dependency mixed ESM/CJS fixture from 1071.62 to 1053.44 ms and from 1052.92 to 1027.62 ms in two fresh-shell runs (25 alternating trials, best and worst dropped).
Summary
--import dd-trace/initialize.mjsalways registered the off-thread loader directly, bypassing the existing synchronous registration path. Supported runtimes therefore kept the main-thread/loader-worker IPC overhead thatregister.jsalready avoids.This reduced empty-process startup from 405.81 to 386.82 ms and from 404.58 to 380.09 ms in two fresh-shell runs on Node 24.18.0 (25 alternating trials, best and worst dropped).