From: David.Kastrup@t-online.de (David Kastrup)
Cc: emacs-devel@gnu.org
Subject: Re: Any idea about what makes Emacs slow reading on pipes?
Date: 17 May 2003 02:34:17 +0200 [thread overview]
Message-ID: <x5vfwae7hy.fsf@lola.goethe.zz> (raw)
In-Reply-To: <5x1xyye3y4.fsf@kfs2.cua.dk>
storm@cua.dk (Kim F. Storm) writes:
> David.Kastrup@t-online.de (David Kastrup) writes:
> So I do see the "1 byte" reads, but not the slowness.
Fine for you.
> > I don't know _what_ Emacs does do the pipe/pty that causes only single
> > characters to gather/be processed, with a sporadic 1024 packet getting
> > through from time to time, but I hate it. Some setting must be on the
> > pipe that causes the writer to stall before further writes in many
> > cases until Emacs has read the next character. And after some time
> > the pipe gets filled properly now and then, with single characters in
> > between.
> >
> > I don't get it.
>
> Well, it seems that emacs is FAST enough the keep up with your dd
> which actually only writes 1 byte at a time, so basically if your
> program writes 1 char at a time, emacs will read 1 char at a time if
> it can keep up...
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). 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.
> 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. The dd was explicitly there to force small writes,
since that is the most common situation when talking with
applications through a pipe. And that is what makes Emacs dog slow
when compared with XEmacs when running things like TeX from within
AUCTeX.
> Based on this, I would conclude that emacs is behaving _correctly_
> for the input you supply it.
Well, it certainly does receive and process all bytes, so of _course_
it is behaving `correctly'. But it causes dd and perhaps Linux to
crawl. I am not interested in assigning a culprit, but the fact
remains that the implementation causes awful performance. Part of the
reason is that Emacs does a lot of partly excessively looking overhead
for every accept-process-output or related call (like sit-for). But
improving that would not pay off even remotely as well as having a way
to let the pipe have better utilization. If Emacs could find a way
_not_ to let Linux wake it up until the writing process either is
regularly preempted, or has the pipe filled, or is waiting for
something other, this would greatly benefit performance by causing
Emacs to work on more useful batches than just single characters.
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.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
next prev parent reply other threads:[~2003-05-17 0:34 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 [this message]
2003-05-18 0:31 ` Kim F. Storm
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=x5vfwae7hy.fsf@lola.goethe.zz \
--to=david.kastrup@t-online.de \
--cc=dak@gnu.org \
--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 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).