FileDesc should override Read::initializer() #53980
Labels
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
As it is, due to a comedy of errors, code like
Command::new("head").arg("-c").arg("100000000").arg("/dev/zero").output()
is accidentally quadratic if rust reads fast enough to drain the stdout pipe, whileCommand::new("head").arg("-c").arg("100000000").arg("/dev/zero").stderr(Stdio::null()).output()
is fine.Since the first command has to listen to both stdout and stderr, it calls read2 and winds up looping around pipe + read_to_end, and each read_to_end call reinitializes the buffer again and again. An override of initializer() would skip this, or I suppose there could be some extra special casing so that the read_to_end state isn't lost during poll, but that seems like more work.
I think windows avoids this entirely, but the commented-out select-based read2 impl in redox would also want this for redox's FileDesc.
The text was updated successfully, but these errors were encountered: