Re: Reduced power consumption in WAL Writer process - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Reduced power consumption in WAL Writer process
Date
Msg-id ABA11F10-E6B7-4FBC-905E-5731500A4A9A@gmail.com
Whole thread Raw
In response to Re: Reduced power consumption in WAL Writer process  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Reduced power consumption in WAL Writer process
List pgsql-hackers
On Jul 14, 2011, at 4:42 AM, Simon Riggs <simon@2ndQuadrant.com> wrote:
> On Thu, Jul 14, 2011 at 9:57 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
>
>> Currently walwriter might write out the WAL before a transaction commits.
>> IOW, walwriter tries to write out the WAL in wal_buffers in every wakeups.
>> This might be useful for long transaction which generates lots of WAL
>> records before commit. So we should call SetLatch() in XLogInsert() instead
>> of RecordTransactionCommit()? Though I'm not sure how much walwriter
>> improves the performance of synchronous commit case..
>
> Yeh, we did previously have a heuristic to write out the WAL when it
> was more than half full. Not sure I want to put exactly that code back
> into such a busy code path.
>
> I suggest that we set latch every time the wal buffers wrap.
>
> So at the bottom of AdvanceXLInsertBuffer(), if nextidx == 0 then
> SetLatch on the WALWriter.
>
> That's a simple test and we only check it if we're switch WAL buffer page.

Seems reasonable at first blush, but I worry that changing the algorithm here could change performance in somewhat
unpredictableways. Some of those might be improvements, but I think some careful measurement would be in order. 

If the primary goal here is to reduce power consumption, another option would be to keep the regular wake-ups most of
thetime but have some mechanism for putting the process to sleep until wakened when no activity happens for a certain
periodof time - say, 10 cycles. I'm not at all sure that's better, but it would be less of a change to the existing
behavior.

...Robert

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Single pass vacuum - take 1
Next
From: Peter Geoghegan
Date:
Subject: Re: Reduced power consumption in WAL Writer process