Skip to content

Conversation

benminer
Copy link
Contributor

@benminer benminer commented Feb 6, 2025

No description provided.

@benminer
Copy link
Contributor Author

benminer commented Feb 6, 2025

Need to add a new Github Action for node 21 and 22

grep "busyLoop.*src/busybench.js"
output=$(pprof -lines -top -nodecount=2 time.pb.gz | tee $tty)

# Due to V8 changes in Node 21, the line numbers are different.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR. It's unfortunate that the function name is lost. Do you have any more info on this V8 change or if there is something we can do to workaround it?

It's good to see the output is the same in older node versions.

Copy link
Member

Choose a reason for hiding this comment

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

Last time I looked at this, I did some playing around and found some weird behavior. #284 somehow restores the function name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, hm. I am no v8 expert, but from some quick searches, this could be because v8's optimizer was changed/improved in version 11 (which node21 is using). Since busyLoop is in the "hot path", there might be some under the hood optimizations happening to it that hide it from the profiler, which adding noop to break it up removes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to dig for a way to force this, it may even require some changes to how pprof is being called altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I just proved this too, adding this native syntax yields function name in v21 (without the noop function)

function busyLoop(durationSeconds) {
  %NeverOptimizeFunction(busyLoop);

You have to execute the benchmark with --allow-natives-syntax, though.

The output:

Showing top 2 nodes out of 6
      flat  flat%   sum%        cum   cum%
    1805ms 68.58% 68.58%     2606ms 99.01%  (anonymous) file:/tmp/tmp.YTvrn84YUd/busybench/src/busybench.js:37
     634ms 24.09% 92.67%      634ms 24.09%  busyLoop file:/tmp/tmp.YTvrn84YUd/busybench/src/busybench.js:32'

interesting that there is still one trace that is anonymous, though,

Copy link
Member

Choose a reason for hiding this comment

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

@benminer that makes sense and kind of what I figured. Thank you for looking into this. It sounds good to merge this then, I'll let @rohitpruthi-google take it over.

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.92%. Comparing base (dead429) to head (1e6dc15).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #305   +/-   ##
=======================================
  Coverage   41.92%   41.92%           
=======================================
  Files          14       14           
  Lines        2092     2092           
  Branches       42       42           
=======================================
  Hits          877      877           
  Misses       1197     1197           
  Partials       18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

grep "busyLoop.*src/busybench.ts"
output=$(pprof -filefunctions -top -nodecount=2 time.pb.gz | tee $tty)
if [ "$NODE_VERSION" -ge 21 ]; then
grep "anonymous.*busybench.ts" <<< "$output"
Copy link
Contributor

Choose a reason for hiding this comment

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

The tests are failing for node 21 because of the error:

++ pprof -filefunctions -top -nodecount=2 time.pb.gz
++ tee
Main binary filename not available.
+ output='Type: wall
Time: Feb 18, 2025 at 12:04pm (UTC)
Duration: 10.04s, Total samples = 9.26s (92.25%)
Showing nodes accounting for 8.74s, 94.40% of 9.26s total
Dropped 53 nodes (cum <= 0.05s)
Showing top 2 nodes out of 6
      flat  flat%   sum%        cum   cum%
     7.51s 81.13% 81.13%      7.52s 81.24%  (anonymous) /tmp/tmp.wxlgZ4mMRa/busybench/build/src/busybench.js
     1.23s 13.28% 94.40%      1.23s 13.28%  (idle)'
+ '[' 21 -ge 21 ']'
+ grep 'anonymous.*busybench.ts'
** TEST FAILED **

Could you please change this to busybench.js here? I am assuming the source reported here is from build files, hence the different extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rohitpruthi-google Not sure how I missed this, but yes, will fix!

Copy link

Choose a reason for hiding this comment

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

Any ETA when it will be merged/released?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@acierto I've just fixed all of the tests, it's up to @rohitpruthi-google to review now!

@benminer
Copy link
Contributor Author

benminer commented Jul 1, 2025

@rohitpruthi-google I believe I've addressed the feedback, and all tests are passing for me on my machine!

@AmitNimrodiBringg
Copy link

Hey @benminer , is it planned to merge sometime soon?
We've just migrated a service that uses pprof package, to Node V22, and it breaks because of the compatibility issue.

@benminer
Copy link
Contributor Author

benminer commented Sep 2, 2025

Hey @benminer , is it planned to merge sometime soon? We've just migrated a service that uses pprof package, to Node V22, and it breaks because of the compatibility issue.

hey @AmitNimrodiBringg - I am not in control of this repo, so I am not sure when they will get around to it! I might raise it with my Google contacts because it's been sitting for months now :)

To get around your Node22 issues, I recommend overriding pprof with this fork, like so:

        "pprof": "github:benminer/pprof-nodejs#main",

Hopefully, this can be temporary until the pprof team can take a look at this again.

@benminer
Copy link
Contributor Author

benminer commented Sep 2, 2025

@aabmass @rohitpruthi-google hey guys - just bumping this, would love to get this merged after 6 months.

@AmitNimrodiBringg
Copy link

hey @benminer @aabmass @rohitpruthi-google pinging again ☝️ Would really appreciate your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants