Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileDesc should override Read::initializer() #53980

Closed
talchas opened this issue Sep 6, 2018 · 1 comment
Closed

FileDesc should override Read::initializer() #53980

talchas opened this issue Sep 6, 2018 · 1 comment
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.

Comments

@talchas
Copy link

talchas commented Sep 6, 2018

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, while
Command::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.

@fbernier
Copy link
Contributor

fbernier commented Sep 6, 2018

#53981

@Centril Centril added 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. labels Sep 7, 2018
@sfackler sfackler closed this as completed Sep 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

4 participants