Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
bnoordhuis opened this Issue · 3 comments

2 participants

@bnoordhuis

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.

Example:

uv_stream_t stream = /* ... */;
uv_cork(stream);
do_something();
uv_write(&req1, stream, &buf1, 1, write_cb);
do_something_else();
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

@bnoordhuis

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

@bnoordhuis bnoordhuis referenced this issue in joyent/node
Open

Chunked encoding + setNoDelay #5204

@saghul
Owner

Do you still want to have this, Ben?

@saghul
Owner

Tentatively closing this since node seems to have solved it another way and libuv people can pass multiple buffers to uv_write. Eventually we should address #742, sigh...

@saghul saghul closed this
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.