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: optimize ALPN callback #44875

Closed
wants to merge 2 commits into from
Closed

Conversation

bnoordhuis
Copy link
Member

It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.


First commit is minor cleanup for readability++.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. 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 Oct 3, 2022
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.
@tniessen
Copy link
Member

tniessen commented Oct 3, 2022

It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

Is this technically breaking in that users were previously able to modify the ArrayBuffer in-between handshakes?

@bnoordhuis
Copy link
Member Author

I suppose, but it's an undocumented property on an undocumented property. Seems both very unlikely and not deserving of much sympathy.

@bnoordhuis bnoordhuis added request-ci Add this label to start a Jenkins CI on a PR. and removed needs-ci PRs that need a full CI run. labels Oct 10, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 10, 2022
@nodejs-github-bot
Copy link
Collaborator

@bnoordhuis bnoordhuis added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 19, 2022
@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 Oct 19, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/44875
✔  Done loading data for nodejs/node/pull/44875
----------------------------------- PR info ------------------------------------
Title      src: optimize ALPN callback (#44875)
Author     Ben Noordhuis  (@bnoordhuis)
Branch     bnoordhuis:more-better-alpn -> nodejs:main
Labels     c++, lib / src
Commits    2
 - src: simplify ALPN code, remove indirection
 - src: optimize ALPN callback
Committers 1
 - Ben Noordhuis 
PR-URL: https://github.com/nodejs/node/pull/44875
Reviewed-By: James M Snell 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/44875
Reviewed-By: James M Snell 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Mon, 03 Oct 2022 11:03:19 GMT
   ✔  Approvals: 1
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/44875#pullrequestreview-1136253893
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-10-10T22:25:49Z: https://ci.nodejs.org/job/node-test-pull-request/47165/
- Querying data for job/node-test-pull-request/47165/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
   9926b89a99..19f3973828  main       -> origin/main
✔  origin/main is now up-to-date
main is out of sync with origin/main. Mismatched commits:
 - 6ff429777a meta: move one or more collaborators to emeritus
 - 19f3973828 meta: move one or more collaborators to emeritus
--------------------------------------------------------------------------------
HEAD is now at 19f3973828 meta: move one or more collaborators to emeritus
   ✔  Reset to origin/main
- Downloading patch for 44875
From https://github.com/nodejs/node
 * branch                  refs/pull/44875/merge -> FETCH_HEAD
✔  Fetched commits as 19f397382810..0f5896716196
--------------------------------------------------------------------------------
Auto-merging src/crypto/crypto_common.cc
[main b6f6501ff8] src: simplify ALPN code, remove indirection
 Author: Ben Noordhuis 
 Date: Mon Oct 3 13:00:53 2022 +0200
 3 files changed, 4 insertions(+), 12 deletions(-)
Auto-merging src/env_properties.h
[main 821948a439] src: optimize ALPN callback
 Author: Ben Noordhuis 
 Date: Mon Oct 3 13:00:53 2022 +0200
 5 files changed, 19 insertions(+), 35 deletions(-)
   ✔  Patches applied
There are 2 commits in the PR. Attempting autorebase.
Rebasing (2/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
src: simplify ALPN code, remove indirection

PR-URL: #44875
Reviewed-By: James M Snell jasnell@gmail.com

[detached HEAD 777dea3416] src: simplify ALPN code, remove indirection
Author: Ben Noordhuis info@bnoordhuis.nl
Date: Mon Oct 3 13:00:53 2022 +0200
3 files changed, 4 insertions(+), 12 deletions(-)
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
src: optimize ALPN callback

It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell jasnell@gmail.com

[detached HEAD 3465634e85] src: optimize ALPN callback
Author: Ben Noordhuis info@bnoordhuis.nl
Date: Mon Oct 3 13:00:53 2022 +0200
5 files changed, 19 insertions(+), 35 deletions(-)

Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/3284097315

Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

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

Agreed that the breaking change is unlikely to affect anything.

@richardlau richardlau added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Oct 19, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 19, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 2d0d997...fdadea8

nodejs-github-bot pushed a commit that referenced this pull request Oct 19, 2022
PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
nodejs-github-bot pushed a commit that referenced this pull request Oct 19, 2022
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@bnoordhuis bnoordhuis deleted the more-better-alpn branch October 19, 2022 23:30
RafaelGSS pushed a commit that referenced this pull request Nov 1, 2022
PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
RafaelGSS pushed a commit that referenced this pull request Nov 1, 2022
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@RafaelGSS RafaelGSS mentioned this pull request Nov 1, 2022
RafaelGSS pushed a commit that referenced this pull request Nov 10, 2022
PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
RafaelGSS pushed a commit that referenced this pull request Nov 10, 2022
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
It doesn't make sense from a performance perspective to retain an
arraybuffer with the ALPN byte string and look it up as a property on
the JS context object for every TLS handshake.

Store the byte string in the C++ TLSWrap object instead. That's both
a lot faster and a lot simpler.

PR-URL: #44875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
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++. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants