-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Feature/faster crypto #664
Conversation
Handle most popular cases in a trie-style, branching on a first character. Remove useless HandleScope which was only eating time without producing any value.
Boosts speed up to 10% on primitive `createHash().update().digest()` benchmark.
Whoa replaced all uses of StringBytes in crypto. @bnoordhuis: please take a look. |
Ha, just created @iojs/crypto |
Oh, forgot to say. Overall improvement is about 15%. |
|
||
node::Utf8Value encoding(isolate, encoding_v); | ||
|
||
return ParseEncoding(*encoding, _default); |
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.
You can probably do a little better still by also passing encoding->length()
. Then you can filter on length first before you start comparing bytes.
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.
Also, wouldn't it be cheaper to do the comparison in JS and just pass integers to C++ land? I suspect that the biggest overhead is from the new[]/delete[] calls, not the string comparison.
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.
I'm +1 for JS-land thing, but for now - let's do it the way it is. encoding->length()
doesn't seem to be improving situation much on my benchmarks.
LGTM. Left some comments but nothing substantial. |
Handle most popular cases in a trie-style, branching on a first character. Remove useless HandleScope which was only eating time without producing any value. PR-URL: #664 Reviewed-By: Ben Noordhuis <[email protected]>
PR-URL: #664 Reviewed-By: Ben Noordhuis <[email protected]>
Boosts speed up to 10% on primitive `createHash().update().digest()` benchmark. PR-URL: #664 Reviewed-By: Ben Noordhuis <[email protected]>
Speaking of naming, I think |
@piscisaureus suggestions? |
First of all the To take it a step further, an The current (*) You might argue that the |
BTW I think this is a good addition. |
@piscisaureus there is no v8 API to do such on-stack allocations. |
@piscisaureus oh, we could use |
@piscisaureus opened a PR as you suggested #670 |
Right now this is only about
crypto.createHash().update().digest()
, but soon will add other methods here if you do not have any objections.cc @bnoordhuis . Btw, would be nice to have @iojs/crypto