Skip to content
This repository

stream: add uv_cork() and uv_uncork() #743

bnoordhuis opened this Issue · 2 comments

2 participants

Ben Noordhuis Saúl Ibarra Corretgé
Ben Noordhuis

Proposal: add two new API functions, uv_cork() and uv_uncork().

The first one stops libuv from trying to write out pending write reqs, the second one tells libuv it's okay again to write.

Purpose: to make it possible for the libuv user to signal libuv that he'll be making several calls to uv_write() and that libuv should try to batch those into a single writev() call.


uv_stream_t stream = /* ... */;
uv_write(&req1, stream, &buf1, 1, write_cb);
uv_write(&req2, stream, &buf2, 1, write_cb);
uv_uncork(stream);  // flushes the pending data to the network

Without cork/uncork, buf1 would likely be written out immediately and buf2 probably ends up in a separate TCP packet, meaning an extra round trip (=higher latency).

/cc @piscisaureus

Ben Noordhuis

Depends on #742, refs joyent/node#4975.

Ben Noordhuis bnoordhuis referenced this issue in joyent/node

Chunked encoding + setNoDelay #5204

Saúl Ibarra Corretgé

Do you still want to have this, Ben?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.