Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

src: introduce V8 fast api to guessHandleType #48349

Closed
wants to merge 2 commits into from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Jun 5, 2023

Divided the changes into 2 commits:

  • First commit returns uint32_t instead of string to remove unnecessary serialization.
  • Second commit adds V8 Fast API.

@anonrig anonrig added performance Issues and PRs related to the performance of Node.js. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. labels Jun 5, 2023
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/net
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jun 5, 2023
Copy link
Contributor

@RaisinTen RaisinTen left a comment

Choose a reason for hiding this comment

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

Were you able to measure the performance improvement?

src/node_util.cc Show resolved Hide resolved
@anonrig
Copy link
Member Author

anonrig commented Jun 5, 2023

Were you able to measure the performance improvement?

Unfortunately, I don't have the time, but imho the performance gains would be around 40-50% due to fast api.

@mscdex
Copy link
Contributor

mscdex commented Jun 5, 2023

I can't imagine there being a measurable difference with these changes.

@anonrig
Copy link
Member Author

anonrig commented Jun 5, 2023

I can't imagine there being a measurable difference with these changes.

I didn't understand. (English as a second language has its limitations): You don't believe that these changes would improve the performance. Right? Why would you think that?

@anonrig anonrig changed the title src: improve guessHandleType performance src: introduce V8 fast api to guessHandleType Jun 5, 2023
@mscdex
Copy link
Contributor

mscdex commented Jun 5, 2023

Why would you think that?

Because it's generally not something that would be done/called often enough and/or compared to other operations (e.g. performing I/O).

@RaisinTen
Copy link
Contributor

If this function is not called very frequently, V8 might not prefer the fast API over the slow one and so, the new code might not even get run.

Given that this also hampers readability with practically very little performance gain (because it's not a hot code path AFAICT), is it worth making this change?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2023
@nodejs-github-bot
Copy link
Collaborator

@cjihrig
Copy link
Contributor

cjihrig commented Jun 13, 2023

I'm curious about the second commit in this PR. Based on the comments and reactions, I'm guessing there are at least three people that question whether it should land at all since it complicates the code and is unlikely to show any real world improvements. Yet, there are claims of a possible 40-50% performance improvement with no benchmarks to confirm.

I don't think we should get in the habit of merging things like that. I also don't think we should add V8 fast paths everywhere possible, unless we know they are going to help (I'm pointing this out because similar suggestions have been made in other PRs recently).

@anonrig
Copy link
Member Author

anonrig commented Jun 13, 2023

I'm curious about the second commit in this PR. Based on the comments and reactions, I'm guessing there are at least three people that question whether it should land at all since it complicates the code and is unlikely to show any real world improvements. Yet, there are claims of a possible 40-50% performance improvement with no benchmarks to confirm.

This claim was mostly an educated guess referencing the improvements in previous V8 Fast API implementations. Due to the lack of time to add benchmarks to support my claim, I've changed the pull request title. If you think it's worth to split the commits into separate pull requests, I can do that as well, but not as soon as one can expect.

I also don't think we should add V8 fast paths everywhere possible, unless we know they are going to help.

I understand your concern, but this forces to find a unique path to trigger V8 to optimize and call Fast API, and it is not always easy to find that path. I personally, don't see any downsides of adding V8 Fast API integrations, since it does not effect the rest of the code. What I personally also like about V8 Fast API is that the limitations of it, forces us to keep our API surface as minimal as possible. For example, due to limitations, we can't return strings, which is a good thing because we also need to avoid strings serialization.

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2023
@anonrig anonrig requested a review from RaisinTen June 14, 2023 03:57
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2023
@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 14, 2023
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 14, 2023
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/48349
✔  Done loading data for nodejs/node/pull/48349
----------------------------------- PR info ------------------------------------
Title      src: introduce V8 fast api to `guessHandleType` (#48349)
Author     Yagiz Nizipli  (@anonrig)
Branch     anonrig:improve-guessHandleType -> nodejs:main
Labels     lib / src, performance, needs-ci, commit-queue-rebase
Commits    2
 - src: return uint32 for `guessHandleType`
 - src: add V8 fast api to `guessHandleType`
Committers 1
 - Yagiz Nizipli 
PR-URL: https://github.com/nodejs/node/pull/48349
Reviewed-By: Matteo Collina 
Reviewed-By: Robert Nagy 
Reviewed-By: Minwoo Jung 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/48349
Reviewed-By: Matteo Collina 
Reviewed-By: Robert Nagy 
Reviewed-By: Minwoo Jung 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - src: return uint32 for `guessHandleType`
   ⚠  - src: add V8 fast api to `guessHandleType`
   ℹ  This PR was created on Mon, 05 Jun 2023 16:41:28 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/48349#pullrequestreview-1465345051
   ✔  - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/48349#pullrequestreview-1465728186
   ✔  - Minwoo Jung (@JungMinu): https://github.com/nodejs/node/pull/48349#pullrequestreview-1471073777
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2023-06-14T04:03:31Z: https://ci.nodejs.org/job/node-test-pull-request/52248/
- Querying data for job/node-test-pull-request/52248/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/5271924719

@anonrig anonrig added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jun 15, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 15, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in f3ee4e2...d2dfdd6

nodejs-github-bot pushed a commit that referenced this pull request Jun 15, 2023
PR-URL: #48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Jun 15, 2023
PR-URL: #48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Jul 3, 2023
PR-URL: #48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Jul 3, 2023
PR-URL: #48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Jul 3, 2023
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48349
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
@ruyadorno ruyadorno added the backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. label Sep 8, 2023
@ruyadorno
Copy link
Member

This commit does not land cleanly on v18.x-staging and will need manual backport in case we want it to land in v18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants