Re: Excessive PostmasterIsAlive calls slow down WAL redo
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-04-05T18:27:58Z
Lists: 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
Commits
-
Poll postmaster less frequently in recovery.
- 57dcc2ef3320 14.0 landed
-
Use signals for postmaster death on FreeBSD.
- f98b8476cd4a 12.0 landed
-
Use signals for postmaster death on Linux.
- 9f09529952ac 12.0 landed
-
Introduce a pipe between postmaster and each backend, which can be used to
- 89fd72cbf26f 9.2.0 cited