Several AsyncRead impls unnecessarily zero buffers in prepare_uninitialized_buffer #2308
Labels
A-tokio
Area: The main tokio crate
C-bug
Category: This is a bug.
M-io
Module: tokio/io
M-process
Module: tokio/process
T-performance
Topic: performance and benchmarks
Version
tokio
0.2.13Platform
This is an issue for all platforms.
Subcrates
I haven't reviewed the full source, but I've reviewed
process
and can confirm that theChildStdout
andChildStderr
types are affected.Description
ChildStdout
andChildStderr
implementAsyncRead
by deferring to an internalPollEvented
of a platform specific type: UNIX uses the standard library's child streams withEventedFd
and Windows usesNamedPipe
frommio_named_pipes
.PollEvented
naturally cannot implementprepare_uninitialized_buffer
in any way other than zeroing, due tostd::io::Read::initializer
being unstable, howeverChildStdout
andChildStderr
use well-behaved types internally and should be known not to read from the buffer. Thus, the buffer needs not be initialized andprepare_uninitialized_buffer
should be overwritten for these types to be a no-op.Currently this bug affects me because I cannot call
prepare_uninitialized_buffer
due to the unacceptable zeroing, despite this being part of the contract ofAsyncRead
when an uninitialized buffer is involved. I just have to assume that thetokio
implementation will remain well-behaved.The text was updated successfully, but these errors were encountered: