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 1phxvE-0005Ft-Vj for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 19:26:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1phxvD-0004ko-SM for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 19:26:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phxvD-0004g4-IA for pgsql-hackers@lists.postgresql.org; Thu, 30 Mar 2023 19:26:55 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phxv7-0004lz-5E for pgsql-hackers@postgresql.org; Thu, 30 Mar 2023 19:26:55 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 381CD2F5B3DF for ; Thu, 30 Mar 2023 21:26:48 +0200 (CEST) Received: from s979.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 27C352E2979A; Thu, 30 Mar 2023 21:26:48 +0200 (CEST) Received: from s474.loopia.se (unknown [172.22.191.5]) by s979.loopia.se (Postfix) with ESMTP id 0172910BC420; Thu, 30 Mar 2023 21:26:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s981.loopia.se ([172.22.191.5]) by s474.loopia.se (s474.loopia.se [172.22.190.14]) (amavisd-new, port 10024) with LMTP id B9BhQCXS_SXw; Thu, 30 Mar 2023 21:26:47 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s981.loopia.se (Postfix) with ESMTPSA id 7385B22B1750; Thu, 30 Mar 2023 21:26:47 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: Should vacuum process config file reload more often From: Daniel Gustafsson In-Reply-To: Date: Thu, 30 Mar 2023 21:26:47 +0200 Cc: Melanie Plageman , Kyotaro Horiguchi , PostgreSQL Hackers , Andres Freund , amit.kapila16@gmail.com Content-Transfer-Encoding: quoted-printable Message-Id: <935191FB-083B-4060-89FC-466F61FAA391@yesql.se> References: <20230329.120908.350115307125624430.horikyota.ntt@gmail.com> <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> <20230329.173456.1185961934810139447.horikyota.ntt@gmail.com> To: Masahiko Sawada X-Mailer: Apple Mail (2.3696.120.41.1.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 30 Mar 2023, at 04:57, Masahiko Sawada = wrote: > As another idea, why don't we use macros for that? For example, > suppose VacuumCostStatus is like: >=20 > typedef enum VacuumCostStatus > { > VACUUM_COST_INACTIVE_LOCKED =3D 0, > VACUUM_COST_INACTIVE, > VACUUM_COST_ACTIVE, > } VacuumCostStatus; > VacuumCostStatus VacuumCost; >=20 > non-vacuum code can use the following macros: >=20 > #define VacuumCostActive() (VacuumCost =3D=3D VACUUM_COST_ACTIVE) > #define VacuumCostInactive() (VacuumCost <=3D VACUUM_COST_INACTIVE) // > or we can use !VacuumCostActive() instead. I'm in favor of something along these lines. A variable with a name = that implies a boolean value (active/inactive) but actually contains a = tri-value is easily misunderstood. A VacuumCostState tri-value variable (or a better = name) with a set of convenient macros for extracting the boolean = active/inactive that most of the code needs to be concerned with would more for more readable = code I think. -- Daniel Gustafsson