Re: Excessive PostmasterIsAlive calls slow down WAL redo - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Excessive PostmasterIsAlive calls slow down WAL redo
Date
Msg-id 20180405182758.32alicjtth7wkz7t@alap3.anarazel.de
Whole thread Raw
In response to Excessive PostmasterIsAlive calls slow down WAL redo  (Heikki Linnakangas <hlinnaka@iki.fi>)
Responses Re: Excessive PostmasterIsAlive calls slow down WAL redo  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On 2018-04-05 10:23:43 +0300, Heikki Linnakangas wrote:
> Profiling that, without any patches applied, I noticed that a lot of time
> was spent in read()s on the postmaster-death pipe, i.e. in
> PostmasterIsAlive(). We call that between *every* WAL record.

> That seems like an utter waste of time. I'm almost inclined to call that a
> performance bug. As a straightforward fix, I'd suggest that we call
> HandleStartupProcInterrupts() in the WAL redo loop, not on every record, but
> only e.g. every 32 records.

I agree this is a performance problem. I do however not like the fix.
ISTM the better approach would be to try to reduce the cost of
PostmasterIsAlive() on common platforms - it should be nearly free if
done right.

One way to achieve that would e.g. to stop ignoring SIGPIPE and instead
check for postmaster death inside the handler, without reacting to
it. Then the the actual PostmasterIsAlive() checks are just a check of a
single sig_atomic_t.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: pgsql: New files for MERGE
Next
From: Tom Lane
Date:
Subject: Re: WIP: a way forward on bootstrap data