3 ms·
you can already send fragmented data in one system call without copying it to a single buffer.
by mgaunard 10mo ago
you can already send fragmented data in one system call without copying it to a single buffer.
- rwmj 10mo agoIndeed you can, but we've found it useful to use MSG_MORE when using state machines, where different states are responsible for different parts of the reply. (Plenty of examples in states*.c here: https://gitlab.com/nbdkit/libnbd/-/tree/master/generator?ref_type=heads https://gitlab.com/nbdkit/libnbd/-/tree/master/generator?ref...)
- mgaunard 10mo agoDoing more system calls isn't really a good idea for performance. Also if you're doing asynchronous writes you typically can only have one write in-flight at any time, you should aggregate all other buffers while that happens. Though arguably asynchronous writes are often undesired due to the complexity of doing flow-control with them.
- mgaunard 10mo agoActually, with newer Linux kernels and io_uring, it appears it is now possible to do multiple writes asynchronously concurrently, by annotating each one with a sequencing constraint. Whether that's really useful or not depends on whether you do the associated buffer management work.
- zamalek 10mo agoConsider using a user-space buffer instead, syscalls are slow so bonus points for limiting them are on the table. If you want to avoid resizing an array have a look at the vectored io syscalls (readv etc.).