Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msZVS-0004hh-He for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Dec 2021 23:59:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msZVR-0008HA-Bt for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Dec 2021 23:59:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msZVQ-0008H1-Ri for pgsql-hackers@lists.postgresql.org; Wed, 01 Dec 2021 23:59:21 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1msZVN-0006pK-K5 for pgsql-hackers@postgresql.org; Wed, 01 Dec 2021 23:59:19 +0000 Received: by mail-io1-xd29.google.com with SMTP id x10so33235488ioj.9 for ; Wed, 01 Dec 2021 15:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SzbPRuLi3zdLgIzbtFF5AuXNvtmWue7btEWyatvvWms=; b=Mi+wMlPmCIhM5/iGxcrJERoK8Sm/fX8IqbGKYgepqP/sv5nzzhnf8m1o2C8YstF4gN TXj/6f+p1oDOSVoymRj17kLMgsYLbXmqz44RelLyLR37zZ8Ar+xDhDuebSTuo7DjS+BZ Dpkaig+JlSxFXcBMa7D6Qa/8Ax7zmzPCy74xPnXIflcrrGOEwVR5XzofbqU16LarckQO aQIG+PZMIbkUzXsV7xIZ0pPu65huju4Qk+3YE9Byz1dYiSMzBqz0bHkg3eoQ0iEkWywh ZOVT2LMItRjZvP7YbD0ChQ23OncGizJkj17MBTLOsWVL6V2Z66F4elEwsAfUYPtVvgJ3 VZ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SzbPRuLi3zdLgIzbtFF5AuXNvtmWue7btEWyatvvWms=; b=z3A24g2LLKpVOL2I03gb/VAJn6jUIIqUqUnjIciYPJ/cfDeZt3nvx3rwYBD3dwib/v KGdxZ70El3iWwAJy9rhznSuYfH7FpQ3MmdBVGwW4Y1jkrXN9vO23xewO84p/ZOehjYAn Q9/6AGnvUqcGKesFGau8qp2LHbk52mdzvI/QkBy68H55w1GHiO8R/r6sLJhDFne/7AFl IclVEkLKBkzZRXAs1tfbzAiRy/KqZKxolNkeXLDRzb9J4uEhpdwH7pSRqeuoQltQrm6A v68bcUP3pXBMJs2vhJbMbKeERuNlqmK9IHUOhIgvdpGsKQzQ8/aioimpl77lPmfkjjgX Rsig== X-Gm-Message-State: AOAM532HkQGTkb4ZXrinrRJlque+XWiR9ShbawXb1BIF1iDYdSgBHKqE +rQ349ao6rUm+x54Wyh039kA1sYW13wtWw== X-Google-Smtp-Source: ABdhPJw7zLJ3g9/+k8RRPs/rKTJyk8WHVRkZE8KvLpNCyjfNe55nCLLx+0RyIi8nzCj6j9dzKu7AZg== X-Received: by 2002:a5d:9ec2:: with SMTP id a2mr13862782ioe.44.1638403156716; Wed, 01 Dec 2021 15:59:16 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id g5sm1037357ioo.18.2021.12.01.15.59.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Dec 2021 15:59:16 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id CD2048009D6; Wed, 1 Dec 2021 17:59:15 -0600 (CST) Date: Wed, 1 Dec 2021 17:59:15 -0600 From: Justin Pryzby To: Melanie Plageman Cc: Andres Freund , Alvaro Herrera , Kyotaro Horiguchi , Magnus Hagander , pgsql-hackers@postgresql.org, Lukas Fittl , Thomas Munro Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) Message-ID: <20211201235915.GI17618@telsasoft.com> References: <20211008175620.nspjy6wwmzvyzkrg@alap3.anarazel.de> <20211019192931.eeeohw6yrvqe6bol@alap3.anarazel.de> <20211119164952.mlw7ecj4xxliuuut@alap3.anarazel.de> <20211125011559.GC17618@telsasoft.com> <20211126211636.GE17618@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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