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

Does a createCipheriv stream execute in the threadpool or the main thread? #8318

Closed
jorangreef opened this issue Aug 29, 2016 · 3 comments
Closed
Labels
crypto Issues and PRs related to the crypto subsystem. question Issues that look for answers.

Comments

@jorangreef
Copy link
Contributor

I can see that a cipher stream calls 'end' asynchronously, i.e. at least in the next tick after cipher.end() is called.

I am not sure from the source though, if OpenSSL's EVP... methods are actually executed in the threadpool or in the main thread?

Does a createCipheriv() stream execute in the threadpool, or does it just execute in the main thread, while deferring the 'end' event with a nextTick()?

@addaleax addaleax added question Issues that look for answers. crypto Issues and PRs related to the crypto subsystem. labels Aug 29, 2016
@mscdex
Copy link
Contributor

mscdex commented Aug 29, 2016

Pretty much the only asynchronous (meaning executed in the thread pool) crypto API is crypto.randomBytes() (when a callback is passed), everything else is executed synchronously on the main thread currently.

Related issue: #678

@jorangreef
Copy link
Contributor Author

Thanks @mscdex, will close this in favor of #678

@jorangreef
Copy link
Contributor Author

In case anyone else is looking for async cipher, hash or hmac operations, I created a native module, crypto-async, to execute these in Node's threadpool without blocking the event loop. The latency is very close to Node's operations, but the throughput is much better because more CPU cores can be utilized. The module includes a latency and throughput comparison.

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. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

3 participants