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

Optimize some functions in std::process #31618

Merged
merged 3 commits into from
Mar 10, 2016

Commits on Mar 9, 2016

  1. std: Funnel read_to_end through to one location

    This pushes the implementation detail of proxying `read_to_end` through to
    `read_to_end_uninitialized` all the way down to the `FileDesc` and `Handle`
    implementations on Unix/Windows. This way intermediate layers will also be able
    to take advantage of this optimized implementation.
    
    This commit also adds the optimized implementation for `ChildStdout` and
    `ChildStderr`.
    alexcrichton committed Mar 9, 2016
    Configuration menu
    Copy the full SHA
    d46c99a View commit details
    Browse the repository at this point in the history
  2. std: Don't always create stdin for children

    For example if `Command::output` or `Command::status` is used then stdin is just
    immediately closed. Add an option for this so as an optimization we can avoid
    creating pipes entirely.
    
    This should help reduce the number of active file descriptors when spawning
    processes on Unix and the number of active handles on Windows.
    alexcrichton committed Mar 9, 2016
    Configuration menu
    Copy the full SHA
    6afa32a View commit details
    Browse the repository at this point in the history
  3. std: Don't spawn threads in wait_with_output

    Semantically there's actually no reason for us to spawn threads as part of the
    call to `wait_with_output`, and that's generally an incredibly heavyweight
    operation for just reading a few bytes (especially when stderr probably rarely
    has bytes!). An equivalent operation in terms of what's implemented today would
    be to just drain both pipes of all contents and then call `wait` on the child
    process itself.
    
    On Unix we can implement this through some convenient use of the `select`
    function, whereas on Windows we can make use of overlapped I/O. Note that on
    Windows this requires us to use named pipes instead of anonymous pipes, but
    they're semantically the same under the hood.
    alexcrichton committed Mar 9, 2016
    1 Configuration menu
    Copy the full SHA
    7c3038f View commit details
    Browse the repository at this point in the history