unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: buffering of process output
       [not found] <20030716.123727.83083338.kazu@iijlab.net>
@ 2004-10-10  0:08 ` Kim F. Storm
  2004-10-10 14:09   ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Kim F. Storm @ 2004-10-10  0:08 UTC (permalink / raw)
  Cc: emacs-devel


I have tried your example on gnu/linux, and I can confirm your
findings for CVS emacs under X.  (I don't have 20.7)

But if I try your example with 'emacs -nw', then CVS emacs runs
smoothly too.  Wierd!!!

It seems that the difference in buffering in X vs. -nw is in the call
to emacs_read, i.e. in the call to read.  But 20.7 seems to do exactly
the same calls.

I have yet to find a sensible explanation why CVS emacs buffers output
differently with X.
 
So I wonder if X somehow causes read from a pipe to buffer things
differently [line buffering perhaps] (or the pipe to be setup
differently)?

I also tried to do (set-buffer-multibyte nil) before call-process:

- CVS emacs under X becomes much worse (seems to have to collect 16K
  output before updating)

- CVS emacs -nw still runs smoothly.

So unibyte/multibyte also kicks in somehow...

Ideas anyone ??


Kazu Yamamoto (山本和彦) <kazu@iijlab.net> writes:

> Emacs 21 has a different behavior of buffering of process output from
> Emacs 20.7.
>
> Evaluate the following in the *scratch* buffer
>
> 	(call-process "ping" nil t t "localhost")
>
> On Emacs 20.7, each line is smoothly inserted every second.
>
> On Emacs 21.3.50, however, insertion is awkward.
>
> --Kazu
>
> ----
> In GNU Emacs 21.3.50.1 (i386-unknown-netbsdelf1.6T, X toolkit, Xaw3d scroll bars)
>  of 2003-07-16 on caster.iij.ad.jp
> configured using `configure '--without-xim' '--prefix=/usr/local/emacs21' 'CFLAGS=-I/usr/pkg/include' 'CPPFLAGS=-I/usr/pkg/include -L/usr/pkg/lib' 'LDFLAGS=-R/usr/pkg/lib -L/usr/pkg/lib -R/usr/X11R6/lib -L/usr/X11R6/lib''
>

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: buffering of process output
  2004-10-10  0:08 ` buffering of process output Kim F. Storm
@ 2004-10-10 14:09   ` Andreas Schwab
  2004-10-10 22:36     ` Kim F. Storm
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2004-10-10 14:09 UTC (permalink / raw)
  Cc: Kazu Yamamoto (山本和彦), emacs-devel

storm@cua.dk (Kim F. Storm) writes:

> So I wonder if X somehow causes read from a pipe to buffer things
> differently [line buffering perhaps] (or the pipe to be setup
> differently)?

It doesn't.  It's because there is no call to XFlush during the read loop
in call-process.  See the comment in xterm.c:

/* Remove calls to XFlush by defining XFlush to an empty replacement.
   Calls to XFlush should be unnecessary because the X output buffer
   is flushed automatically as needed by calls to XPending,
   XNextEvent, or XWindowEvent according to the XFlush man page.
   XTread_socket calls XPending.  Removing XFlush improves
   performance.  */

Thus redisplay_preserve_echo_area does not call XFlush any more.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: buffering of process output
  2004-10-10 14:09   ` Andreas Schwab
@ 2004-10-10 22:36     ` Kim F. Storm
  2004-10-11  8:37       ` Kim F. Storm
  0 siblings, 1 reply; 4+ messages in thread
From: Kim F. Storm @ 2004-10-10 22:36 UTC (permalink / raw)
  Cc: Kazu Yamamoto (山本和彦), emacs-devel

Andreas Schwab <schwab@suse.de> writes:

> storm@cua.dk (Kim F. Storm) writes:
>
> It doesn't.  It's because there is no call to XFlush during the read loop
> in call-process.  See the comment in xterm.c:
>
> /* Remove calls to XFlush by defining XFlush to an empty replacement.
>    Calls to XFlush should be unnecessary because the X output buffer
>    is flushed automatically as needed by calls to XPending,
>    XNextEvent, or XWindowEvent according to the XFlush man page.
>    XTread_socket calls XPending.  Removing XFlush improves
>    performance.  */
>
> Thus redisplay_preserve_echo_area does not call XFlush any more.
>
> Andreas.

Thanks for the explanation.  I'll fix that.

-- 
Kim F. Storm  http://www.cua.dk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: buffering of process output
  2004-10-10 22:36     ` Kim F. Storm
@ 2004-10-11  8:37       ` Kim F. Storm
  0 siblings, 0 replies; 4+ messages in thread
From: Kim F. Storm @ 2004-10-11  8:37 UTC (permalink / raw)
  Cc: emacs-devel, )

no-spam@cua.dk (Kim F. Storm) writes:

> Andreas Schwab <schwab@suse.de> writes:
>
>> storm@cua.dk (Kim F. Storm) writes:
>>
>> It doesn't.  It's because there is no call to XFlush during the read loop
>> in call-process.  See the comment in xterm.c:
>>
>> /* Remove calls to XFlush by defining XFlush to an empty replacement.
>>    Calls to XFlush should be unnecessary because the X output buffer
>>    is flushed automatically as needed by calls to XPending,
>>    XNextEvent, or XWindowEvent according to the XFlush man page.
>>    XTread_socket calls XPending.  Removing XFlush improves
>>    performance.  */
>>
>> Thus redisplay_preserve_echo_area does not call XFlush any more.
>>
>> Andreas.
>
> Thanks for the explanation.  I'll fix that.

An explicit flush doesn't fix the problem -- it may have some effect,
but output is still buffered (at least) two lines per update.

I still see cases where the display is not really updated at all
(as if redisplay doesn't see that the display need update).

I'll keep investigating.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-10-11  8:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20030716.123727.83083338.kazu@iijlab.net>
2004-10-10  0:08 ` buffering of process output Kim F. Storm
2004-10-10 14:09   ` Andreas Schwab
2004-10-10 22:36     ` Kim F. Storm
2004-10-11  8:37       ` Kim F. Storm

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).