Skip to content

Commit

Permalink
Rollup merge of rust-lang#95782 - ChrisDenton:pipe-buffer-size, r=thomcc
Browse files Browse the repository at this point in the history
Windows: Increase a pipe's buffer capacity to 64kb

This brings it inline with typical Linux defaults: https://www.man7.org/linux/man-pages/man7/pipe.7.html

> Since Linux 2.6.11, the pipe capacity is 16 pages (i.e., 65,536 bytes in a system with a page size of 4096 bytes).

This may also help with rust-lang#45572 and rust-lang#95759 but does not fix either issue. It simply makes them much less likely to be encountered.
  • Loading branch information
Dylan-DPC committed Apr 8, 2022
2 parents 1f80881 + 6a4b444 commit fdfdb33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/std/src/sys/windows/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub struct Pipes {
/// with `OVERLAPPED` instances, but also works out ok if it's only ever used
/// once at a time (which we do indeed guarantee).
pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Result<Pipes> {
// A 64kb pipe capacity is the same as a typical Linux default.
const PIPE_BUFFER_CAPACITY: u32 = 64 * 1024;

// Note that we specifically do *not* use `CreatePipe` here because
// unfortunately the anonymous pipes returned do not support overlapped
// operations. Instead, we create a "hopefully unique" name and create a
Expand Down Expand Up @@ -91,8 +94,8 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
| c::PIPE_WAIT
| reject_remote_clients_flag,
1,
4096,
4096,
PIPE_BUFFER_CAPACITY,
PIPE_BUFFER_CAPACITY,
0,
ptr::null_mut(),
);
Expand Down

0 comments on commit fdfdb33

Please sign in to comment.