From: David Kastrup <dak@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: request for review: Doing direct file I/O in Emacs Lisp
Date: 16 May 2004 19:46:43 +0200 [thread overview]
Message-ID: <x5wu3cp8n0.fsf@lola.goethe.zz> (raw)
In-Reply-To: <ud654oovj.fsf@gnu.org>
Eli Zaretskii <eliz@gnu.org> writes:
> > From: David Kastrup <dak@gnu.org>
> > Date: 16 May 2004 00:13:57 +0200
> >
> > The problem is that I/O using "select" is ready the moment a _single_
> > byte is available.
>
> Forgive me for a possibly stupid question, but with applications such
> as `cat' with their stdout redirected to a pipe, shouldn't we have
> `cat' write the pipe in relatively large blocks, as defined by the
> default buffering of its stdout?
cat will probably write in lines when writing to a pseudo tty.
Anyway, it is not as much cat I am concerned with mostly: the most
common problem are applications with small buffer size running in
comint mode.
Running TeX inside of an Emacs buffer is slow, easily 30% slower than
running it in an XTerm. And it is the console I/O that causes this.
> > Perhaps one would need some nicer system calls for telling Linux
> > "ok, wake me up immediately if any pipe is _full_.
>
> Almost full, you mean. If the pipe is full, it's too late, since
> the pipe could be written again before the pipe reader actually
> awakes and runs, in which case you will lose characters at best and
> get SIGPIPE at worst.
I recommend that you look up the semantics of Unix pipes again. You
seem to labor under the delusion that there is a constant race
condition going on. If the pipe is filled, the writing process will
simply get blocked. SIGPIPE is never raised unless the reading
process has _closed_ its end of the pipe, for example by exiting.
> Also, this has complications when the pipe writer exits without
> filling the pipe (which is the normal case).
Again, I don't know what kind of pipes you are talking of here. A
read call on a pipe will block the reader until enough data is
available, or until the writer has closed its end of the pipe.
> > And wake me up immediately if there is input on some of [list of
> > files]. Other than that, only wake me up if there is input and no
> > other process is wanting the CPU". So we'd need to tell the
> > operating system how urgent we want what amount of data on what
> > input to be scheduled for processing.
>
> Sounds like a brutal intervention into the OS scheduler, which most
> systems will not allow.
Intervention? Telling the scheduler where I expect interactive
response, and where I expect batch processing? That is no
"intervention", it is information.
> It's possible that a much simpler solution would be to have a
> separate thread or a helper subprocess read the pipe until a certain
> amount of data is available or a timeout expires, and only then
> present the data to Emacs's process filter/sentinel.
Maybe. If we had some fast preprocessor that would score only a
moderate penalty when the operating system schedules it all the time,
this might help quite a bit.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
next prev parent reply other threads:[~2004-05-16 17:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-10 5:59 request for review: Doing direct file I/O in Emacs Lisp John Wiegley
2004-05-10 6:52 ` Kim F. Storm
2004-05-10 8:27 ` David Kastrup
2004-05-10 14:21 ` Stefan Monnier
2004-05-10 15:59 ` David Kastrup
2004-05-10 16:36 ` Stefan Monnier
2004-05-10 17:00 ` David Kastrup
2004-05-10 17:22 ` Stefan Monnier
2004-05-11 9:23 ` John Wiegley
2004-05-11 10:22 ` David Kastrup
2004-05-10 9:38 ` Andreas Schwab
2004-05-10 11:29 ` Eli Zaretskii
2004-05-10 11:23 ` Andreas Schwab
2004-05-10 15:04 ` Eli Zaretskii
2004-05-10 14:19 ` Stefan Monnier
2004-05-10 17:46 ` Oliver Scholz
2004-05-10 18:21 ` Stefan Monnier
2004-05-10 22:40 ` Oliver Scholz
2004-05-11 12:22 ` Richard Stallman
2004-05-10 17:54 ` Richard Stallman
2004-05-11 9:20 ` John Wiegley
2004-05-12 19:41 ` Richard Stallman
2004-05-13 7:59 ` Kai Grossjohann
2004-05-14 9:21 ` Richard Stallman
2004-05-14 10:42 ` Kai Grossjohann
2004-05-15 8:53 ` Richard Stallman
2004-05-15 16:27 ` Kai Grossjohann
2004-05-16 13:20 ` Richard Stallman
2004-05-14 21:43 ` John Wiegley
2004-05-15 18:33 ` Richard Stallman
2004-05-15 21:36 ` John Wiegley
2004-05-15 22:13 ` David Kastrup
2004-05-16 6:41 ` Eli Zaretskii
2004-05-16 17:46 ` David Kastrup [this message]
2004-05-17 11:04 ` Richard Stallman
2004-05-13 22:50 ` John Wiegley
2004-05-14 21:02 ` 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=x5wu3cp8n0.fsf@lola.goethe.zz \
--to=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).