From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Pip Cet <pipcet@protonmail.com>
Cc: "Pip Cet via \"Emacs development discussions.\""
<emacs-devel@gnu.org>, "Óscar Fuentes" <ofv@wanadoo.es>
Subject: Re: Gap buffer problem?
Date: Wed, 11 Dec 2024 16:33:18 +0100 [thread overview]
Message-ID: <m2cyhyqloh.fsf@gmail.com> (raw)
In-Reply-To: <877c86l1aj.fsf@protonmail.com> (Pip Cet's message of "Wed, 11 Dec 2024 14:53:22 +0000")
Pip Cet <pipcet@protonmail.com> writes:
> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>
>> Pip Cet <pipcet@protonmail.com> writes:
>>
>>> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>>>
>>>> Pip Cet <pipcet@protonmail.com> writes:
>>>>> if we ever replace the gap buffer code, we should make sure its
>>>>> replacement actually handles buffer text and text properties/intervals
>>>>> in an integrated manner, rather than storing just buffer text).
>>>>>
>>>>> Pip
>>>>
>>>> And if I may add a wish to the future author: Make whatever you use
>>>> persistent data structures, so that one could think of letting redisplay
>>>> run concurrently. Really! :-)
>>>
>>> You won't be surprised to hear I've been playing with some code,
>>
>> Indeed, I was just thinking to myself "I knew it" :-).
>> Two thumbs up!
>>
>>> so could I ask you to expand on this point? What precisely does
>>> redisplay require? Full snapshotting or would it be sufficient to have
>>> fine-grained locking?
>>
>> Maybe it's helpful when I tell something about the background. Some time
>> last year I asked myself if I could make Emacs more than one of my
>> plenty of CPU cores without solving the multi-threaded Elisp problem.
>> And the idea was that I could do that, possibly, by letting redisplay
>> happen in another thread.
>
> This may be a very stupid idea, but why not use a separate process?
Not stupid at all. I thought about something similar in a different
context, namely if one could decouple the GUI part of Emacs from the
rest.
Something like that has been done by Eberhard Mattes for OS/2 with the
old redisplay. He had to do that because the whole Presentation Manager
(GUI) in OS/2 would block, for all process, when an application did not
timely handle events and return to the PM. Something like that.
Eberhard's OS/2 Emacs had one process doing the GUI stuff, and one for
the rest. Both communicated with each other using a defined message
protocol. It worked. Don't remember what he used for process
communication, pipes or something else.
I got stuck with this idea because everything seemed to depend on
everything else nowadays. Redisplay needs to execute Lisp, Font backends
I think, not sure. Some GUIs call redisplay (nsterm). And then I
imagined the licensing issues, and dropped the idea. Although - NS could
really need something done, IMO, which was the reason I thought about
that in the first place. NS is not working for me at least. I always
wonder why nobody else has the same freezing problems that I have.
I think the same dependency problems also creep up with to concurrent
redisplay, don't know. Values of variables, faces, jit-lock, and so on.
I think it would be "easier" to handle if one has everything in one
process.
But in principle both could be done. An actor model.
> fork() is fast on GNU/Linux, and I suspect on macOS too, and the
> redisplay child would receive a consistent snapshot of the data to
> inspect and/or modify while coming up with the redisplay instructions,
> which it would then send back via a pipe or shared memory to be executed
> in the main process.
>
> I suggested doing something similar for GC (the GC child would perform a
> full GC and send back the Lisp_Objects which are definitely unreachable
> via a pipe. No, I never figured out how to make that work for weak hash
> tables which may resurrect references, I just made all hash tables
> strong...), and in that case the pipe seemed sufficient for the amount
> of data that was transferred, but I'm not sure how compact (or
> otherwise) serialized redisplay "instructions" would be.
>
> One issue I see is that fork() does a lot of housekeeping work in
> addition to marking the child's memory as a COW copy of the parent's
> memory at the time of the fork(). ISTR you can split that process on
> GNU/Linux (probably not Android), so you'd already have a prepared
> thread/LWP which wouldn't need to "start up" when you un-share the
> memory, but I can't find the relevant manpage right now. However, I have
> no real idea just how bad the fork() latency would be (as you point out,
> most people have more CPU cores than they can use, so I don't consider
> the approximate doubling of CPU usage a problem).
>
> This would deal very nicely with fontification code attempting to modify
> data it shouldn't, by ignoring such modifications. It would also deal
> with catastrophic failure in the redisplay code, as it's insulated in a
> separate process and we could just print a nice message in the main
> process rather than crashing all of Emacs.
>
> I'm emphatically not suggesting letting the redisplay child actually
> communicate with the X server or equivalent. That would be much more
> difficult.
>
> In fact, I think a good way to test this approach would be to use the
> tty code, since there's already a standard serialization of redisplay
> instructions for tty displays: VT100 escape sequences.
>
>> I later realized while thinking about the details, that this undertaking
>> is an order of magnitude too large for me. Everything taking more than a
>> few months is. And, in addition, I wouldn't want to do data structures
>> in C anyway.
>
> I think the VT100 case could be done as a weekend project (those always
> end up taking several weeks for me...), but I'm not sure it's worth it
> as VT100 redisplay isn't the common use case, and the performance
> problems are more visible on GUI terminals.
Yes. In a way, it's already the case that the GUI part of Emacs that I
described above for OS/2, is the terminal emulator, and the protocol is
VT100.
> And, like pretty much all Emacs ideas, this depends on having a better
> GC.
>
> (However, I've just experimented with an 8 GB process forking, and it's
> much slower than I'd hoped for - about 70 ms. I wouldn't be surprised
> if most of that cost is setting up page tables for the ridiculously
> small 4KB page size x86 uses, so it may work a lot better for AArch64
> systems such as yours).
>
> Pip
next prev parent reply other threads:[~2024-12-11 15:33 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.39.1723910423.12184.emacs-devel@gnu.org>
2024-08-17 22:49 ` Emacs-devel Digest, Vol 246, Issue 17 ali_gnu2
2024-08-18 0:10 ` Po Lu
2024-08-18 0:19 ` Po Lu
2024-08-18 1:15 ` Solaris dldump (was: Pure space) ali_gnu2
2024-08-18 1:25 ` Solaris dldump Po Lu
2024-08-18 22:27 ` Stefan Kangas
2024-08-18 23:56 ` Po Lu
2024-08-19 11:18 ` Eli Zaretskii
2024-08-19 12:09 ` Po Lu
2024-08-19 12:50 ` Eli Zaretskii
2024-08-19 11:44 ` Pip Cet
2024-08-19 11:57 ` Po Lu
2024-08-19 12:10 ` Pip Cet
2024-08-19 12:55 ` Eli Zaretskii
2024-08-19 13:46 ` Pip Cet
2024-08-19 14:39 ` Eli Zaretskii
2024-08-19 15:26 ` Corwin Brust
2024-08-19 15:31 ` Corwin Brust
2024-08-19 20:51 ` Stefan Kangas
2024-08-19 20:35 ` Stefan Kangas
2024-12-08 12:17 ` pdumper on Solaris 10 Pip Cet via Emacs development discussions.
2024-12-08 13:05 ` Eli Zaretskii
2024-12-08 13:52 ` Pip Cet via Emacs development discussions.
2024-12-08 14:52 ` Eli Zaretskii
2024-12-08 16:17 ` Pip Cet via Emacs development discussions.
2024-12-08 16:49 ` Eli Zaretskii
2024-12-08 17:37 ` Pip Cet via Emacs development discussions.
2024-12-08 18:41 ` Eli Zaretskii
2024-12-08 19:15 ` Gerd Möllmann
2024-12-08 20:38 ` Eli Zaretskii
2024-12-09 3:09 ` Gerd Möllmann
2024-12-09 3:32 ` Eli Zaretskii
2024-12-09 3:43 ` Gerd Möllmann
2024-12-09 4:53 ` Stefan Kangas
2024-12-09 5:26 ` Gerd Möllmann
2024-12-09 13:58 ` Eli Zaretskii
2024-12-10 0:02 ` Po Lu
2024-12-09 9:56 ` Pip Cet via Emacs development discussions.
2024-12-10 0:04 ` Po Lu
2024-12-10 3:34 ` Eli Zaretskii
2024-12-11 1:13 ` Po Lu
2024-12-11 11:29 ` Pip Cet via Emacs development discussions.
2024-12-09 4:59 ` Stefan Kangas
2024-12-09 14:39 ` Eli Zaretskii
2024-12-09 21:06 ` Merging MPS a.k.a. scratch/igc, yet again Stefan Kangas
2024-12-09 21:49 ` Óscar Fuentes
2024-12-10 4:17 ` Xiyue Deng
2024-12-10 4:26 ` Sean Whitton
2024-12-10 4:42 ` chad
2024-12-10 13:10 ` Óscar Fuentes
2024-12-10 15:10 ` Pip Cet via Emacs development discussions.
2024-12-10 15:37 ` Óscar Fuentes
2024-12-10 15:47 ` Pip Cet via Emacs development discussions.
2024-12-10 17:16 ` Eli Zaretskii
2024-12-10 13:20 ` Eli Zaretskii
2024-12-10 14:46 ` Pip Cet via Emacs development discussions.
2024-12-10 13:09 ` Eli Zaretskii
2024-12-10 13:20 ` Óscar Fuentes
2024-12-10 14:41 ` Eli Zaretskii
2024-12-09 23:13 ` chad
2024-12-10 12:41 ` Eli Zaretskii
2024-12-10 0:09 ` pdumper on Solaris 10 Stefan Kangas
2024-12-10 12:59 ` Eli Zaretskii
2024-12-10 13:39 ` Óscar Fuentes
2024-12-10 14:39 ` Eli Zaretskii
2024-12-10 15:21 ` Óscar Fuentes
2024-12-10 16:39 ` Eli Zaretskii
2024-12-10 15:38 ` Pip Cet via Emacs development discussions.
2024-12-10 16:04 ` Óscar Fuentes
2024-12-10 17:23 ` Eli Zaretskii
2024-12-11 5:27 ` Gap buffer problem? Gerd Möllmann
2024-12-11 8:50 ` Pip Cet via Emacs development discussions.
2024-12-11 9:35 ` Gerd Möllmann
2024-12-11 11:50 ` Pip Cet via Emacs development discussions.
2024-12-11 13:22 ` Gerd Möllmann
2024-12-11 14:53 ` Pip Cet via Emacs development discussions.
2024-12-11 15:33 ` Gerd Möllmann [this message]
2024-12-11 16:58 ` Eli Zaretskii
2024-12-11 17:13 ` Gerd Möllmann
2024-12-11 17:45 ` Robert Pluim
2024-12-11 18:11 ` Gerd Möllmann
2024-12-11 19:08 ` Eli Zaretskii
2024-12-11 17:41 ` Pip Cet via Emacs development discussions.
2024-12-11 19:04 ` Eli Zaretskii
2024-12-11 19:09 ` Gerd Möllmann
2024-12-11 12:27 ` Pip Cet via Emacs development discussions.
2024-12-11 13:27 ` Gerd Möllmann
2024-12-11 15:06 ` Marcus Harnisch
2024-12-11 14:22 ` Eli Zaretskii
2024-12-11 15:51 ` Gerd Möllmann
2024-12-11 17:06 ` Eli Zaretskii
2024-12-11 17:15 ` Gerd Möllmann
2024-12-10 18:13 ` pdumper on Solaris 10 Gerd Möllmann
2024-12-10 15:23 ` Pip Cet via Emacs development discussions.
2024-12-10 17:08 ` Eli Zaretskii
2024-12-10 18:03 ` Gerd Möllmann
2024-12-10 19:34 ` Pip Cet via Emacs development discussions.
2024-12-10 19:59 ` Gerd Möllmann
2024-12-10 20:17 ` Pip Cet via Emacs development discussions.
2024-12-10 20:34 ` Gerd Möllmann
2024-12-11 14:13 ` Pip Cet via Emacs development discussions.
2024-12-11 17:43 ` Eli Zaretskii
2024-12-09 16:21 ` Pip Cet via Emacs development discussions.
2024-12-08 18:47 ` Pip Cet via Emacs development discussions.
2024-12-09 1:13 ` Po Lu
2024-12-09 1:08 ` Po Lu
2024-12-09 0:58 ` Po Lu
2024-12-09 3:28 ` Eli Zaretskii
2024-12-09 1:01 ` Po Lu
2024-12-09 13:11 ` Pip Cet via Emacs development discussions.
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=m2cyhyqloh.fsf@gmail.com \
--to=gerd.moellmann@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=ofv@wanadoo.es \
--cc=pipcet@protonmail.com \
/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).