Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vYaBo-007oDc-2z for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Dec 2025 01:30:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vYaBn-006Gwq-2u for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Dec 2025 01:30:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vYaBn-006Gwi-1v for pgsql-hackers@lists.postgresql.org; Thu, 25 Dec 2025 01:30:52 +0000 Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vYaBm-002bud-0L for pgsql-hackers@postgresql.org; Thu, 25 Dec 2025 01:30:52 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 0E2301D0012B; Wed, 24 Dec 2025 20:30:48 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Wed, 24 Dec 2025 20:30:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1766626247; x=1766712647; bh=AA/osJgZj2 /OGz0RZILJ3qZWrmnIf782AmpnCbtiiQ8=; b=LEMdoX5gabEAch/kMdNrPgGYya YlbM4cvUOM1u71oLBHNzVB9W4KizoYo7tfOZqlF6zifO2Wchop6ScIuiOl6aoQaZ Nmsd8JWnVgHZnRF5dG5McHdZ71iHdTFUAQLlqQJIq9JK0972wGHypBOu9Q105ce8 +QyYTmmWEGo0KzdITYnH5egHEcjvYsBmxOCP4E8Ssl1dt5s6i65sjgoPuNnKxZ3m AEOX6yuKwy+qN3mrQFZE8F9kOS5Fk2kLR5OF+qqD2w58IgmKyU3A03qbrfTStZ5s iuNcJrWQNYCojq5TMtSLT3bWohMdwOF+ShBfIiFV/D8gCqvRGNQajghO4mDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1766626247; x=1766712647; bh=AA/osJgZj2/OGz0RZILJ3qZWrmnIf782Amp nCbtiiQ8=; b=TH0vcPoWds1kem0YAstYt7BzwoMMnCW3Sfohj9mzNU0I8gwQN1w hwIZxtLyxWCQIyF06a39VrqtGz32rmdsXGaC9GPYxijM2mh5T2QEZbEHSPcP3N5L KIiufHb2PDFLTmXNBpM05IwI6I6pqm3h5fByLL9DQ4hKnNRCbA+IoZgQw3sBv/45 aWkEYaZImViIMsLgCUKcKUy5W15w5sOebdU2OUL2W/ijemh0XkYUq7d4EATgQXT6 K3JJPmzNvZxcqDGEw69EAjlo1cSJ6PkNHBFmu9M9zaqe0bvB6Xli23ReO/mL5CpB GiSGTuNT17OLmb1Biky2Ut9WSVPAjcf2CHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeigedvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehnrghgnh hrihhksehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghshhhuthhoshhhrdgsrghprght rdhoshhssehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhomhgrshesvhhonhgurhgrrd hmvgdprhgtphhtthhopeiguhhnvghnghiihhhouhesghhmrghilhdrtghomhdprhgtphht thhopehtohhrihhkohhshhhirgesohhsshdrnhhtthgurghtrgdrtghomhdprhgtphhtth hopehrvghshhhkvghkihhrihhllhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhs qhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 Dec 2025 20:30:45 -0500 (EST) Date: Thu, 25 Dec 2025 10:30:37 +0900 From: Michael Paquier To: Naga Appani Cc: Ashutosh Bapat , Tomas Vondra , Xuneng Zhou , torikoshia , Kirill Reshke , pgsql-hackers@postgresql.org Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring Message-ID: References: <95850ce1-2d5e-4271-92ea-c2a02e36b303@vondra.me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="H3h2cgA/A+8IoCzp" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --H3h2cgA/A+8IoCzp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Dec 25, 2025 at 09:45:33AM +0900, Michael Paquier wrote: > Seems basically sensible here for the structure, including the hints > and recommendations for the GUCs. +/* Calculate storage space in bytes for a given number of members */ +static inline int64 +MultiXactMemberStorageSize(MultiXactOffset members) +{ + return (int64) (members / MULTIXACT_MEMBERS_PER_MEMBERGROUP) * + MULTIXACT_MEMBERGROUP_SIZE; +} By the way, this bit also feels a bit confusing, and this comes down to the fact that "members" is not an offset, isn't it? This relates to MultiXactMemberFreezeThreshold(), that considers the number of members as an offset, but it is a number of members, a difference between two offsets. I am wondering if it would not be cleaner and less confusing to do things slightly differently (sorry I did not pay much attention to that previously): - Change GetMultiXactInfo() to return two offsets, nextOffset and oldestOffset. - Use uint64 for members and recalculate the difference in MultiXactMemberFreezeThreshold() and the function code. Heikki has just switched multixact offsets to be 64 bits, yippee. - Redefine MultiXactMemberStorageSize() so as it does not take a number of members in input, but as the amount of space taken between two offsets. At least that would be more consistent with all the other inline functions of multixact.h that rely on MultiXactOffset inputs. Using a int64 is still OK I guess, there may be a case to detect "negative" numbers and give a change to the users of the new inline function to notice that they did a computation wrong, rather than hiding a signedness problem. -- Michael --H3h2cgA/A+8IoCzp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlMk70ACgkQnvQgOdby QH18Tw/8Dexorg+mT2j1wh/x8F1LjZ/ps5oqS+xa3omdfbvhnUtaItgk+V5G+Mzm CTWmWMH5UDyPa8FBbKvGO+ZTrD6eoksmArdGYDlo+OUmaVuevxMUPUtvWcQYAsE5 q2O37CAlGHcbV3dWHriPEDxND44wwAzjl9OuX5M3EaL2ai91WhKkNniYQSg62qrI CImCHF+ldsqR25rYua4NhRg8u5zGUkA+RdYEohhVCmpx4yUQyxdEVQDNmMVJrtR/ ot4HYyPBqGsYG6TXxxWhKYxIwCLuRflnSZTIW1bWKS3B3XYwmhnWXuFPM+LqnGuW C0b02Wgsg+S66ab2lSxY34reIL7jUIUDLfbttMnyuQjxjKL05bgQ2uE4GDxHZ0oV ltuTCo910ROws8sljiBXGMq/75c4TA1P7PXgY8JQ+m1kazGaLiuSTeuv9mRfVFhR OLyTBzCEv4YkGZx0OXhqtT2H7CkmJYgxb2IO6kYJ/bQb7pF+QPWG3oU3YqYZNAk+ FGXXV/R/NqV7zgLAhefYDP2Qk0sdBK//IvPhPhwhXGGE6jzUZdDNU0R2yautsCI1 EA1YLgMAgnfHI7Pt1zwxZSpp5oMwZMlEBByDDKYUPsVu+0npqf5WDySLCMVjZgsG e7D2nDOxQCxrWozk79gZjr6pJrv/E9dNuTPqku5cTLNhn6ZndiY= =m7mh -----END PGP SIGNATURE----- --H3h2cgA/A+8IoCzp--