Subject: bug#18626: 24.3.94; communication with subprocess is slow

From: Stephen Leake <[email-masked]>
Date: Sat, 04 Oct 2014 03:11:26 -0500

As Eli suggested, I tried changing the pipe buffer size in w32.c pipe2,
and the delay in process.c send_process, call to
wait_reading_process_output.

The pipe buffer size should affect reading from the subprocess, but it
doesn't change the timing significantly:

(pipe-torture-read "/Projects/emacs/emacs-24.3.94/src/xdisp.c")

size                time
------------------------
0 (uses OS default) 11.965184
9192                12.012684
80000               12.018934

The send_process time delay is the cause of the slowdown in write:

(find-file "xdisp.c")
(pipe-torture "debug.exe" "4096")

delay               time
------------------------
20 * 1000 * 1000    4.450068
10 * 1000 * 1000    2.443788
 0 * 1000 * 1000    hangs until C-g

xdisp.c has 974233 bytes; with a subprocess read buffer of 4096 and a
delay of 0.020 seconds, that gives a send time of (* 0.020 (/ 974233
4096)) = 4.74, which is close to what we see above.

One way around the write delay is to use a large enough read buffer in
the subprocess. In my current real application, this is easy and also
gives other benefits.

I'm not clear why Emacs hangs with a delay of 0. The subprocess should
be running on a separate CPU core, so even if the Emacs process is in a
busy wait loop, the subprocess should read input.

-- 
-- Stephe