Skip to content

Conversation

@mildsunrise
Copy link
Contributor

Backport of #27861 (and also #27891 and #28903 to fix tests).

The original code uses AllocatedBuffer, so we would need to also backport #26207 (specifically 6c257cd). Instead I've defined it as vector<char> which has almost identical API; are these changes okay for backports?

Correct docs to clarify that behaviour,
and fix a race condition in test-http2-large-write-destroy.js.

Fixes: nodejs#27863
PR-URL: nodejs#27891
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: nodejs#28903
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
TLSWrap::DoWrite() now concatenates data chunks and makes a single
call to SSL_write(). Grouping data into a single segment:

- reduces network overhead: by factors of even 2 or 3 in usages
  like `http2` or `form-data`

- improves security: segment lengths can reveal lots of info, i.e.
  with `form-data`, how many fields are sent and the approximate length
  of every individual field and its headers

- reduces encryption overhead: a quick benchmark showed a ~30% CPU time
  decrease for an extreme case, see
  nodejs#27573 (comment)

Fixes: nodejs#27573

PR-URL: nodejs#27861
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. tls Issues and PRs related to the tls subsystem. v10.x labels Jul 30, 2019
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Aug 2, 2019

Tests are passing. /ping @nodejs/backporters for reviews/landing

@Trott
Copy link
Member

Trott commented Aug 2, 2019

@nodejs/crypto

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

Instead I've defined it as vector<char> which has almost identical API; are these changes okay for backports?

Ideally the delta between release lines is as small as possible. If it's not a gargantuan task to back-port the AllocatedBuffer API, then that's strongly preferred.

@mildsunrise
Copy link
Contributor Author

Then I'll try to also backport #26207 and see if it works.

@mildsunrise
Copy link
Contributor Author

I've tried to do a backport of just 6c257cd (commit that adds the API) but it needs the previous 4 commits of #26207, including a patch to V8. The last commit, 84e02b1 (which touches a lot of Node.JS parts) adds a lot of conflicts, but isn't necessary to have the API. What do I do?

@bnoordhuis
Copy link
Member

Thanks, at least you tried. I'm good with landing this PR as is.

BethGriggs pushed a commit that referenced this pull request Oct 7, 2019
Correct docs to clarify that behaviour,
and fix a race condition in test-http2-large-write-destroy.js.

Fixes: #27863

Backport-PR-URL: #28904
PR-URL: #27891
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 7, 2019
Backport-PR-URL: #28904
PR-URL: #28903
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 7, 2019
TLSWrap::DoWrite() now concatenates data chunks and makes a single
call to SSL_write(). Grouping data into a single segment:

- reduces network overhead: by factors of even 2 or 3 in usages
  like `http2` or `form-data`

- improves security: segment lengths can reveal lots of info, i.e.
  with `form-data`, how many fields are sent and the approximate length
  of every individual field and its headers

- reduces encryption overhead: a quick benchmark showed a ~30% CPU time
  decrease for an extreme case, see
  #27573 (comment)

Fixes: #27573

Backport-PR-URL: #28904
PR-URL: #27861
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@BethGriggs
Copy link
Member

Landed in 7f48519...fe58bca

@BethGriggs BethGriggs closed this Oct 7, 2019
@mildsunrise mildsunrise deleted the v10.x-tls-writev branch October 7, 2019 10:52
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++. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants