all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Any idea about what makes Emacs slow reading on pipes?
Date: 18 May 2003 02:31:34 +0200	[thread overview]
Message-ID: <5xznllw0wp.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <x5vfwae7hy.fsf@lola.goethe.zz>

David.Kastrup@t-online.de (David Kastrup) writes:

> No, that isn't it.  I can pipe the stuff into |cat >/dev/null instead
> of Emacs, and it will be finished in a whiffy.  Emacs must be using
> some sort of system call that _stops_ dd most of the time from being
> able to so another write to the pipe until the Linux scheduler has run
> again (which it does at the rate of about 100 per second, almost
> exactly the rate at which characters arrive).  

That is because emacs is using a pty by default for process i/o (I
guess that is to avoid buffering output from the writer, so emacs will
get a more steady flow of input to process, e.g. for compiler output),
and it sets the pty to non-blocking mode when reading from the pty 
(to avoid having emacs hanging on the read system call until it has
successfully read all 1024 bytes).

The combined effect is that the write (such as tex) will use
un-buffered writes, and emacs will use non-blocing reads, effectively
using as small data units between writer and reader as possible.

If you just do your-command | cat > /dev/null, your-command will
most likely do buffered i/o, so it will surely run faster.

>                                                I am not saying that
> the current Linux kernel might not play its part in the catastrophic
> performance here, but the fact is that substituting different readers
> for Emacs on the delivering pipe yields in vast performance gains of
> the _writing_ process.
> 
> > What happens if you try the following version, which forces
> > start-process to use a pipe rather than a pty:
> 
> Nothing much, I said already.

Well, it could have an effect for your ACUTeX case, since it would
then be writing to a pipe (using buffered i/o) rather than to a pty
(typically using non-buffered i/o).

> > But if you really want to speed up things, use a block size
> > of 1k like this:
> 
> > 	       "-c" "hexdump -v /dev/zero|dd bs=1k count=100")
> 
> Oh, come on.  

Come on yourself...  This illustrates that if you use
        "tex ... | dd bs=1k"
instead of just
        "tex ..."
in acutex, you'll probably end up with much faster performance
since you will get buffered output from tex.

But you should get the same effect by setting process-connection-type
to nil.


>               The dd was explicitly there to force small writes,
> since that is the most common situation when talking with
> applications through a pipe.  

I would expect that for a pty, not for a pipe!

>                               And that is what makes Emacs dog slow
> when compared with XEmacs when running things like TeX from within
> AUCTeX.

Maybe Xemacs is using pipes rather than ptys by default (or never use
pty's at all)...

> 
> We are having here an operating system with a single CPU, and we
> switch processes here for every byte mainly, and the producing process
> gets no CPU time for making new bytes while the consuming process is
> still busy processing the byte it got.  Anyhow, I _do_ have the
> additional suspicion that there is pretty much one "tick" of delay for
> every of byte involved and that the CPU is mostly idling for that
> reason: a 600MHz PIII should even with the full processing overhead
> due to catering for every single character on its own be able to
> handle more than 100 characters per second.

Could you try

        M-: (setq process-connection-type nil)

before you run your acutex process, and see if that makes a difference.

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

  reply	other threads:[~2003-05-18  0:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-16 13:08 Any idea about what makes Emacs slow reading on pipes? David Kastrup
2003-05-16 13:55 ` Andreas Schwab
2003-05-16 17:18 ` Kevin Rodgers
2003-05-16 17:34   ` David Kastrup
2003-05-16 18:38     ` Kevin Rodgers
2003-05-16 18:49       ` David Kastrup
2003-05-16 17:48 ` Jan D.
2003-05-16 18:38   ` David Kastrup
2003-05-16 20:23     ` Jan D.
2003-05-16 21:00     ` Andreas Schwab
2003-05-16 23:17     ` Satyaki Das
2003-05-17  1:50     ` Kim F. Storm
2003-05-17  0:34       ` David Kastrup
2003-05-18  0:31         ` Kim F. Storm [this message]
2003-05-17 23:07           ` Stefan Monnier
2003-05-17 23:39           ` David Kastrup
2003-05-18  2:09             ` Stefan Monnier
2003-05-18  8:45             ` Kai Großjohann
2003-05-18 10:12               ` David Kastrup
2003-05-18 19:04               ` Richard Stallman
2003-05-18 19:46                 ` David Kastrup
2003-05-19  7:33                   ` Kai Großjohann
2003-05-19  8:24                     ` David Kastrup
2003-05-18  8:46             ` Kai Großjohann
2003-05-18 10:03               ` David Kastrup
2003-05-18 15:09                 ` Kai Großjohann
2003-05-18 15:36                   ` David Kastrup
2003-05-18 15:50                     ` Kai Großjohann
2003-05-18 16:28                       ` David Kastrup
2003-05-19  7:26                         ` Kai Großjohann
2003-05-19  8:09                           ` David Kastrup
2003-05-18 19:03           ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5xznllw0wp.fsf@kfs2.cua.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.