From: Pip Cet via "Emacs development discussions." <emacs-devel@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gerd.moellmann@gmail.com, emacs-devel@gnu.org, ofv@wanadoo.es
Subject: Re: Gap buffer problem?
Date: Wed, 11 Dec 2024 19:54:07 +0000 [thread overview]
Message-ID: <87ldwmj8sw.fsf@protonmail.com> (raw)
In-Reply-To: <86cyhy2g97.fsf@gnu.org>
"Eli Zaretskii" <eliz@gnu.org> writes:
>> Date: Wed, 11 Dec 2024 17:41:29 +0000
>> From: Pip Cet <pipcet@protonmail.com>
>> Cc: Gerd Möllmann <gerd.moellmann@gmail.com>, emacs-devel@gnu.org, ofv@wanadoo.es
>>
>> "Eli Zaretskii" <eliz@gnu.org> writes:
>>
>> > If it can be done by two processes, it can also be done by two threads
>> > in the same process. Right?
>>
>> AFAIU: No, not right.
>>
>> I may have misunderstood, but if the idea is to preserve a consistent
>> state of all Lisp data and buffer text for redisplay to use, the easiest
>> way to ensure that consistency is fork(). The other ways, such as
>> copying all heap objects that might be used by redisplay (and adjusting
>> all internal pointers in such heap objects to point to the copy rather
>> than the original data), probably will end up either being a lot slower
>> or being very specific to the system we're running on.
>
> How do you do the same in a forked process? The glyph matrices are
> not allocated once, they are reallocated constantly. Are you going to
> fork each time?
Not necessarily "each time" (meaning once per frame/keystroke), but
quite frequently, yes.
> And if you are, how is it different from copying
> stuff lazily within the same process, exactly like the OS does with
> forked processes?
It is very different indeed:
Copying within a process involves changing the (virtual) addresses that
the copied data is at (unless you use an architecture-specific
implementation of TLS). The beauty of fork() is that the virtual
addresses stay the same, so we don't need to adjust any pointers, which
we cannot do because there are ambiguous references to Lisp data.
IOW, no, you can't lazily create two copies of Lisp data in the same
process. You have to do so eagerly, adjusting any and all pointers (and
only those) in the Lisp data before the new data is read for the first
time (because what you read might be a pointer, and then it needs to be
adjusted). With fork(), you only have to make the copy when the data is
being written to, by either process.
(Of course you can just access all memory through some sort of API that
translates addresses for you, but that would effectively mean we'd be
running Emacs on a virtual machine and simulate fork() on it).
> Anyway, the fact that redisplay calls Lisp and Lisp calls back into
> redisplay all but kills this idea. Gerd's document has also other
> gotchas. We didn't just give up easily back when we discussed that.
I don't see why the redisplay process would not be able to call Lisp;
it's a full Emacs process (with a single thread), except it doesn't have
an FD or socket for the window system, and has an extra pipe to
communicate with the parent process instead.
It's true that the side effects of the called Lisp code won't be visible
to the next redisplay process, but such side effects are perilous
anyway, and avoiding them would seem to me to be a feature, not a bug.
However, if such side effects are desired, we can use IPC to execute
Lisp in the main process (some effort) or simply send a "this redisplay
needs to happen synchronously" message to the main process, which would
kill the current redisplay process and perform a synchronous redisplay
(as not all operating systems support fork() reliably, we'll have to
retain the ability to redisplay synchronously, either way).
But, to be perfectly honest, I'm not sure redisplay is slowing me down
the way traditional GC is.
Pip
next prev parent reply other threads:[~2024-12-11 19:54 UTC|newest]
Thread overview: 114+ 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
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:54 ` Pip Cet via Emacs development discussions. [this message]
2024-12-11 20:26 ` Eli Zaretskii
2024-12-11 22:07 ` Dmitry Gutov
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 22:11 ` Dmitry Gutov
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=87ldwmj8sw.fsf@protonmail.com \
--to=emacs-devel@gnu.org \
--cc=eliz@gnu.org \
--cc=gerd.moellmann@gmail.com \
--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).