unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Emacs design and architecture. How about copy-on-write?
@ 2023-09-21  9:43 Payas Relekar
  0 siblings, 0 replies; 154+ messages in thread
From: Payas Relekar @ 2023-09-21  9:43 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, dmitry, yantar92, acm, incal, emacs-devel

Po Lu <luangruo@yahoo.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> Then try leaning on C-n or C-p _after_ everything is already
>> fontified.  You will still see that Emacs sometimes cannot keep up,
>> especially if lines are not too short.
>
> Long lines are, at worst, infrequently encountered in source code,

Long lines are frequently encountered in prose like say Org-mode, that
might require font lock extensively, depending on the document.



^ permalink raw reply	[flat|nested] 154+ messages in thread
* Re: Emacs design and architecture. How about copy-on-write?
@ 2023-09-20 20:51 zhanghj
  0 siblings, 0 replies; 154+ messages in thread
From: zhanghj @ 2023-09-20 20:51 UTC (permalink / raw)
  To: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

    The same will happen if only the main thread can display.  If a
    non-main thread wants to prompt the user, it will have to wait until
    the main thread becomes available, prompts the user, and returns the
    response.

    Someone always has to wait when threads need to synchronize.  There's
    no way around that.  Doing this in the thread that needs to
    display/prompt is easier because the context and relevant variables
    don't need to be communicated to another thread.

Sorry for my poor English.

Message queue is a good solution for parallel and concurrence.

I think it is not a good idea to let all threads to do display things directly.
It will be better to let non-main threads to do display things via message queue,
like many GUI toolkit does. It is also like the message loop in Emacs.
This will make many things easier.

For GUI toolkit on windows, there are two basic API: Sendmessage and PostMessage.
Non-gui thread can use theme to do display and UI related things.

For example in Emacs, when a non-main thread calls `message', a small display task is built
and put into the message queue of the main thread, like `PostMessage` does.
If it calls `read-file-name`, an UI task is built and put into the message queue of
the main thread like `SendMessage` does, while the caller thread will be blocked until result comes.

When all display jobs are all in one thread (decoupled with other threads), display jobs may be scheduled
more efficiently and may be concurrent internally.

[-- Attachment #2: Type: text/html, Size: 1685 bytes --]

^ permalink raw reply	[flat|nested] 154+ messages in thread
* Re: Emacs design and architecture
@ 2023-09-15  9:32 Gerd Möllmann
  2023-09-15 15:52 ` Dmitry Gutov
  0 siblings, 1 reply; 154+ messages in thread
From: Gerd Möllmann @ 2023-09-15  9:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Yuri Khan, dmitry, owinebar, rms, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Yuri Khan <yuri.v.khan@gmail.com>
>> Date: Fri, 15 Sep 2023 13:51:56 +0700
>> Cc: Dmitry Gutov <dmitry@gutov.dev>, owinebar@gmail.com, rms@gnu.org, emacs-devel@gnu.org
>> 
>> On Fri, 15 Sept 2023 at 12:51, Eli Zaretskii <eliz@gnu.org> wrote:
>> 
>> > One of the important aspects to keep in mind in this regard is that
>> > Emacs must give Lisp programs dynamic control of how stuff is
>> > displayed, and should be able to exercise that control at high
>> > frequency (a trivial example: pulse.el).
>> 
>> In CSS, this is solved in core with transitions. A style specifies
>> that a certain property will change gradually, provides its target
>> value, the transition duration, and a transition curve.
>
> You have taken the pulse.el example too literally.  The fact that it
> changes the color gradually is not relevant to the point I was trying
> to make, but you made it the main point.
>
> My point is that quite a few Lisp programs affect the display in
> near-real time and at high frequency.  This is what makes Emacs so
> powerful, and we don't want to lose this power when changing the
> display engine.
>
>> The use case of pulse.el would be translated to a couple of styles
>> that say effectively “A pulsed span will instantly gain yellow
>> background” and “A non-pulsed span will linearly revert to whatever
>> background it had over the course of 200 milliseconds” and a small
>> function that sets the span to pulsed and then immediately to
>> non-pulsed.
>
> This sounds like a lot of hair, when a Lisp program just wants to
> change the color of some part of the display.
>
>> (Implementing a CSS engine over a character terminal is a nontrivial
>> matter though.)
>
> Something else to keep in mind, I guess.  TTY colors are implemented
> specially and separately in Emacs (under the hood; Lisp programs can
> disregard the differences if they want), so it isn't a non-starter,
> per se.

I think it would maybe be good to think about the following:

Random thoughts about a parallel redisplay, from a height of 10 km.

What currently happens to bring changes to the screen is that redisplay
is called quite frequently in the course of processing input for
example.  Redisplay determines what part of the a "model" (buffer) has
changed, if any.  It makes sure that all info it needs to proceed is
available; think jit-lock, i.e. it calls Lisp. Because redisplay is
called frequently, it must minimize what it does, which is the reason
for the complicated optimizations there.

Whatever is done in the end, I think it would first be necessary to
change this general principle, so that layout/drawing whatever can
happen in parallel.  Without that, I suspect redisplay would get too
slow, or would finally collapse to a black hole by its complexity.

This of course, would pose several problems.

- This form of parallel redisplay cannot call Lisp, so no jit-lock, no
  hooks, or whatever during redisplay.  And at the point where we call
  redisplay today we don't know what will be displayed...
- Parallel redisplay also needs either a copy of what it to be
  displayed, or the model must be some persistent data structure
  that makes immutable versions of buffer-text, for instance,
  available.



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

end of thread, other threads:[~2023-09-24  0:29 UTC | newest]

Thread overview: 154+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21  9:43 Emacs design and architecture. How about copy-on-write? Payas Relekar
  -- strict thread matches above, loose matches on Subject: below --
2023-09-20 20:51 zhanghj
2023-09-15  9:32 Emacs design and architecture Gerd Möllmann
2023-09-15 15:52 ` Dmitry Gutov
2023-09-15 18:36   ` Gerd Möllmann
2023-09-15 18:42     ` Eli Zaretskii
2023-09-15 19:19       ` Gerd Möllmann
2023-09-15 22:20         ` Dmitry Gutov
2023-09-15 23:58           ` Emanuel Berg
2023-09-16  6:00             ` Eli Zaretskii
2023-09-17 12:16               ` Emanuel Berg
2023-09-17 14:24                 ` Eli Zaretskii
2023-09-17 15:36                   ` Emacs design and architecture. How about copy-on-write? Alan Mackenzie
2023-09-18 10:30                     ` Eli Zaretskii
2023-09-18 11:38                       ` Alan Mackenzie
2023-09-18 12:08                         ` Eli Zaretskii
2023-09-18 12:49                           ` Ihor Radchenko
2023-09-18 14:27                             ` Eli Zaretskii
2023-09-18 15:55                               ` Ihor Radchenko
2023-09-18 17:47                                 ` Eli Zaretskii
2023-09-18 22:48                                   ` Emanuel Berg
2023-09-19 10:53                                     ` Eli Zaretskii
2023-09-19 11:14                                       ` Emanuel Berg
2023-09-19 12:37                                         ` Ihor Radchenko
2023-09-19 19:21                                           ` Emanuel Berg
2023-09-20  9:56                                             ` Ihor Radchenko
2023-09-22 15:50                                               ` Emanuel Berg
2023-09-22 16:15                                                 ` Ihor Radchenko
2023-09-22 16:22                                                   ` Emanuel Berg
2023-09-22 18:08                                                   ` Eli Zaretskii
2023-09-19 19:34                                           ` Emanuel Berg
2023-09-20  9:59                                             ` Ihor Radchenko
2023-09-20 10:22                                               ` Po Lu
2023-09-20 10:56                                                 ` Ihor Radchenko
2023-09-20 11:11                                                   ` Po Lu
2023-09-20 11:53                                                     ` Ihor Radchenko
2023-09-20 11:58                                                       ` Po Lu
2023-09-20 12:05                                                         ` Ihor Radchenko
2023-09-20 13:35                                                     ` Po Lu
2023-09-20 15:53                                                       ` Eli Zaretskii
2023-09-21  0:55                                                         ` Po Lu
2023-09-21  3:35                                                           ` Po Lu
2023-09-21  7:27                                                           ` Eli Zaretskii
2023-09-21  7:34                                                             ` Po Lu
2023-09-21  8:13                                                               ` Eli Zaretskii
2023-09-21  8:35                                                                 ` Ihor Radchenko
2023-09-21  9:59                                                                   ` Eli Zaretskii
2023-09-21 10:13                                                                     ` Ihor Radchenko
2023-09-21 11:49                                                                       ` Po Lu
2023-09-21 23:43                                                                         ` Dmitry Gutov
2023-09-21 12:57                                                                       ` Eli Zaretskii
2023-09-21 13:12                                                                         ` Po Lu
2023-09-21 13:29                                                                           ` Eli Zaretskii
2023-09-21 13:35                                                                             ` Po Lu
2023-09-21 13:49                                                                               ` Eli Zaretskii
2023-09-21 13:57                                                                                 ` Po Lu
2023-09-21 14:10                                                                                   ` Eli Zaretskii
2023-09-21  9:14                                                                 ` Po Lu
2023-09-22 15:59                                               ` Emanuel Berg
2023-09-19 12:38                                         ` Eli Zaretskii
2023-09-19 12:57                                           ` Po Lu
2023-09-19 14:36                                             ` Eli Zaretskii
2023-09-20  1:05                                               ` Po Lu
2023-09-20 12:02                                                 ` Eli Zaretskii
2023-09-20 12:09                                                   ` Ihor Radchenko
2023-09-20 12:27                                                   ` Po Lu
2023-09-19 19:38                                           ` Emanuel Berg
2023-09-20 12:35                                             ` Eli Zaretskii
2023-09-22 14:22                                               ` Emanuel Berg
2023-09-22 15:51                                                 ` Eli Zaretskii
2023-09-22 16:00                                                   ` Emanuel Berg
2023-09-22 19:00                                                     ` Eli Zaretskii
2023-09-22 21:14                                                       ` Emanuel Berg
2023-09-22 16:11                                                   ` Ihor Radchenko
2023-09-22 16:14                                                     ` Eli Zaretskii
2023-09-22 16:27                                                       ` Ihor Radchenko
2023-09-22 17:19                                                         ` Emanuel Berg
2023-09-22 16:13                                                   ` tomas
2023-09-19 11:36                                   ` Ihor Radchenko
2023-09-19 12:34                                     ` Eli Zaretskii
2023-09-19 13:35                                       ` Ihor Radchenko
2023-09-19 14:14                                         ` Eli Zaretskii
2023-09-19 15:15                                           ` Dmitry Gutov
2023-09-19 15:37                                             ` Eli Zaretskii
2023-09-19 16:01                                               ` Dmitry Gutov
2023-09-19 17:54                                                 ` Eli Zaretskii
2023-09-19 20:21                                                   ` Dmitry Gutov
2023-09-20 11:28                                                     ` Eli Zaretskii
2023-09-20 11:38                                                       ` Ihor Radchenko
2023-09-20 14:35                                                         ` Eli Zaretskii
2023-09-21 10:41                                                           ` Ihor Radchenko
2023-09-21 13:26                                                             ` Eli Zaretskii
2023-09-22 10:05                                                               ` Ihor Radchenko
2023-09-22 11:53                                                                 ` Eli Zaretskii
2023-09-22 12:49                                                                   ` Ihor Radchenko
2023-09-22 13:01                                                                     ` Eli Zaretskii
2023-09-22 13:08                                                                       ` Ihor Radchenko
2023-09-20 12:21                                                       ` Po Lu
2023-09-20 14:51                                                         ` Eli Zaretskii
2023-09-20 19:39                                                           ` Dmitry Gutov
2023-09-21  4:31                                                             ` Eli Zaretskii
2023-09-21 10:41                                                               ` Dmitry Gutov
2023-09-21 22:21                                                             ` Stefan Kangas
2023-09-21 23:01                                                               ` Dmitry Gutov
2023-09-21  0:41                                                           ` Po Lu
2023-09-21  2:23                                                             ` Adam Porter
2023-09-21  2:53                                                               ` Po Lu
2023-09-21  7:25                                                             ` Eli Zaretskii
2023-09-21  7:48                                                               ` Po Lu
2023-09-21  8:18                                                                 ` Eli Zaretskii
2023-09-21  9:25                                                                   ` Po Lu
2023-09-21  9:39                                                                     ` Ihor Radchenko
2023-09-21 10:36                                                                       ` Dmitry Gutov
2023-09-21 10:48                                                                         ` Ihor Radchenko
2023-09-21 11:10                                                                           ` Dmitry Gutov
2023-09-21 11:17                                                                             ` Ihor Radchenko
2023-09-21 11:27                                                                               ` Dmitry Gutov
2023-09-21 13:00                                                                           ` Eli Zaretskii
2023-09-21 13:30                                                                             ` Dmitry Gutov
2023-09-21 13:44                                                                               ` Eli Zaretskii
2023-09-22  1:29                                                                                 ` Dmitry Gutov
2023-09-22 10:51                                                                                   ` Ihor Radchenko
2023-09-22 10:28                                                                                 ` Ihor Radchenko
2023-09-22 12:26                                                                                   ` Eli Zaretskii
2023-09-22 13:06                                                                                     ` Ihor Radchenko
2023-09-22 13:12                                                                                       ` Eli Zaretskii
2023-09-21 10:03                                                                     ` Eli Zaretskii
2023-09-20 19:22                                                       ` Dmitry Gutov
2023-09-21  4:29                                                         ` Eli Zaretskii
2023-09-21 20:24                                                     ` Richard Stallman
2023-09-20  9:47                                           ` Ihor Radchenko
2023-09-20 14:02                                             ` Eli Zaretskii
2023-09-21 10:29                                               ` Ihor Radchenko
2023-09-21 14:02                                                 ` Eli Zaretskii
2023-09-22 10:48                                                   ` Ihor Radchenko
2023-09-22 12:34                                                     ` Eli Zaretskii
2023-09-23 11:07                                                       ` Ihor Radchenko
2023-09-23 11:23                                                         ` Eli Zaretskii
2023-09-23 12:53                                                           ` Dmitry Gutov
2023-09-23 13:01                                                             ` Eli Zaretskii
2023-09-23 13:08                                                               ` Dmitry Gutov
2023-09-23 13:15                                                                 ` Eli Zaretskii
2023-09-23 14:09                                                                   ` Ihor Radchenko
2023-09-24  0:29                                                                   ` Dmitry Gutov
2023-09-23 14:23                                                                 ` Yuri Khan
2023-09-23 14:25                                                                   ` Dmitry Gutov
2023-09-18 13:30                           ` Po Lu
2023-09-18 13:34                             ` Po Lu
2023-09-18 13:55                             ` Ihor Radchenko
2023-09-18 15:04                             ` Eli Zaretskii
2023-09-18 23:41                               ` Po Lu
2023-09-19 14:25                                 ` Eli Zaretskii
2023-09-20  1:01                                   ` Po Lu
2023-09-20 11:56                                     ` Eli Zaretskii
2023-09-20 12:13                                       ` Po Lu
2023-09-20 14:46                                         ` Eli Zaretskii
2023-09-20 18:50                                         ` Dmitry Gutov
2023-09-21  4:23                                           ` Eli Zaretskii
2023-09-21 10:08                                       ` Ihor Radchenko
2023-09-21 10:12                                         ` Eli Zaretskii
2023-09-21 10:35                                           ` Ihor Radchenko
2023-09-21 13:13                                             ` Eli Zaretskii
2023-09-19 21:37                                 ` Björn Bidar
2023-09-19 10:20                     ` Richard Stallman

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).