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

Optimize request.pipeline writing #208

Closed
ronag opened this issue May 30, 2020 · 4 comments
Closed

Optimize request.pipeline writing #208

ronag opened this issue May 30, 2020 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@ronag
Copy link
Member

ronag commented May 30, 2020

It should be possible to have the returned Duplex write directly to the socket. Instead of providing a Readable as request body we can provide a function, i.e. the reverse of what we do on the response side in request.enqueue.

This would allow us to entirely bypass the intermediate PassThrough or Readable between the Duplex and the socket.

@ronag ronag added the enhancement New feature or request label May 30, 2020
@ronag ronag added this to the 1.1.0 milestone May 30, 2020
@ronag ronag changed the title Optimize pipeline Optimize request.pipeline writing May 30, 2020
@ronag
Copy link
Member Author

ronag commented May 30, 2020

Might also make use of WritableBase which is being worked on here. Could extract that out into this library in order to use of it across Node versions.

@mcollina
Copy link
Member

go for it

@szmarczak
Copy link
Member

I ran the benchmarks on master again. I got:

http - keepalive - pipe x 9,623 ops/sec ±3.24% (76 runs sampled)
undici - request - pipe x 16,881 ops/sec ±0.45% (86 runs sampled)
undici - pipeline - pipe x 11,107 ops/sec ±0.81% (87 runs sampled)
undici - stream - pipe x 17,350 ops/sec ±0.61% (86 runs sampled)

Indeed it's still faster than the native http2 module 🎉

Also I fixed the h2o.conf in http2-wrapper so when you clone the repo you can easily start the server just by running
h2o -c h2o.conf (no need to clone the examples in the h2o repository).

@ronag
Copy link
Member Author

ronag commented Aug 12, 2020

Let's stick to normal streams and not go to crazy here. pipeline has reasonable perf now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants