unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
Cc: emacs-devel@gnu.org
Subject: Re: What's the problem?
Date: 10 Dec 2003 16:19:11 +0900	[thread overview]
Message-ID: <buofzftuols.fsf@mcspd15.ucom.lsi.nec.co.jp> (raw)
In-Reply-To: <ilullpl2nay.fsf@latte.josefsson.org>

Simon Josefsson <jas@extundo.com> writes:
> I'm using the Agent in recent Gnus, so almost all data is locally
> cached (except for flag updates via IMAP and new-mail checks in NNTP),
> so for me the delays I see are mostly CPU bound.

Not sure about agent mode -- the last time I tried it, it was so
completely awful that I quickly stopped.

> > What I'm trying to say is that the `threading support' need not be
> > particularly good, or general-purpose.  Probably something could be
> > hacked up right _now_, without any additional core functions, using
> > clever programming and emacs timers, by changing the worst-offending
> > part of the gnus code into something event driven.
> 
> I don't understand.  How would making the summary buffer generation
> asynchronous stop Emacs from locking up during computations?  For me,
> the summary buffer generation is CPU bound in elisp, not IO bound.

Yes, I understand.  I'd guess that a typical very long computation in
gnus is probably in the form of loops that do something fairly simple
many, many times, with other shorter calculations between them.  So
you'd like gnus to somehow yield cpu time for the user every iteration,
or every 100 iterations, or something like that.  In a cooperative
multi-tasking system, you'd just stick in a (yield) or something, but in
emacs this would be very hard to support.

So, instead, lets say you have a function like:

   (define gnus-fill-in-summary-buffer (...)
     (let (...some bindings...)
       (do-some-fairly-quick-calculation)
       (dolist (var1 potentially-big-long-list-1)
         ...something-1...)
       (dolist (var2 potentially-big-long-list)
         ...something-2...)))

change it into something like:

   (define gnus-fill-in-summary-buffer (...)
     (let ((some-state ...))
       (do-some-fairly-quick-calculation)
       (with-background-queue (bgq some-state)
         (bgq-dolist (var1 potentially-big-long-list-1 bgq)
            ...something-1...)
         (bgq-dolist (var2 potentially-big-long-list-2 bgq)
            ...something-2...))))

where `with-background-queue' and `bgq-dolist' (1) just package up their
body code into lambda(s), [effectively] shove them on the end of some
queue in bgq, and return immediately, and (2) explicitly refuse to make
any guarantees about non-global bindings; the value here called
`some-state' is stashed away in bgq somewhere, and can be used to
communicate values internal to the calculation.

IOW, it's annoying for the gnus programmer, but very easy for the emacs
implementation.

Some questions are (1) are there only a few points within gnus that
represent most of the annoying delays (2) do these places have fairly
simple code structures that could be split up into pieces like the above
example, and (3) do these pieces not depend on the long-term consistency
of any global state.

> I think there are two separate problems here.  They can and need to be
> solved individually.

I don't know.  A framework like the above could pretty simply handle the
I/O bound portion too, though.

-Miles
-- 
`To alcohol!  The cause of, and solution to,
 all of life's problems' --Homer J. Simpson

  reply	other threads:[~2003-12-10  7:19 UTC|newest]

Thread overview: 133+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-16 21:46 Are there plans for a multi-threaded Emacs? Frank Schmitt
2003-11-17  0:49 ` Alex Schroeder
2003-11-17  4:06   ` Dhruva Krishnamurthy
2003-11-17  4:29     ` Miles Bader
2003-11-30 16:36       ` Kai Grossjohann
2003-11-30 18:01         ` Vinicius Jose Latorre
2003-11-30 18:39           ` Kai Grossjohann
2003-11-30 18:12         ` Benjamin Riefenstahl
2003-11-30 19:40         ` Nic Ferrier
2003-12-01 16:04         ` Ted Zlatanov
2003-12-02 14:45           ` Ted Lemon
2003-12-02 15:48             ` Per Abrahamsen
2003-12-02 17:18               ` David Kastrup
2003-12-03 12:38                 ` Per Abrahamsen
2003-12-02 17:27               ` Stefan Monnier
2003-12-02 18:53                 ` Simon Josefsson
2003-12-03 13:03                   ` Per Abrahamsen
2003-12-02 17:44             ` Ted Zlatanov
2003-12-03 17:16           ` Richard Stallman
2003-12-03 17:58             ` Ted Zlatanov
2003-12-03 23:38               ` Martin Stjernholm
2003-12-04 13:05                 ` Ted Zlatanov
2003-12-04 14:07                   ` David Kastrup
2003-12-04 14:58                     ` Nic Ferrier
2003-12-04 15:44                       ` David Kastrup
2003-12-04 16:17                     ` Kim F. Storm
2003-12-04 15:58                       ` Nic Ferrier
2003-12-04 16:26                         ` non-blocking sockets (was Re: Are there plans for a multi-threaded Emacs?) Nic Ferrier
2003-12-05 11:35                           ` Kim F. Storm
2003-12-04 19:55                       ` Are there plans for a multi-threaded Emacs? Ted Zlatanov
2003-12-04 20:30                         ` Stefan Monnier
2003-12-04 20:58                           ` Ted Zlatanov
2003-12-04 22:49                             ` Stefan Monnier
2003-12-05 12:17                               ` Ted Zlatanov
2003-12-05 13:06                                 ` Thien-Thi Nguyen
2003-12-05 14:44                                 ` David Kastrup
2003-12-07 23:55                                 ` Stefan Monnier
2003-12-08 16:54                                   ` Ted Zlatanov
2003-12-08 17:09                                     ` David Kastrup
2003-12-08 18:10                                       ` Ted Zlatanov
2003-12-08 22:02                                       ` Martin Stjernholm
2003-12-08 18:25                                     ` What's the problem? (Was: Are there plans for a multi-threaded Emacs?) Luke Gorrie
2003-12-08 19:56                                       ` Ted Zlatanov
2003-12-08 20:56                                         ` David Kastrup
2003-12-08 22:09                                           ` Martin Stjernholm
2003-12-08 21:01                                         ` Stefan Monnier
2003-12-08 19:57                                       ` What's the problem? Simon Josefsson
2003-12-09 23:45                                         ` Juri Linkov
2003-12-10  0:58                                           ` Simon Josefsson
2003-12-10  4:35                                             ` Miles Bader
2003-12-10  5:38                                               ` Simon Josefsson
2003-12-10  5:51                                                 ` Miles Bader
2003-12-10  6:34                                                   ` Simon Josefsson
2003-12-10  7:19                                                     ` Miles Bader [this message]
2003-12-11 14:12                                                       ` Stefan Monnier
2003-12-11 23:09                                                         ` Miles Bader
2003-12-12 23:55                                                         ` Richard Stallman
2003-12-13 16:11                                                           ` Eli Zaretskii
2003-12-13 17:29                                                             ` Jan D.
2003-12-13 17:35                                                             ` David Kastrup
2003-12-14  6:17                                                               ` Eli Zaretskii
2003-12-14 11:55                                                                 ` David Kastrup
2003-12-14 14:27                                                                   ` Eli Zaretskii
2003-12-14 10:18                                                             ` Richard Stallman
2003-12-10  8:18                                                     ` Eli Zaretskii
2003-12-11 14:45                                                       ` Richard Stallman
2003-12-10 15:36                                                 ` Ted Zlatanov
2003-12-11  1:46                                                   ` Miles Bader
2003-12-12 23:54                                                     ` Richard Stallman
2003-12-11 18:39                                                 ` Ted Zlatanov
2003-12-11 18:48                                                 ` Ted Zlatanov
2003-12-12  3:27                                                   ` Luke A. Olbrish
2003-12-12  3:57                                                     ` Miles Bader
2003-12-13 15:17                                                       ` Richard Stallman
2003-12-13  4:08                                                 ` Miles Bader
2003-12-13 23:14                                                   ` Richard Stallman
2003-12-14 13:12                                                   ` Emacs kill buffer Camm Maguire
2003-12-09 19:28                                       ` What's the problem? (Was: Are there plans for a multi-threaded Emacs?) Ted Zlatanov
2003-12-09 22:02                                         ` David Kastrup
2003-12-10  0:13                                           ` Stefan Monnier
2003-12-10  1:41                                             ` David Kastrup
2003-12-10  2:49                                               ` Stefan Monnier
2003-12-12  0:44                                                 ` Martin Stjernholm
2003-12-10  0:45                                           ` Martin Stjernholm
2003-12-10  2:55                                             ` Stefan Monnier
2003-12-09 19:32                                       ` Ted Zlatanov
2003-12-09 22:13                                         ` Stefan Monnier
2003-12-10 15:16                                       ` Ted Zlatanov
     [not found]                                         ` <E1AUS6B-0006KH-Hq@fencepost.gnu.org>
     [not found]                                           ` <4ny8tjryy8.fsf@collins.bwh.harvard.edu>
     [not found]                                           ` <4nn09xm68c.fsf@collins.bwh.harvard.edu>
2003-12-13 23:15                                             ` What's the problem? Richard Stallman
2003-12-14  3:21                                               ` Martin Stjernholm
2003-12-05  8:58                             ` Are there plans for a multi-threaded Emacs? Thien-Thi Nguyen
2003-12-05 11:58                               ` Ted Zlatanov
2003-12-05 12:12                               ` Ted Zlatanov
2003-12-05 20:37                                 ` Luke A. Olbrish
2003-12-05 21:45                                   ` Ted Zlatanov
2003-12-08  0:10                                   ` Stefan Monnier
2003-12-08  1:26                                     ` Luke A. Olbrish
2003-12-04 17:22                   ` Martin Stjernholm
2003-12-04 18:01                     ` David Kastrup
2003-12-04 18:31                       ` Martin Stjernholm
2003-12-04 19:26                         ` David Kastrup
2003-12-04 22:05                           ` Martin Stjernholm
2003-12-04 20:18                     ` Ted Zlatanov
2003-12-04 23:00                       ` Martin Stjernholm
2003-12-05 12:06                         ` Ted Zlatanov
2003-12-05 13:16                           ` Martin Stjernholm
2003-12-05 21:30                             ` Ted Zlatanov
2003-12-05 14:46                           ` David Kastrup
2003-12-05 15:07                             ` Martin Stjernholm
2003-12-05 13:56                       ` Benjamin Riefenstahl
2003-12-05 21:33                         ` non-blocking auto-save (was: Are there plans for a multi-threaded Emacs?) Ted Zlatanov
2003-12-03 20:01             ` Are there plans for a multi-threaded Emacs? Nic Ferrier
2003-12-03 20:29               ` Stefan Monnier
2003-12-03 21:42                 ` Robert J. Chassell
2003-12-04  7:33                   ` Richard Stallman
2003-12-04 15:37                     ` Stefan Monnier
2003-12-04 18:06                       ` Thien-Thi Nguyen
2003-12-04  7:33                 ` Richard Stallman
2003-12-04 13:14                   ` Ted Zlatanov
2003-12-04 15:41                   ` Stefan Monnier
2003-12-06 20:58       ` Kai Grossjohann
2003-12-07  0:15         ` Thien-Thi Nguyen
2003-12-07 14:52           ` Kai Grossjohann
2003-12-07 16:58             ` Thien-Thi Nguyen
2003-12-07  4:16         ` Martin Stjernholm
2003-12-07 14:53           ` Kai Grossjohann
2003-12-07 23:00             ` Martin Stjernholm
2003-11-17 19:31 ` Richard Stallman
2003-11-17 22:53   ` David Masterson
2003-11-18  5:57     ` Miles Bader
2003-11-20 19:19       ` David Masterson
2003-11-22 21:19         ` Richard Stallman
2003-11-18  6:52     ` John Wiegley

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=buofzftuols.fsf@mcspd15.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=emacs-devel@gnu.org \
    --cc=miles@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).