Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Optimize uv_write() + uv_fs_sendfile() #1470

Open
@bnoordhuis

Description

A standard trick on Linux to pack response headers and body into a single TCP packet is to sendmsg() the headers with flags=MSG_MORE and sendfile() or splice() the body afterwards. That kind of optimized mix-and-match I/O is not something you can do with libuv.

In theory, libuv could apply the sendmsg+sendfile trick implicitly by correlating write and sendfile requests for the same file descriptor. That wouldn't need any new APIs but it would require deep cooperation between normal socket I/O and the thread pool. (The time gap between the system calls should be short in order to be effective. Wait too long and the kernel will flush the headers automatically. Then you not only have two TCP packets but also extra latency.)

Alternatively, one could conceive an "I/O plan" API that lets the user compile a sequence of I/O actions. I'm not sure what it would look like but it's potentially more general, extensible and reliable than applying heuristics.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions