Re: Reduced power consumption in WAL Writer process

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: 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-15 13:29:41
Message-ID: ABA11F10-E6B7-4FBC-905E-5731500A4A9A@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jul 14, 2011, at 4:42 AM, Simon Riggs <simon(at)2ndQuadrant(dot)com> wrote:
> On Thu, Jul 14, 2011 at 9:57 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)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 unpredictable ways. 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 the time but have some mechanism for putting the process to sleep until wakened when no activity happens for a certain period of 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2011-07-15 13:36:27 Re: Reduced power consumption in WAL Writer process
Previous Message Simon Riggs 2011-07-15 11:23:36 Re: Single pass vacuum - take 1