Open
Description
Version
21.5.0
Platform
Darwin COMP-F2RFYQPYC7 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041 arm64 arm Darwin
Subsystem
module
What steps will reproduce the bug?
The bug was originally reported as performance regression in the aws-cdk-lib
when using Node.js v22 instead of v20. The regression seems to surface stronger in combination with dd-trace
, which instruments the library code.
When I ran a flamegraph on the below example, at least 80% of time is spend in Node.js package_json_reader (image)
npm i dd-trace aws-cdk-lib constructs
nvm i 21.4.0
time node test.js
# About 500 ms on my device
nvm i 21.5.0
time node test.js
# About 4500 ms on my device
require('dd-trace').init();
const cdk = require('aws-cdk-lib');
const app = new cdk.App();
for (let i = 0; i < 1000; i++) { // simulate a large CDK app
new cdk.Stack(app, `DdTraceStack${i}`);
}
I do not have the time to look into it deeper, so I also can't post any reproducible code without external code.
It does seem to be related to this PR: #50322
CC @anonrig
See also aws/aws-cdk#33576, DataDog/dd-trace-js#5360, aws/aws-cdk#34112
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
To have about the same runtime as v21.4.0
What do you see instead?
The runtime increases by a factor of 9x
Additional information
No response