-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
crypto: make createXYZ inlineable #16067
Conversation
This is just an example. We should do the same for all the rest of the |
Yes, I think we should be doing it for the rest as well. |
The reason it was not inlining was with the following output:
|
@mscdex do you prefer if we do all of them here, or we do this into separate PRs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the understanding that this is going to be done with all the other creation functions, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
For the record: We removed the recursive inlining restriction recently.
@bmeurer is this worth doing then? In which version of V8 this is going to be part of? |
625e27b
to
a6a2f89
Compare
I have ported all the createXYZ functions. |
I think it's worth doing for now, especially for node v8.x which may not see the version of V8 where the fixed is applied. |
lib/crypto.js
Outdated
@@ -79,23 +79,67 @@ const { | |||
} = require('internal/crypto/util'); | |||
const Certificate = require('internal/crypto/certificate'); | |||
|
|||
function createHash(algorithm, options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a quick comment explaining the optimization.
a6a2f89
to
6042f8e
Compare
@bengl done. |
@mcollina I just noticed that we still disallow direct recursive inlining (as of 08bfcb293cfff2d71bcfb28fae8679d0b29a3d5c), so even though indirect recursion is handled, direct recursion is not. These changes are in V8 6.2. So for Node 8 it definitely makes sense to land this change. |
lib/crypto.js
Outdated
@@ -79,23 +79,69 @@ const { | |||
} = require('internal/crypto/util'); | |||
const Certificate = require('internal/crypto/certificate'); | |||
|
|||
// These function are needed because Hash() calls new Hash() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits:
s/function/helper functions/
Also, might use more generic wording like 'These helper functions are needed because the constructors can use new
, in which case V8 cannot inline the recursive constructor call' or something along those lines.
This commit increase by around 10% hot code paths that are hitting createXYZ functions. Before this change the createXYZ called the XYZ constructor without new.
6042f8e
to
4e61acb
Compare
CI before landing: https://ci.nodejs.org/job/node-test-pull-request/10523/ |
Landed as 9bc4f86 |
This commit increase by around 10% hot code paths that are hitting createXYZ functions. Before this change the createXYZ called the XYZ constructor without new. PR-URL: #16067 Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This commit increase by around 10% hot code paths that are hitting createXYZ functions. Before this change the createXYZ called the XYZ constructor without new. PR-URL: nodejs/node#16067 Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This does not land cleanly on v8.x Would someone be willing to backport if it makes sense? |
assert.strictEqual(crypto.createHash, crypto.Hash); et al. throw with this change, should we backport anyway? |
@lpinca if it is breaking than this should likely be tagged semver-major, if not then I don't see why we shouldn't backport |
@MylesBorins yes exactly I'm not sure if it's a breaking change or not. |
setting semver-major for right now /cc @nodejs/tsc to chime in. Feel free to change tag |
According to our doc, this is patch. if people are calling createHash with new, probably they are doing somethig wrong. This can go in 8. Or we can bake it for a bit on 9 and then backport to 8. |
I'm +1 on it being semver-patch. |
This commit increase by around 10% hot code paths that are hitting createXYZ functions. Before this change the createXYZ called the XYZ constructor without new. PR-URL: nodejs#16067 Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Backport in #16446 marked as blocked currently. |
dropping semver-major. Thinking we should let this bake in 9.x a bit first |
This commit increase by around 10% hot code paths that are hitting createXYZ functions. Before this change the createXYZ called the XYZ constructor without new. PR-URL: #16067 Backport-PR-URL: #16446 Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This commit increase by around 10% hot code paths that are hitting createXYZ functions. Before this change the createXYZ called the XYZ constructor without new. PR-URL: #16067 Backport-PR-URL: #16446 Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This commit increase by around 10% hot code paths that are hitting
createXYZ functions. Before this change the createXYZ called the XYZ
constructor without new.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
crypto