audit implementation of std.io.poll
#21565
Labels
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
standard library
This issue involves writing Zig code for the standard library.
Milestone
std.io.poll
is implemented by writing the data from each stream to astd.LinearFifo
. However, this implementation is problematic:poll
to be able to allocateLinearFifo
buffer does not have a stable order; incr-check enhancements, and CI for incremental test cases #21518 works around this by queuing the async read to a 1-byte temporary buffer, and performing larger immediate reads to the FIFO when that read completes, but this incurs syscall overheadpoll
wants to process all bytes as soon as they come in, there's no point having a dynamic buffer in the middleFor these reasons, it may be more effective for
poll
to expose a lower-level API.One idea would be for
poll
to read to an internal (or user-supplied) buffer, and forpoll
to directly return this information. For instance, it could return:The user of the API could choose to write
data
toLinearFifo
if this provides a helpful interface. This would allow more flexibility to the user in terms of using, for instance, a statically-sizedLinearFifo
if a small upper bound can be placed on the amount of data that must be buffered at a time.This issue isn't necessary suggesting to go with that exact idea; rather, it is just tracking that this function's implementation/API should be looked at more closely to figure out the optimal API for both users of the standard library and to incur minimal overhead.
The text was updated successfully, but these errors were encountered: