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

Node v11 6x crypto hash performance degradation #24266

Closed
SergeyFromHell opened this issue Nov 9, 2018 · 4 comments
Closed

Node v11 6x crypto hash performance degradation #24266

SergeyFromHell opened this issue Nov 9, 2018 · 4 comments
Labels
crypto Issues and PRs related to the crypto subsystem. performance Issues and PRs related to the performance of Node.js. regression Issues related to regressions.

Comments

@SergeyFromHell
Copy link

SergeyFromHell commented Nov 9, 2018

  • Version: v11.1.0
  • Platform: Linux
  • Subsystem: Crypto

I met a big performance degradation (about 6 times) with updating node version from 10.13.0 to 11.1.0. The scenario is: calculating many sha1 hashes of small strings (in my case theese are URLs, so about 20-50 bytes each).

const crypto = require('crypto');

const str = 'abcd'.repeat(10);

console.time('hash');
for(let i=0; i<1000000; ++i) {
	const hash = crypto.createHash('sha1').update(str).digest();
}
console.timeEnd('hash');

node 10 output:

hash: 3336.388ms

node 11 output:

hash: 18088.861ms
@vsemozhetbyt vsemozhetbyt added crypto Issues and PRs related to the crypto subsystem. performance Issues and PRs related to the performance of Node.js. labels Nov 9, 2018
@targos
Copy link
Member

targos commented Nov 9, 2018

/cc @nodejs/crypto

Most of the time is spent setting up the deprecated _handle property here:

Object.defineProperty(obj, '_handle', {
get: deprecate(() => handle,
`${obj.constructor.name}._handle is deprecated. Use the ` +
'public API instead.', 'DEP0117'),
set: deprecate((h) => obj[kHandle] = handle = h,
`${obj.constructor.name}._handle is deprecated. Use the ` +
'public API instead.', 'DEP0117'),
enumerable: false
});

@targos targos added the regression Issues related to regressions. label Nov 9, 2018
@targos
Copy link
Member

targos commented Nov 9, 2018

I'm trying a fix

targos added a commit to targos/node that referenced this issue Nov 9, 2018
Creating deprecated accessors each time an object is created is very
time consuming.

Refs: nodejs#22747
Fixes: nodejs#24266
@targos
Copy link
Member

targos commented Nov 9, 2018

#24269

@tniessen
Copy link
Member

tniessen commented Nov 9, 2018

Thanks for reporting this, @SergeyFromHell, and thanks for fixing it, @targos!

@targos targos closed this as completed in e83d7e8 Nov 11, 2018
BridgeAR pushed a commit that referenced this issue Nov 14, 2018
Creating deprecated accessors each time an object is created is very
time consuming.

Refs: #22747
Fixes: #24266

PR-URL: #24269
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
kiyomizumia pushed a commit to kiyomizumia/node that referenced this issue Nov 15, 2018
Creating deprecated accessors each time an object is created is very
time consuming.

Refs: nodejs#22747
Fixes: nodejs#24266

PR-URL: nodejs#24269
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. performance Issues and PRs related to the performance of Node.js. regression Issues related to regressions.
Projects
None yet
Development

No branches or pull requests

4 participants