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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 04 Oct 2014 11:32:00 +0300

> From: Stephen Leake <[email-masked]>
> Date: Sat, 04 Oct 2014 03:11:26 -0500
> 
> 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.

Did you try with 5 msec instead of zero?

Anyway, for 24.4 all I can suggest is a variable to replace the fixed
20 msec value.  Doing anything more complicated than that would be too
dangerous this late into the pretest.