Skip to content

FileDesc should override Read::initializer() #53980

Closed
@talchas

Description

@talchas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-slowIssue: Problems and improvements with respect to performance of generated code.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions