Обсуждение: The efficiency of the WAL log writer

Поиск
Список
Период
Сортировка

The efficiency of the WAL log writer

От
Steven Elliott
Дата:
Recently I became curious about the WAL log writer.  I noticed that with
a default ACID complaint configuration that the the WAL log writer wakes
up every 200 msec (the default indicated by "wal_log_writer") and does
nothing.  Here's a typical strace:
  21:37:07.194809 select(0, NULL, NULL, NULL, {0, 31914}) = 0 (Timeout)
<0.032059>
  21:37:07.227098 getppid()               = 4979 <0.000018>
  21:37:07.227198 select(0, NULL, NULL, NULL, {0, 200000}) = 0 (Timeout)
<0.200287>
  21:37:07.427609 getppid()               = 4979 <0.000023>
and ltrace:
  21:37:36.265849 getppid()                        = 4979 <0.000200>
  21:37:36.266299 select(0, 0, 0, 0, 0x7fff2ffec9c0) = 0 <0.200442>
  21:37:36.466979 getppid()                        = 4979 <0.000154>
  21:37:36.467255 select(0, 0, 0, 0, 0x7fff2ffec9c0) = 0 <0.200442>
It's possible it's doing something useful, such as with shared memory,
that is not revealed by strace and ltrace, but my question is - For at
least default ACID complaint configurations where each write is made to
the WAL logs immediately what, if anything, is the WAL log writer
polling?  And if the WAL log writer is polling for something could it
instead wait on a condition which would then be signaled?

I don't think the current behavior is particularly harmful, but maybe
PostgreSQL could be made to idle more quietly.  I have not investigated
the other PostgreSQL processes as closely, but some of them appear to
behave in a similar manner.

--
------------------------------------------------------------------------
|  Steven Elliott  |  http://selliott.org  |  selliott4@austin.rr.com  |
------------------------------------------------------------------------


Re: The efficiency of the WAL log writer

От
Tom Lane
Дата:
Steven Elliott <selliott4@austin.rr.com> writes:
> I don't think the current behavior is particularly harmful, but maybe
> PostgreSQL could be made to idle more quietly.

Yeah, this is something that's on my personal to-do list.  It's not
really an efficiency/performance issue, but in a machine that's
otherwise idle this behavior is bad for overall CPU power consumption.

The plan is to try to use the "latch" primitives that were recently
added to the code to eliminate sleep-and-check-for-something-to-do
loops.  Didn't get done for 9.1 unfortunately.

            regards, tom lane

Re: The efficiency of the WAL log writer

От
Steven Elliott
Дата:
On Thu, 2011-02-17 at 10:26 -0500, Tom Lane wrote:
> Steven Elliott <selliott4@austin.rr.com> writes:
> > I don't think the current behavior is particularly harmful, but maybe
> > PostgreSQL could be made to idle more quietly.
>
> Yeah, this is something that's on my personal to-do list.  It's not
> really an efficiency/performance issue, but in a machine that's
> otherwise idle this behavior is bad for overall CPU power consumption.

I see what you mean that it's more of a CPU power consumption issue than
efficiency.  That makes sense.

This is a small issue that I've been meaning to ask about.  Thanks for
getting back to me.

> The plan is to try to use the "latch" primitives that were recently
> added to the code to eliminate sleep-and-check-for-something-to-do
> loops.  Didn't get done for 9.1 unfortunately.

Sounds good.

--
------------------------------------------------------------------------
|  Steven Elliott  |  http://selliott.org  |  selliott4@austin.rr.com  |
------------------------------------------------------------------------