google / pprof-nodejs

pprof support for Node.js
Apache License 2.0
251 stars 26 forks source link

System test failing for Node 21 #283

Open aabmass opened 5 months ago

aabmass commented 5 months ago

Specifically seeing this issue with Node v21.6.1. What's happening is the output off pprof is missing function name (it just says "anonymous"):

+ pprof -filefunctions -top -nodecount=2 time.pb.gz                                               
Main binary filename not available.
Type: wall                                                                                        
Time: Jan 31, 2024 at 10:07pm (UTC)
Duration: 10.03s, Total samples = 9274ms (92.48%)                                                 
Showing nodes accounting for 9126ms, 98.40% of 9274ms total                                       
Dropped 43 nodes (cum <= 46.37ms)
Showing top 2 nodes out of 5
      flat  flat%   sum%        cum   cum%                                                        
    8262ms 89.09% 89.09%     8269ms 89.16%  (anonymous) /tmp/tmp.5G3K6fnfvv/busybench/src/busybench.ts
     864ms  9.32% 98.40%      864ms  9.32%  (idle)

compare the the Node 20 version which has the function name busyLoop:

+ pprof -filefunctions -top -nodecount=2 time.pb.gz                                                
Main binary filename not available.
Type: wall                                       
Time: Jan 31, 2024 at 9:24pm (UTC)
Duration: 10.03s, Total samples = 9272ms (92.47%)                                                  
Showing nodes accounting for 8750ms, 94.37% of 9272ms total                                        
Dropped 44 nodes (cum <= 46.36ms)
Showing top 2 nodes out of 6
      flat  flat%   sum%        cum   cum%
    7910ms 85.31% 85.31%     7913ms 85.34%  busyLoop /tmp/tmp.RSf1fHb4u0/busybench/src/busybench.ts 
     840ms  9.06% 94.37%      840ms  9.06%  (idle)

I'm not sure why, but its probably related to the V8 version used in Node 21. Some ideas I think it might be

Originally from https://github.com/google/pprof-nodejs/issues/281

aabmass commented 5 months ago

OK one way to make the system test pass for CPU profiling is to add a noop in the inner loop: https://github.com/google/pprof-nodejs/pull/284

This leads me to think the issue is with V8 CpuProfiler or there is some optimization affecting the profile. In any event, it's probably not our fault. I also tried with various other node v21.* minor versions with the same effect.