From 64d292d7a028b2a962c97c60fbefa15b5cca338d Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Sun, 17 Mar 2019 22:10:40 +0300 Subject: [PATCH] win: Increase communication buffers size (#412) Currently the size of reading buffer is 16KiB while the the pipe buffer is of system default size which seems to be 8KiB on Win7. Because of this the half of the reading buffer is never used. Also, recent Windows updates with Meltdown mitigation made syscalls more expensive, and increasing the buffer size will lower the syscalls count. --- src/engine/execnt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/execnt.c b/src/engine/execnt.c index 2f213bf5e..b456791db 100644 --- a/src/engine/execnt.c +++ b/src/engine/execnt.c @@ -112,6 +112,9 @@ static void register_wait( int job_id ); */ #define MAX_RAW_COMMAND_LENGTH 32766 + /* Communication buffers size */ +#define IO_BUFFER_SIZE ( 64 * 1024 ) + /* We hold handles for pipes used to communicate with child processes in two * element arrays indexed as follows. */ @@ -497,14 +500,14 @@ static void invoke_cmd( char const * const command, int const slot ) /* Create pipes for communicating with the child process. */ if ( !CreatePipe( &cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_READ ], - &cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_WRITE ], &sa, 0 ) ) + &cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_WRITE ], &sa, IO_BUFFER_SIZE ) ) { reportWindowsError( "CreatePipe", slot ); return; } if ( globs.pipe_action && !CreatePipe( &cmdtab[ slot ].pipe_err[ EXECCMD_PIPE_READ ], &cmdtab[ slot ].pipe_err[ EXECCMD_PIPE_WRITE ], - &sa, 0 ) ) + &sa, IO_BUFFER_SIZE ) ) { reportWindowsError( "CreatePipe", slot ); return; @@ -749,8 +752,6 @@ static void record_times( HANDLE const process, timing_info * const time ) } -#define IO_BUFFER_SIZE ( 16 * 1024 ) - static char ioBuffer[ IO_BUFFER_SIZE + 1 ]; #define FORWARD_PIPE_NONE 0