emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Concurrency via isolated process/thread


From: Ihor Radchenko
Subject: Re: Concurrency via isolated process/thread
Date: Mon, 24 Jul 2023 10:09:50 +0000

Po Lu <luangruo@yahoo.com> writes:

>> Would it be acceptable to convert buffer PT, BEGV, and ZV into
>> thread-local for current cooperative threads?
> ...
> But how much do you want to slow down accesses to PT in the future, when
> multiple threads will run simultaneously?  Operations that use and
> modify PT are essentially the bread and butter of Emacs, and as a result
> accesses to PT must be very fast.

I do not plan to slow down access to PT.
The basic idea is to have
#define PT (current_thread->m_pt + 0)
#define PT_BYTE (current_thread->m_pt_byte + 0)

Basically, use thread object slot instead of buffer object slot to store
point and restriction. This will not cause any performance degradation
and allow multiple points in the same buffer.

What may be slightly slower is setting/getting points in other (not
current) buffers.
We will need to store point and restriction history for each thread.
Searching this history will scale with the number of buffers that have
been current previously during thread execution (though we may use hash
table if necessary).

However, accessing and changing point in buffer that is not current is
not very common. AFAIU, it is done in (1) read operation when reading
from stream represented by a buffer; (2) when switching buffers when we
need to transfer current PT to history for current buffer and retrieve
PT from history for the buffer that will become current.

> In addition to that, we already have separate window and buffer
> points. It would confound users even more to add a third kind of
> object with its own point to the mix.

I propose to remove buffer points completely and use thread points
instead.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]