Skip to content

Commit

Permalink
src: use EnqueueMicrotask for tls writes
Browse files Browse the repository at this point in the history
Instead of using SetImmediate, use EnqueueMicrotask as it appears to
be significantly more performant in certain cases and even in the
optimal case yields roughly 10% higher throughput.
  • Loading branch information
apapirovski committed Apr 25, 2018
1 parent d3edf2f commit 48e6289
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,10 @@ void TLSWrap::EncOut() {
NODE_COUNT_NET_BYTES_SENT(write_size_);

if (!res.async) {
HandleScope handle_scope(env()->isolate());

// Simulate asynchronous finishing, TLS cannot handle this at the moment.
env()->SetImmediate([](Environment* env, void* data) {
env()->isolate()->EnqueueMicrotask([](void* data) {
static_cast<TLSWrap*>(data)->OnStreamAfterWrite(nullptr, 0);
}, this, object());
}, this);
}
}

Expand Down

0 comments on commit 48e6289

Please sign in to comment.