From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Interrupts vs signals |
Date: | 2021-10-20 18:55:54 |
Message-ID: | CA+hUKG+3MkS21yK4jL4cgZywdnnGKiBg0jatoV6kzaniBmcqbQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I wonder if we really need signals to implement interrupts. Given
that they are non-preemptive/cooperative (work happens at the next
CFI()), why not just use shared memory flags and latches? That skips
a bunch of code, global variables and scary warnings about programming
in signal handlers.
I sketched out some code to try that a few months back, while
speculating about bite-sized subproblems that would come up if each
backend is, one day, a thread.
There are several other conditions that are also handled by
CHECK_FOR_INTERRUPTS(), but are not triggered by other backends
sending signals, or are set by other signal handlers (SIGALRM,
SIGQUIT). One idea is to convert those into "procsignals" too, for
consistency. In the attached, they can be set (ie by the same
backend) with ProcSignalRaise(), but it's possible that in future we
might have a reason for another backend to set them too, so it seems
like a good idea to have a single system, effectively merging the
concepts of "procsignals" and "interrupts".
There are still a few more ad hoc (non-ProcSignal) uses of SIGUSR1 in
the tree. For one thing, we don't allow the postmaster to set
latches; if we gave up on that rule, we wouldn't need the bgworker
please-signal-me thing. Also the logical replication launcher does
the same sort of thing for no apparent reason. Changed in the
attached -- mainly so I could demonstrate that check-world passes with
SIGUSR1 ignored.
The attached is only experiment grade code: in particular, I didn't
quite untangle the recovery conflict flags properly. It's also doing
function calls where some kind of fast inlined magic is probably
required, and I probably have a few other details wrong, but I figured
it was good enough to demonstrate the concept.
Attachment | Content-Type | Size |
---|---|---|
0001-WIP-Refactor-procsignals-and-interrupts.patch | text/x-patch | 53.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2021-10-20 19:01:13 | Re: [RFC] speed up count(*) |
Previous Message | Greg Stark | 2021-10-20 18:42:35 | Re: Extending amcheck to check toast size and compression |