Re: Latch implementation that wakes on postmaster death on both win32 and Unix

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
Cc: Florian Pflug <fgp(at)phlo(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Latch implementation that wakes on postmaster death on both win32 and Unix
Date: 2011-07-08 16:10:55
Message-ID: 4E172C0F.4040508@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08.07.2011 18:56, Peter Geoghegan wrote:
> On 8 July 2011 15:58, Florian Pflug<fgp(at)phlo(dot)org> wrote:
>> Also, none of the callers of WaitLatch() seems to actually inspect
>> the WL_POSTMASTER_DEATH bit of the result. We might want to make
>> their !PostmasterIsAlive() check conditional on the WL_POSTMASTER_DEATH
>> bit being set. At least in the case of SyncRepWaitForLSN(), it seems
>> that avoiding the extra read() syscall might be beneficial.
>
> I don't think so. Postmaster death is an anomaly, so why bother with
> any sort of optimisation for that case?

We currently call PostmasterIsAlive() on every iteration of the loop,
and what Florian is saying is that it would be more efficient to only
call PostmasterIsAlive() if WaitLatch() reports that the postmaster has
died. That's an optimization that would help the case where postmaster
has not died. However, I don't think it makes any difference in practice
because the loop usually only iterates once, and there's break
statements to exit the loop as soon as one of the other exit conditions
are satisfied.

I just committed the v8 of the patch, BTW, after fixing the comment typo
you pointed out. Thanks!

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2011-07-08 16:15:21 Re: [HACKERS] Creating temp tables inside read only transactions
Previous Message Alvaro Herrera 2011-07-08 16:10:23 blog post on ancient history