From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org, Lukas Fittl <lukas(at)fittl(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Subject: | Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) |
Date: | 2021-12-01 23:59:15 |
Message-ID: | 20211201235915.GI17618@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Dec 01, 2021 at 05:00:14PM -0500, Melanie Plageman wrote:
> > Also:
> > src/include/miscadmin.h:#define BACKEND_NUM_TYPES (B_LOGGER + 1)
> >
> > I think it's wrong to say NUM_TYPES = B_LOGGER + 1 (which would suggest using
> > lessthan-or-equal instead of lessthan as you are).
> >
> > Since the valid backend types start at 1 , the "count" of backend types is
> > currently B_LOGGER (13) - not 14. I think you should remove the "+1" here.
> > Then NROWS (if it continued to exist at all) wouldn't need to subtract one.
>
> I think what I currently have is technically correct because I start at
> 1 when I am using it as a loop condition. I do waste a spot in the
> arrays I allocate with BACKEND_NUM_TYPES size.
>
> I was hesitant to make the value of BACKEND_NUM_TYPES == B_LOGGER
> because it seems kind of weird to have it have the same value as the
> B_LOGGER enum.
I don't mean to say that the code is misbehaving - I mean "num_x" means "the
number of x's" - how many there are. Since the first, valid backend type is 1,
and they're numbered consecutively and without duplicates, then "the number of
backend types" is the same as the value of the last one (B_LOGGER). It's
confusing if there's a macro called BACKEND_NUM_TYPES which is greater than the
number of backend types.
Most loops say for (int i=0; i<NUM; ++i)
If it's 1-based, they say for (int i=1; i<=NUM; ++i)
You have two different loops like:
+ for (int i = 0; i < BACKEND_NUM_TYPES - 1 ; i++)
+ for (int backend_type = 1; backend_type < BACKEND_NUM_TYPES; backend_type++)
Both of these iterate over the correct number of backend types, but they both
*look* wrong, which isn't desirable.
--
Justin
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Martinez | 2021-12-02 00:17:20 | Re: [PATCH] Partial foreign key updates in referential integrity triggers |
Previous Message | Greg Nancarrow | 2021-12-01 23:21:39 | Re: Data is copied twice when specifying both child and parent table in publication |