dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

[BUG]: Severe performance degradation on Node 22

Open mrgrain opened this issue 11 months ago • 1 comments

Tracer Version(s)

5.40.0

Node.js Version(s)

22.14.0

Bug Report

On Node 22 tracing performance when loading the aws-cdk-lib package is severely impacted. For more complex CDK applications, this gets much worst. We have customers reporting an increase from 2 min to over 30 min.

hyperfine -w5 "node20 dd-trace.js" "node22 dd-trace.js"
Benchmark 1: node20 dd-trace.js
  Time (mean ± σ):      1.388 s ±  0.015 s    [User: 1.470 s, System: 0.104 s]
  Range (min … max):    1.361 s …  1.405 s    10 runs
 
Benchmark 2: node22 dd-trace.js
  Time (mean ± σ):      8.826 s ±  0.124 s    [User: 9.143 s, System: 0.479 s]
  Range (min … max):    8.646 s …  9.022 s    10 runs
 
Summary
  node20 dd-trace.js ran
    6.36 ± 0.11 times faster than node22 dd-trace.js

Note that even for node20 performance is kind of slow. Running DD_TRACE_ENABLED=false node22 dd-trace.js brings the execution time up again.

Reproduction Code

Save as dd-trace.js

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}`);
}

Error Logs

No response

Tracer Config

No response

Operating System

Darwin Kernel Version 24.3.0

Bundling

Unsure

mrgrain avatar Mar 04 '25 18:03 mrgrain

@mrgrain I had a look into this and it seems like almost all time is spend in Node.js own code. After checking closer where the regression came from, I identified this change as most likely culprit.

This is unfortunate, that it's surfaced stronger with our code. I am going to see that it's going to be fixed in Node.js itself.

Image

I opened https://github.com/nodejs/node/issues/58126 for further tracking.

BridgeAR avatar May 02 '25 17:05 BridgeAR