Re: Interrupts vs signals

2025-03-05 Thread Heikki Linnakangas
On 05/03/2025 21:25, Andres Freund wrote: On 2025-02-28 22:24:56 +0200, Heikki Linnakangas wrote: The second patch makes it possible to use ModifyWaitEvent() to switch between WL_POSTMASTER_DEATH and WL_EXIT_ON_PM_DEATH. WaitLatch() used to modify WaitEventSet->exit_on_postmaster_death directly,

Re: Interrupts vs signals

2025-03-05 Thread Andres Freund
Hi, On 2025-02-28 22:24:56 +0200, Heikki Linnakangas wrote: > I noticed that the ShutdownLatchSupport() function is unused. The first > patch removes it. Looks like that's the case since commit 80a8f95b3bca6a80672d1766c928cda34e979112 Author: Andres Freund Date: 2021-08-13 05:49:26 -0700

Re: Interrupts vs signals

2025-01-28 Thread Thomas Munro
On Wed, Jan 29, 2025 at 10:15 AM Andres Freund wrote: > I was chatting with Heikki about this patch and he mentioned that he recalls a > patch that did some work to unify the signal replacement, procsignal.h and > CHECK_FOR_INTERRUPTS(). Thomas, that was probably from you? Do you have a > pointer,

Re: Interrupts vs signals

2025-01-28 Thread Andres Freund
Hi, I was chatting with Heikki about this patch and he mentioned that he recalls a patch that did some work to unify the signal replacement, procsignal.h and CHECK_FOR_INTERRUPTS(). Thomas, that was probably from you? Do you have a pointer, if so? It does seem like we're going to have to do some

Re: Interrupts vs signals

2025-01-28 Thread Andres Freund
Hi, On 2024-12-02 16:39:28 +0200, Heikki Linnakangas wrote: > From eff8de11fbfea4e2aadce9c1d71452b0f5a1b80b Mon Sep 17 00:00:00 2001 > From: Heikki Linnakangas > Date: Mon, 2 Dec 2024 15:51:54 +0200 > Subject: [PATCH v5 1/4] Replace Latches with Interrupts Your email has only three attachements

Re: Interrupts vs signals

2024-12-02 Thread Heikki Linnakangas
On 02/12/2024 09:32, Thomas Munro wrote: On Sat, Nov 23, 2024 at 10:58 AM Heikki Linnakangas wrote: Hmm, so this would replace the maybeSleepingOnInterrupts bitmask I envisioned. Makes a lot of sense. If it's a single bit though, that means that you'll still get woken up by interrupts that you'

Re: Interrupts vs signals

2024-12-01 Thread Thomas Munro
On Sat, Nov 23, 2024 at 10:58 AM Heikki Linnakangas wrote: > Hmm, so this would replace the maybeSleepingOnInterrupts bitmask I > envisioned. Makes a lot of sense. If it's a single bit though, that > means that you'll still get woken up by interrupts that you're not > waiting for. Maybe that's fin

Re: Interrupts vs signals

2024-11-22 Thread Heikki Linnakangas
On 19/11/2024 23:02, Robert Haas wrote: On Mon, Nov 18, 2024 at 11:09 PM Thomas Munro wrote: Names don't match here. I prefer _CONTINUE. As for the general one, I'm on the fence about INTERRUPT_GENERAL_WAKEUP, since wakeups aren't necessarily involved, but I don't have a specific better idea

Re: Interrupts vs signals

2024-11-22 Thread Heikki Linnakangas
On 19/11/2024 06:09, Thomas Munro wrote: It looks like maybeSleepingOnInterrupts replaces maybe_sleeping, and SendInterrupt() would need to read it to suppress needless kill() calls, but doesn't yet, or am I missing something? Ah yes, you're right. Hmm, I think there are two kinds of kill() s

Re: Interrupts vs signals

2024-11-19 Thread Robert Haas
On Mon, Nov 18, 2024 at 11:09 PM Thomas Munro wrote: > Names don't match here. I prefer _CONTINUE. As for the general one, > I'm on the fence about INTERRUPT_GENERAL_WAKEUP, since wakeups aren't > necessarily involved, but I don't have a specific better idea so I'm > not objecting... Perhaps it

Re: Interrupts vs signals

2024-11-18 Thread Thomas Munro
Some feedback on v4-0001-Replace-Latches-with-Interrupts.patch: + latch.c -> waiteventset.c +1 + /* +* INTERRUPT_RECOVERY_WAKEUP is used to wake up startup process, to tell +* it that it should continue WAL replay. It's sent by WAL receiver when +* more WAL arrives,

Re: Interrupts vs signals

2024-11-15 Thread Heikki Linnakangas
Here is also a version of Thomas's "Use Latch for bgworker state change notification patch", rebased over the "Replace latches with Interrupts" patch. I used INTERRUPT_GENERAL_WAKEUP for the notification, as a straightforward replacement of setting the latch, but I wonder if we should have a

Re: Interrupts vs signals

2024-11-14 Thread Jelte Fennema-Nio
On Sun, 10 Nov 2024 at 22:30, Heikki Linnakangas wrote: > I thought of the Wiki so that it could updated more casually by > extension authors. Makes sense, I agree it would be nice not to have to rely on committers to merge these changes. Especially since many extension authors are not committers

Re: Interrupts vs signals

2024-11-10 Thread Heikki Linnakangas
On 05/11/2024 22:21, Jelte Fennema-Nio wrote: On Mon, 4 Nov 2024 at 20:42, Heikki Linnakangas wrote: Having spent some time playing with this, I quite like option C: break compatibility, but provide an out-of-tree header file with *forward*-compatibility macros. That encourages extension author

Re: Interrupts vs signals

2024-11-05 Thread Jelte Fennema-Nio
On Mon, 4 Nov 2024 at 20:42, Heikki Linnakangas wrote: > Having spent some time playing with this, I quite like option C: break > compatibility, but provide an out-of-tree header file with > *forward*-compatibility macros. That encourages extension authors to > adapt to new idioms, but avoids havi

Re: Interrupts vs signals

2024-10-30 Thread Michael Paquier
On Wed, Oct 30, 2024 at 01:23:54PM -0400, Robert Haas wrote: > On Wed, Oct 30, 2024 at 12:03 PM Heikki Linnakangas wrote: >> We can provide backwards compatibility macros and a new facility to >> allocate custom interrupt bits. But how big of a problem is this anyway? >> In an in-person chat last

Re: Interrupts vs signals

2024-10-30 Thread Robert Haas
On Wed, Oct 30, 2024 at 12:03 PM Heikki Linnakangas wrote: > 1. Any extensions using WaitLatch, SetLatch, ResetLatch need to be > changed to use WaitInterrupt, SetInterrupt/RaiseInterrupt, > ResetInterrupt instead. > > 2. If an extension is defining its own Latch with InitLatch, rather than > usin

Re: Interrupts vs signals

2024-10-30 Thread Heikki Linnakangas
One remaining issue with these patches is backwards-compatibility for extensions: 1. Any extensions using WaitLatch, SetLatch, ResetLatch need to be changed to use WaitInterrupt, SetInterrupt/RaiseInterrupt, ResetInterrupt instead. 2. If an extension is defining its own Latch with InitLatch,

Re: Interrupts vs signals

2024-08-30 Thread Thomas Munro
On Sat, Aug 31, 2024 at 10:17 AM Heikki Linnakangas wrote: > > * This direction seems to fit quite nicely with future ideas about > > asynchronous network I/O. That may sound unrelated, but imagine that > > a future version of WaitEventSet is built on Linux io_uring (or > > Windows iorings, or Wi

Re: Interrupts vs signals

2024-08-25 Thread Thomas Munro
On Sun, Aug 25, 2024 at 5:17 AM Heikki Linnakangas wrote: > On 07/08/2024 17:59, Heikki Linnakangas wrote: > > I'm also wondering about the relationship between interrupts and > > latches. Currently, SendInterrupt sets a latch to wake up the target > > process. I wonder if it should be the other w

Re: Interrupts vs signals

2024-08-07 Thread Heikki Linnakangas
On 10/07/2024 09:48, Thomas Munro wrote: The next problems to remove are, I think, the various SIGUSR2, SIGINT, SIGTERM signals sent by the postmaster. These should clearly become SendInterrupt() or ProcSetLatch(). The problem here is that the postmaster doesn't have the proc numbers yet. One

Re: Interrupts vs signals

2024-07-29 Thread Robert Haas
On Mon, Jul 29, 2024 at 1:24 PM Tom Lane wrote: > Robert Haas writes: > > I wonder how this works right now. Is there something that limits the > > number of authentication requests that can be in flight concurrently, > > or is it completely uncapped (except by machine resources)? > > The former.

Re: Interrupts vs signals

2024-07-29 Thread Tom Lane
Robert Haas writes: > I wonder how this works right now. Is there something that limits the > number of authentication requests that can be in flight concurrently, > or is it completely uncapped (except by machine resources)? The former. IIRC, the postmaster won't spawn more than 2X max_connecti

Re: Interrupts vs signals

2024-07-29 Thread Heikki Linnakangas
On 29/07/2024 19:56, Robert Haas wrote: On Wed, Jul 24, 2024 at 8:58 AM Heikki Linnakangas wrote: a) assign every child process a PGPROC entry, and make postmaster responsible for assigning them like you suggest. We'll need more PGPROC entries, because currently a process doesn't reserve one un

Re: Interrupts vs signals

2024-07-29 Thread Robert Haas
On Wed, Jul 24, 2024 at 8:58 AM Heikki Linnakangas wrote: > a) assign every child process a PGPROC entry, and make postmaster > responsible for assigning them like you suggest. We'll need more PGPROC > entries, because currently a process doesn't reserve one until > authentication has happened. Or

Re: Interrupts vs signals

2024-07-24 Thread Heikki Linnakangas
On 10/07/2024 09:48, Thomas Munro wrote: On Mon, Jul 8, 2024 at 9:38 PM Heikki Linnakangas wrote: The patch actually does both: it still does kill(SIGUSR1) and also sets the latch. Yeah, I had some ideas about supporting old extension code that really wanted a SIGUSR1, but on reflection, the

Re: Interrupts vs signals

2024-07-08 Thread Robert Haas
On Mon, Jul 8, 2024 at 5:38 AM Heikki Linnakangas wrote: > Another approach would be to move the responsibility of background > worker state notifications out of postmaster completely. When a new > background worker is launched, the worker process itself could send the > notification that it has s

Re: Interrupts vs signals

2024-07-08 Thread Heikki Linnakangas
On 08/07/2024 05:56, Thomas Munro wrote: Here's an updated version of this patch. The main idea is that SendProcSignal(pid, PROCSIGNAL_XXX, procno) becomes SendInterrupt(INTERRUPT_XXX, procno), and all the pending interrupt global variables and pss_procsignalFlags[] go away, along with the SIGUS

Re: Interrupts vs signals

2021-11-11 Thread Thomas Munro
On Fri, Nov 12, 2021 at 9:24 AM Robert Haas wrote: > On Thu, Nov 11, 2021 at 2:50 PM Andres Freund wrote: > > They can count, but only when used for network sockets or pipes ("slow > > devices" or whatever the posix language is). Disk IO doesn't count as that. > > So > > I don't think it'd be a

Re: Interrupts vs signals

2021-11-11 Thread Robert Haas
On Thu, Nov 11, 2021 at 2:50 PM Andres Freund wrote: > They can count, but only when used for network sockets or pipes ("slow > devices" or whatever the posix language is). Disk IO doesn't count as that. So > I don't think it'd be a huge issue. Somehow the idea that the network is a slow device a

Re: Interrupts vs signals

2021-11-11 Thread Andres Freund
Hi, On 2021-11-11 09:06:01 -0500, Robert Haas wrote: > On Thu, Nov 11, 2021 at 12:27 AM Thomas Munro wrote: > > > Depending on how you implement them, one difference could be whether / > > > when > > > "slow" system calls (recv, poll, etc) are interrupted. > > > > Hopefully by now all such waits

Re: Interrupts vs signals

2021-11-11 Thread Robert Haas
On Thu, Nov 11, 2021 at 12:27 AM Thomas Munro wrote: > > Depending on how you implement them, one difference could be whether / when > > "slow" system calls (recv, poll, etc) are interrupted. > > Hopefully by now all such waits are implemented with latch.c facilities? Do read(), write(), etc. cou

Re: Interrupts vs signals

2021-11-10 Thread Thomas Munro
On Thu, Oct 21, 2021 at 8:27 AM Andres Freund wrote: > On 2021-10-21 07:55:54 +1300, Thomas Munro wrote: > > 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 an

Re: Interrupts vs signals

2021-10-20 Thread Andres Freund
Hi, On 2021-10-21 07:55:54 +1300, Thomas Munro wrote: > 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 variable

Interrupts vs signals

2021-10-20 Thread Thomas Munro
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.