Re: Tracking wait event for latches

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Tracking wait event for latches
Date: 2016-10-03 07:30:55
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

On Mon, Oct 3, 2016 at 12:35 PM, Thomas Munro
<thomas(dot)munro(at)enterprisedb(dot)com> wrote:
> Hmm. I like the use of pgstat in that name. It helps with the
> confusion created by the overloading of the term 'wait event' in the
> pg_stat_activity view and the WaitEventSet API, by putting it into a
> different pseudo-namespace.
> + uint32 wait_event;
> How about a typedef for that instead of using raw uint32 everywhere?
> Something like pgstat_wait_descriptor? Then a variable name like
> pgstat_desc, since this is most definitely not just a wait_event
> anymore.

We cannot do that because of latch.h, which now only includes
<signal.h> and it would be a bad idea to add more dependencies to
PG-specific headers.

> + /* Define event to wait for */
> It's not defining the event to wait for at all, it's building a
> description for pgstat.
> + wait_event = pgstat_make_wait_event(WAIT_EXTENSION,
> It's not making a wait event, it's combining a class and an event.
> How about something like this:
> pgstat_desc = pgstat_make_wait_descriptor(WAIT_CLASS_EXTENSION,

Maybe I sound stupid here, but I am trying to keep the same of this
macro short so I'd go for pgstat_make_wait_desc().

> /* Sleep until there's something to do */
> wc = WaitLatchOrSocket(MyLatch,
> PQsocket(conn),
> - -1L);
> + -1L,
> + wait_event);
> ... then use 'pgstat_desc' here.

For this one I agree, your naming is better. It is kind of good to let
callers of WaitLatch know where this is actually used. I have added as
well comments on top of WaitLatch & friends to mention what
pgstat_desc does, that's useful for the user.

Attachment Content-Type Size
wait-event-set-v12.patch text/x-diff 50.2 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-10-03 07:51:36 Backporting
Previous Message Michael Paquier 2016-10-03 06:46:33 Re: pg_hba_file_settings view patch