-
Notifications
You must be signed in to change notification settings - Fork 51
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
[DENO] optimization on write to just queue up #534
Conversation
src/deno_transport.ts
Outdated
} | ||
this.pendingWrite = writeAll(this.conn, frame).then(() => { | ||
this.pendingWrite = null; | ||
queueMicrotask(() => { |
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.
This didn't have an observable effect so unsure if we should be keeping it. Was trying it to see if the stack would empty which it did not seem to. Promises effectively schedules a micro task.
queueMicrotask(() => { | |
queueMicrotask(() => { |
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.
Benched a bit, definitively faster than main (this is on deno 1.33.x as 1.4 has major issues).
Repositories/nats.deno (on branch 'main') $ deno run --reload -A examples/bench.js --subject a --pub --payload 3500 --count 1000000 --pendingLimit 1024
pub 96,089 msgs/sec - [10.41 secs] ~ 320.73 MB/sec 10407/10407
Repositories/nats.deno (on branch 'write-perf') $ deno run --reload -A examples/bench.js --subject a --pub --payload 3500 --count 1000000 --pendingLimit 1024
pub 421,322 msgs/sec - [2.37 secs] ~ 1.37 GB/sec 2373.4810420000003/2373.4810420000003
src/deno_transport.ts
Outdated
await this.enqueue(TE.encode("")); | ||
this.frames.push(Empty); | ||
const d = deferred<void>(); | ||
this.maybeWriteFrame(d); |
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.
Could just await this.pendingWrite here?
@caspervonb this is effectively your simplification, including the changes to support
debug
and the closing promise.