Re: Tracking wait event for latches - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Tracking wait event for latches
Date
Msg-id CAB7nPqTkNunV1bKRpNOAYTwp0DJuYbjzkrCLmheSbtPSAYatpw@mail.gmail.com
Whole thread Raw
In response to Re: Tracking wait event for latches  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: Tracking wait event for latches  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Oct 3, 2016 at 12:35 PM, Thomas Munro
<thomas.munro@enterprisedb.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,
> + WAIT_EVENT_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,
> WAIT_EVENT_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,
>     WL_LATCH_SET | WL_SOCKET_READABLE,
>     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.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pg_hba_file_settings view patch
Next
From: Craig Ringer
Date:
Subject: Backporting PostgresNode.pm