FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc: add v8 fast api contribution guidelines by anonrig · Pull Request #46199 · nodejs/node · GitHub

/ node Public

doc: add v8 fast api contribution guidelines - #46199

Merged
nodejs-github-bot merged 7 commits into
nodejs:mainfrom
anonrig:docs-fast-api
Jan 24, 2023
Merged

doc: add v8 fast api contribution guidelines#46199
nodejs-github-bot merged 7 commits into
nodejs:mainfrom
anonrig:docs-fast-api

Conversation

anonrig commented Jan 13, 2023

Copy link
Copy Markdown
Member

I'm introducing a guideline to define and share the limitations/caveats and experiences I've gained from researching on this topic. This would help new contributors to add fast APIs to existing functions.

Referencing: nodejs/performance#23

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/tsc

nodejs-github-bot added the doc Issues and PRs related to the documentations. label Jan 13, 2023
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated

ronag left a comment
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Instead of calculateX could you maybe have div(a, b) as an example and have divide by 0 as example for when to switch to slow path?

tniessen 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

cc @devsnek who has done most of the fast API work in node IIRC

Comment thread doc/contributing/adding-v8-fast-api.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

internal C functions is rather ambiguous. Also, V8 internals usually refers to the non-public V8 API, which we try not to use in any case. Lastly, if I remember correctly, V8 API calls are allowed to some degree. Not performing any allocations on the V8 heap is what's critical. (Unless this changed since I last worked on fast API calls.)

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I see. Thanks! Can you give an example of V8 API call, without any allocation on the V8 heap?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I might be wrong, but I think @MayaLekova implemented a fast API that relies on GetAlignedPointerFromInternalField in 6cfba9f, for example. @devsnek might know more about the exact conditions for which APIs are allowed.

anonrig Jan 13, 2023
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You are right. You can access pre-existing/pre-allocated data from the fast apis. I thought it was inferred from the documentation (at least I assumed). Is there any specific wording you'd like me to change?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I've updated the documentation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

[...] Not performing any allocations on the V8 heap is what's critical.

Indeed that's still the case, and until we have the current GC architecture, it will stay like this. Possible future relaxation of this rule might come with conservative stack scanning. Please note that this also leads to the limitation for not calling back into JS code (I think this was discussed in this thread too).

Some brief background on the support for various types in V8 could be found in this external doc.

anonrig commented Jan 13, 2023

Copy link
Copy Markdown
Member Author

Instead of calculateX could you maybe have div(a, b) as an example and have divide by 0 as example for when to switch to slow path?

I updated the example. Thanks for the hint! 🥇 💯

Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think you should mention this file in the src/README.md too.

devsnek self-requested a review January 13, 2023 19:52

tony-go commented Jan 13, 2023

Copy link
Copy Markdown
Member

Awesome @anonrig 🙌🏼

Learned a lot just by reading the PR ^^

anonrig force-pushed the docs-fast-api branch 3 times, most recently from 90c81b8 to 66a8977 Compare January 13, 2023 21:57
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 20, 2023

Copy link
Copy Markdown
Collaborator

Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment on lines +14 to +15
* Throwing errors is not available on fast API, but can be done
through the fallback to slow API.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
* Throwing errors is not available on fast API, but can be done
through the fallback to slow API.
* Throwing errors is not available from within a fast API call, but can be done
through the fallback to the slow API.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Perhaps it's also better to suggest that since in principal, the fast API and the slow API should behave the same to avoid bugs, it's better not to throw errors in the slow API either and just update some flags and return to the JS land to throw?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I agree in principal with @joyeecheung, but that is not a limitation of a V8 Fast API declaration, but an implementation recommendation. I think it should not be included in this documentation, but in a more style specific documentation like README.md?

Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
Comment thread doc/contributing/adding-v8-fast-api.md Outdated
In V8, the options fallback is defined as `FastApiCallbackOptions` inside
[`v8-fast-api-calls.h`](../../deps/v8/include/v8-fast-api-calls.h).

* C++ land

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why is this a bullet point?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It aligns with other sections in the same file for mentioning the context of the example it's referring to. Do you have a recommendation for an alternative?

Comment thread src/README.md Outdated
Comment thread src/README.md Outdated

mcollina 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

anonrig added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jan 23, 2023
anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 24, 2023
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 Jan 24, 2023

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/46199
✔  Done loading data for nodejs/node/pull/46199
----------------------------------- PR info ------------------------------------
Title      doc: add v8 fast api contribution guidelines (#46199)
Author     Yagiz Nizipli  (@anonrig)
Branch     anonrig:docs-fast-api -> nodejs:main
Labels     doc, author ready, commit-queue-squash
Commits    7
 - doc: add v8 fast api contribution guidelines
 - fixup! doc: add v8 fast api contribution guidelines
 - fixup! doc: add v8 fast api contribution guidelines
 - fixup! doc: add v8 fast api contribution guidelines
 - fixup! doc: add v8 fast api contribution guidelines
 - fixup! doc: add v8 fast api contribution guidelines
 - fixup! doc: add v8 fast api contribution guidelines
Committers 1
 - Yagiz Nizipli 
PR-URL: https://github.com/nodejs/node/pull/46199
Reviewed-By: Matteo Collina 
Reviewed-By: Robert Nagy 
Reviewed-By: Darshan Sen 
Reviewed-By: Rafael Gonzaga 
Reviewed-By: James M Snell 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/46199
Reviewed-By: Matteo Collina 
Reviewed-By: Robert Nagy 
Reviewed-By: Darshan Sen 
Reviewed-By: Rafael Gonzaga 
Reviewed-By: James M Snell 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 13 Jan 2023 14:07:12 GMT
   ✔  Approvals: 5
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/46199#pullrequestreview-1266448194
   ✔  - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/46199#pullrequestreview-1248744183
   ✔  - Darshan Sen (@RaisinTen) (TSC): https://github.com/nodejs/node/pull/46199#pullrequestreview-1249572133
   ✔  - Rafael Gonzaga (@RafaelGSS) (TSC): https://github.com/nodejs/node/pull/46199#pullrequestreview-1253500941
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/46199#pullrequestreview-1262907890
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2023-01-20T03:25:41Z: https://ci.nodejs.org/job/node-test-pull-request/49099/
   ⚠  Commits were pushed after the last Full PR CI run:
   ⚠  - fixup! doc: add v8 fast api contribution guidelines
- Querying data for job/node-test-pull-request/49099/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/3992434537

anonrig added request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jan 24, 2023
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 24, 2023

Copy link
Copy Markdown
Collaborator

anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 24, 2023
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 24, 2023
nodejs-github-bot merged commit 7dd4583 into nodejs:main Jan 24, 2023

Copy link
Copy Markdown
Collaborator

Landed in 7dd4583

anonrig deleted the docs-fast-api branch January 24, 2023 03:46
ruyadorno pushed a commit that referenced this pull request Feb 1, 2023
PR-URL: #46199
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
ruyadorno mentioned this pull request Feb 1, 2023
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
PR-URL: #46199
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
juanarbol mentioned this pull request Mar 3, 2023
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
PR-URL: #46199
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. doc Issues and PRs related to the documentations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL