[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some experience with the igc branch
From: |
Gerd Möllmann |
Subject: |
Re: Some experience with the igc branch |
Date: |
Mon, 23 Dec 2024 21:49:02 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, ofv@wanadoo.es, emacs-devel@gnu.org,
>> eller.helmut@gmail.com, acorallo@gnu.org
>> Date: Mon, 23 Dec 2024 18:44:42 +0100
>>
>> BTW, do you know which signal handlers use Lisp, i.e. allocate Lisp
>> objects or access some? All? Or, would it be realistic to rewrite signal
>> handlers to not do that?
>
> SIGPROF does (it's the basis for our Lisp profiler).
>
> SIGCHLD doesn't run Lisp (I think), but it examines objects and data
> structures of the Lisp machine (those related to child processes).
>
>> One thing I've seen done elsewhere is to publish a message to a message
>> board so that it can be handled outside of the signal handler. Something
>> like that, you know what I mean.
>
> This is tricky for the profiler, because you want to sample the
> function in which you are right there and then, not some time later.
>
> For SIGCHLD this could work, but it might make Emacs slower in
> handling subprocesses (there are some Lisp packages that fire
> subprocesses at very high rate).
Thanks.
I've looked at SIGPROF. From an admittedly brief look at this, I'd
summarize my results as:
- The important part is get_backtrace. The rest could be done elsewhere
by posting that to a message board, or whatever the mechanism is at
the end.
- Didn't see get_backtrace or functions called from it allocating Lisp
objects.
- It reads from a Lisp object because of
#define specpdl (current_thread->m_specpdl)
#define specpdl_end (current_thread->m_specpdl_end)
#define specpdl_ptr (current_thread->m_specpdl_ptr)
current_thread is a struct thread_state which is a PVEC_THREAD.
- I remember that I wrote a scanner for the specpdl stacks, so that's
not a Lisp object but a root, so no problem here, I think.
- struct thread_state allocation is done in igc.c via alloc_immovable in
igc_alloc_pseudovector. That allocated from from an AMS pool, which
doesn't use barriers.
- It doesn't seem to access other Lisp objects except current_thread.
That doesn't look bad, I think. Worth mentioning is perhaps that
directly after get_backtrace here
static void
record_backtrace (struct profiler_log *plog, EMACS_INT count)
{
log_t *log = plog->log;
get_backtrace (log->trace, log->depth);
EMACS_UINT hash = trace_hash (log->trace, log->depth);
we access Lisp objects in trace_hash when computing the hash and in the
other hash table code. IIUC that code counts hits with the same
backtrace. Don't know how long that takes. But if posting the backtrace
would take the same time, we would be on par.
I'll try to also look at SIGCHLD at some later point, but Christmas,
family etc.
Happy holidays!
- Re: Some experience with the igc branch, (continued)
- Re: Some experience with the igc branch, Benjamin Riefenstahl, 2024/12/23
- Re: Some experience with the igc branch, Pip Cet, 2024/12/23
- Re: Some experience with the igc branch, Eli Zaretskii, 2024/12/23
- Re: Some experience with the igc branch, Benjamin Riefenstahl, 2024/12/24
- Re: Some experience with the igc branch, Gerd Möllmann, 2024/12/23
- Re: Some experience with the igc branch, Eli Zaretskii, 2024/12/23
- Re: Some experience with the igc branch, Eli Zaretskii, 2024/12/23
- Re: Some experience with the igc branch,
Gerd Möllmann <=
- Re: Some experience with the igc branch, Helmut Eller, 2024/12/23
- Re: Some experience with the igc branch, Pip Cet, 2024/12/23
- Re: Some experience with the igc branch, Helmut Eller, 2024/12/23
- Re: Some experience with the igc branch, Pip Cet, 2024/12/23
- Re: Some experience with the igc branch, Helmut Eller, 2024/12/24
- Re: Some experience with the igc branch, Gerd Möllmann, 2024/12/24
- Re: Some experience with the igc branch, Pip Cet, 2024/12/24
- Re: Some experience with the igc branch, Gerd Möllmann, 2024/12/23
- Re: Some experience with the igc branch, Gerd Möllmann, 2024/12/24
- SIGPROF + SIGCHLD and igc, Gerd Möllmann, 2024/12/24