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

Closed
bnoordhuis opened this Issue Mar 14, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@bnoordhuis
Contributor

bnoordhuis commented Mar 14, 2013

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

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Mar 14, 2013

Contributor

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

Contributor

bnoordhuis commented Mar 14, 2013

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

@bnoordhuis bnoordhuis referenced this issue in nodejs/node-v0.x-archive Apr 7, 2013

Closed

Chunked encoding + setNoDelay #5204

@saghul

This comment has been minimized.

Show comment Hide comment
@saghul

saghul Mar 10, 2014

Contributor

Do you still want to have this, Ben?

Contributor

saghul commented Mar 10, 2014

Do you still want to have this, Ben?

@saghul

This comment has been minimized.

Show comment Hide comment
@saghul

saghul Jul 30, 2014

Contributor

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...

Contributor

saghul commented Jul 30, 2014

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 Jul 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment