Open haoruiqian opened 7 years ago
Does it happen every time you try?
Can't reproduce it on 10.12.4 (16E195), 2.6 GHz Intel Core i5, 8 GB 1600 MHz DDR3, even after 500 attempts. My guess would be that it's either the garbage collector kicks in and slows things down, or your CPU is getting throttled (most likely the latter).
Yes, I can reproduce it every time I try, I can reproduce it in a Linode VPS which has 1GB memory as well.
I tried to test with different node versions today, and this seems related to node, the performance issue happened with node version 4.4.5, if I run the test code with node 6.10.1, no performance issue.
I used Intel Power Gadget to monitor the CPU Frequency, the Frequency increased significantly when running scrypt(), please check the screenshot
The interval inside the red rectangle is during I was running the test, seems this is not related to CPU is getting throttled?
Hi,
The same problem exists in the eth-lightwallet library. I have implemented a solution for reducing the nextTick calls to bypass the browser throttling in this area.
Look at this pull request.
This also happens on JavaScriptCore (React Native).
It doesn't seem to be a library problem, but an engine problem, unfortunately.
"interruptStep: 0" in the OP's code implies no calls to nextTick (just synchronous looping) so I don't understand why it would slow down after repeated calls (i.e. no nextTick throttling)
I encountered performance issue when using scrypt-async to crypt the password, following is the test code
After tens of calling of scrypt, the encryption time becomes 15 times more, following is the output:
As you can see, the beginning 43 calls just cost about 150ms in average, but from the 44th call, the time increased to 2300ms.
The scrypt-async version is 1.3.1, nodejs version 4.4.5 I'm using a MacOS, version 10.12.4 (16E195), Processor 2.8 GHz Intel Core i7, Memory 16 GB 1600 MHz DDR3.