Skip to content

fix: update test.sh for Node 21 and up output #305

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants