Skip to content

dgram: improve get-send-queue-info performance - #59054

Open
IlyasShabi wants to merge 6 commits into
nodejs:mainfrom
IlyasShabi:ishabi/get-send-queue-info
Open

IlyasShabi wants to merge 6 commits into
nodejs:mainfrom
IlyasShabi:ishabi/get-send-queue-info

Conversation

@IlyasShabi

Copy link
Copy Markdown
Member

Improve dgram getSendQueueSize and getSendQueueCount performance by using V8 fast API.

Local benchmark:

                                                      confidence improvement accuracy (*)   (**)  (***)
dgram/get-send-queue-info.js method='count' n=5000000        ***    127.63 %       ±1.01% ±1.35% ±1.77%
dgram/get-send-queue-info.js method='size' n=5000000         ***    127.77 %       ±2.18% ±2.92% ±3.86%

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net
  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dgram Issues and PRs related to UDP and the dgram module. needs-ci PRs that need a full CI run. labels Jul 13, 2025
@IlyasShabi
IlyasShabi marked this pull request as ready for review July 13, 2025 22:32
@codecov

codecov Bot commented Jul 13, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.82609% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.53%. Comparing base (dbe45b7) to head (49d0d65).
⚠️ Report is 4589 commits behind head on main.

Files with missing lines Patch % Lines
src/udp_wrap.cc 47.82% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #59054      +/-   ##
==========================================
- Coverage   88.54%   88.53%   -0.01%     
==========================================
  Files         704      704              
  Lines      207843   207863      +20     
  Branches    40044    40049       +5     
==========================================
+ Hits       184028   184035       +7     
+ Misses      15858    15856       -2     
- Partials     7957     7972      +15     
Files with missing lines Coverage Δ
src/udp_wrap.h 100.00% <ø> (ø)
src/udp_wrap.cc 76.86% <47.82%> (-1.43%) ⬇️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread benchmark/dgram/get-send-queue-info.js Outdated
bench.start();

if (method === 'size') {
for (let i = 0; i < n; ++i) server.getSendQueueSize();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think at some point this will be JIT-eliminated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think that getSendQueueSize() will not be JIT eliminated because it still calls into libuv. Im using size and count now to accumulate the results in order to make that explicit

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@RafaelGSS RafaelGSS left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nevermind, I was looking to HEAD.

@RafaelGSS RafaelGSS added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jul 17, 2025
@IlyasShabi
IlyasShabi force-pushed the ishabi/get-send-queue-info branch from 0f7af8e to 7f9c6e8 Compare July 21, 2025 11:11
@IlyasShabi IlyasShabi added the commit-queue PRs queued for automated landing through the Commit Queue. label Jul 21, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Jul 21, 2025
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/59054
✔  Done loading data for nodejs/node/pull/59054
----------------------------------- PR info ------------------------------------
Title      dgram: improve get-send-queue-info performance (#59054)
Author     Ilyas Shabi <ilyasshabi94@gmail.com> (@IlyasShabi)
Branch     IlyasShabi:ishabi/get-send-queue-info -> nodejs:main
Labels     dgram, c++, author ready, needs-ci
Commits    3
 - dgram: improve get-send-queue-info performance
 - keep packets unsent to have data in getters
 - fix benchmark test
Committers 1
 - ishabi <ilyasshabi94@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/59054
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/59054
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sun, 13 Jul 2025 22:32:01 GMT
   ✔  Approvals: 2
   ✔  - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/59054#pullrequestreview-3031186521
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/59054#pullrequestreview-3038885029
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2025-07-17T21:21:09Z: https://ci.nodejs.org/job/node-test-pull-request/67989/
   ⚠  Commits were pushed after the last Full PR CI run:
   ⚠  - dgram: improve get-send-queue-info performance
   ⚠  - keep packets unsent to have data in getters
   ⚠  - fix benchmark test
- Querying data for job/node-test-pull-request/67989/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/16423922247

@IlyasShabi
IlyasShabi force-pushed the ishabi/get-send-queue-info branch from 7f9c6e8 to 0d00b58 Compare July 28, 2025 09:14
@IlyasShabi
IlyasShabi requested review from RafaelGSS and jasnell July 29, 2025 08:44

@H4ad H4ad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be safer to test on fastApi as well, would you mind adding a test for it? You can use this one as example: https://github.com/nodejs/node/blob/cd0c5159e64353bc057c5704767145b46887c735/test/parallel/test-os-fast.js

Just a little reminder, you need to wrap your function during the test (testFastOs in the example above) to pass that function to the v8 optimize, it fails if you try to optimize your new method directly.

@H4ad H4ad removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Jul 29, 2025
@H4ad

H4ad commented Jul 29, 2025

Copy link
Copy Markdown
Member

You also need to update the first commit message to reflect the new change: add fast api for get-send-queue-size method

@H4ad H4ad added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Jul 29, 2025
@IlyasShabi
IlyasShabi force-pushed the ishabi/get-send-queue-info branch from 0d00b58 to b249db8 Compare August 4, 2025 11:16
@IlyasShabi
IlyasShabi requested a review from a team as a code owner October 13, 2025 20:10
@IlyasShabi
IlyasShabi force-pushed the ishabi/get-send-queue-info branch from 2e55992 to 49d0d65 Compare November 2, 2025 16:06
@RafaelGSS RafaelGSS added the performance Issues and PRs related to the performance of Node.js. label Nov 2, 2025
@avivkeller avivkeller added needs-ci PRs that need a full CI run. commit-queue-squash PRs the Commit Queue should land as one squashed commit. and removed needs-ci PRs that need a full CI run. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Jan 9, 2026
@IlyasShabi IlyasShabi added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 22, 2026
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Jan 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor
Failed to start CI
   ⚠  Commits were pushed since the last approving review:
   ⚠  - dgram: add fast api for get-send-queue-size method
   ⚠  - keep packets unsent to have data in getters
   ⚠  - fix benchmark test
   ⚠  - add fast api test
   ⚠  - fix linter
   ⚠  - src: track fast api call
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/21245794917

@RafaelGSS RafaelGSS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Please update readme with benchmari ci results (33%~)

@anonrig anonrig added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. labels Jan 22, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 22, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Jun 22, 2026
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor
Failed to start CI
- Validating Jenkins credentials
✔  Jenkins credentials valid
- Querying data for job/node-test-pull-request/70972/
[SyntaxError: Unexpected token '<', ..."    
  https://github.com/nodejs/node/actions/runs/27932938404

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark GHA (dgram / get-send-queue-info): https://github.com/nodejs/node/actions/runs/31024654582

Results

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

Benchmark results:

                                                      confidence improvement accuracy (*)   (**)  (***)
dgram/get-send-queue-info.js method='count' n=5000000        ***    -42.76 %       ±3.07% ±4.04% ±5.18%
dgram/get-send-queue-info.js method='size' n=5000000         ***    -40.61 %       ±3.14% ±4.14% ±5.31%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 2 comparisons, you can thus
expect the following amount of false-positive results:
  0.10 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.02 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

@aduh95

aduh95 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The CI finds a negative "improvement", with great confidence. We likely don't want to land this

@panva panva removed author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. labels Sep 7, 2026
@Ethan-Arrowood

Copy link
Copy Markdown
Contributor

There has been no reasonable activity on this PR in over 90 days. Adding the stalled label. Please feel free to update if you wish to continue work on it.

@Ethan-Arrowood Ethan-Arrowood added the stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. label Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open.

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. dgram Issues and PRs related to UDP and the dgram module. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js. stalled Issues and PRs manually marked as stalled and scheduled for automatic closure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.