Re: Reduced power consumption in WAL Writer process

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Peter Geoghegan <peter(at)2ndQuadrant(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reduced power consumption in WAL Writer process
Date: 2011-07-18 14:51:04
Message-ID: 3043.1311000664@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> On Sun, Jul 17, 2011 at 10:41 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Yeah, I agree with putting the actual SetLatch call after we release the
>> lock ... but doesn't the calculation need to be done while we're still
>> holding it? Otherwise it'd be using potentially-inconsistent values.

> The calculation is just a heurustic, so doesn't need to be exactly
> accurate. We need the latest values derived while holding the lock,
> but we don't need to ensure they change while we make the calc.

> The calc needs to say "if we are the ones who make the array more than
> half full, then wake up the WALWriter". It might already be awake, it
> might be already be more than half full or it might even be less than
> half full now - none of those cases are very important.

Nonetheless, I think it'll be better to make the calculation and set a
local bool variable (to tell whether to do SetLatch later) while we're
in the midst of the advance-to-next-WAL-buffer code. Even if it's true
that we would generally get an OK answer by reading the variables again
after releasing the lock, that's highly unlikely to be a performance
win, because of cache line contention effects (ie, having to wrest the
line back from the next guy doing WALInsert, and then give it back to
him afterwards). Once you release the lock, you should stop touching
shared memory, period.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-07-18 14:57:25 Re: pgsql: Made ecpglib write double with a precision of 15 digits.
Previous Message Tom Lane 2011-07-18 14:38:53 Re: proposal: a validator for configuration files