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 1vqo8u-000prs-08 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 08:03:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqo8s-00D3hA-0R for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Feb 2026 08:03:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vqo8r-00D3h1-2i for pgsql-hackers@lists.postgresql.org; Fri, 13 Feb 2026 08:03:10 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vqo8p-00000000Pht-13PT for pgsql-hackers@postgresql.org; Fri, 13 Feb 2026 08:03:09 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-43626796202so550724f8f.3 for ; Fri, 13 Feb 2026 00:03:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770969786; x=1771574586; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TowMp6hZurvx+f9vHq66F/AZ71/Pj7OmwG4ngJ+Dknk=; b=DEKOOug3DMx9yK9AHhydcZG4iOWFlzXFOfPGlwfMXg4wTegsZOPaJ2jleEwZzJj1mC L60hfyysurgBIJkQs87OtDHguXYnZx+bLbdF7j6SyyyNskKjW8wtuvlfgIvBLNpzYRvF AyjWDdijcKvXbHR4yOOvi2mCKm9di4fkJ9cmJRbpib2fA+Fxkw00XPDaBNfMH+34ogKE CDnQoiuIASnv5ZfBW+c0aacCY5U2der3ekXXGO1Orq15uMFjiiXMUAcRUWcpObtsVr6p jEYW6aneqLpO5wflYXArTWbI5hdcpQ39GxmyU5tLmN+BlMa/UWDtnKMBHOSHRmL0xEp8 cORg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770969786; x=1771574586; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TowMp6hZurvx+f9vHq66F/AZ71/Pj7OmwG4ngJ+Dknk=; b=BCadstR6VMPIVO8lRFHzoSM6eG2ysa59rxSn4DE+cYBa38bIrcF1T3wEIy8vuFgtND CetfUVulU3iYTOdHN9XHXpGUI2zXLxRpsjoMPf0/RCQIz15TOPD2s8buvUDG+NQKjtml B1jItdPs9ouYFimD1Ea+4/S64YBlA6+G46CtbDwiNrBPvLzVYY2T1p9Nh85eRWs3SXCA T9rCHl2280/dwPN4TI8oiYNQU+NvuIe59HOa1ouST9PV9Q1VEzqoAo4nq+ce44fzU6Go 0p/tze0hL1rblX9EGMjo0g06pkdcwynK8cs9Jbc0mGLsZR6BcTcM8zVC3WAfwkar8cgP ktyg== X-Forwarded-Encrypted: i=1; AJvYcCUF1m4qPsP8baHRczdkgbkS7K+e+zlPTEcR/OuFoiUC/DhTWTxsBv6rpTrnTp9lOSgf8yjyh5gd1Y3DeiIU@postgresql.org X-Gm-Message-State: AOJu0YwqT1YSU0ndp3X8PDlIxIfPhvL6MNhbAFmHnGB7EeVIWPo30f9W 7FtapssNeF8XeRm2IRGk1zs4XbG0AH5MFLc/k+ccu4ISxILkRHoISTnp X-Gm-Gg: AZuq6aJToCt4rqHq7ZIsZoAwbGKG7h+2WSpSkAx4iYcHloJp7GiYYy9Wpbpfb4iR8q2 YUBu+NBWk3ZXwNR3XZKBY5aYOkhrM6I55ybUxyGjqxFfQotI2iGQaLxrcO7ynoVjdsTvWnD78zg ZE59UX2glJghGh6m3/PVabblXURzLRtjDwPRcp5DH61kSxd7U4oKtPv7MNRxvp+GuL/ylyn80oR BHjWl24w2Bbg/jnpWvmNdDRyAiGqiuomEfXtU7y86la80o3qmFI07nAMNUyIf7D/eFg94v8cA0P aIBc1LDP8WJYKlku4i0ZurFa1hkwlpIeHuaoQN2+Y2kOiET4FofY6JB9w56TvqQMNi2WIoy5Ccp A69Q7jTTkPqPv7hPRWQEunQ62yn+LUHYbmOCWVHecJddA8C8hbzUpgEUTDjgh2Hl++q4A+QOwLL xnObBzE/kcwCPFaDCgM8CWiurU3ooBpK6siKJziaTCTa8/co081M37bLJ5xVFW3WEoNAs+DVIFE jbJdTyzlBmmik9X0BmnPH7qe8AJmUYB83qxdA7ov8ygEd8Ixg76hW181ZDY27LaNGEY X-Received: by 2002:a05:6000:2283:b0:435:e451:39d4 with SMTP id ffacd0b85a97d-4379792bf73mr1906543f8f.44.1770969786215; Fri, 13 Feb 2026 00:03:06 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a6a5f0sm3755991f8f.11.2026.02.13.00.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Feb 2026 00:03:05 -0800 (PST) Date: Fri, 13 Feb 2026 08:03:04 +0000 From: Bertrand Drouvot To: Heikki Linnakangas Cc: Andres Freund , "pgsql-hackers@postgresql.org" Subject: Re: PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals) Message-ID: References: <1cb0d7e9-d6dd-4517-a7cd-0ad98e1207f3@iki.fi> <3dd6f70c-b94d-4428-8e75-74a7136396be@iki.fi> <787be980-0878-4f4a-be01-d042ab5d370e@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <787be980-0878-4f4a-be01-d042ab5d370e@iki.fi> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Feb 11, 2026 at 12:03:51PM +0200, Heikki Linnakangas wrote: > On 11/02/2026 06:40, Bertrand Drouvot wrote: > > A few comments: > > > > 0001: > > > > + * and (b) to make the multiplication / division to convert between PGPROC * > > + * and ProcNumber be a little cheaper > > > > Is that correct if PGPROC size is not a power of 2? > > You're right, it's not. Looking more closely at: " /* GCC supports aligned and packed */ #if defined(__GNUC__) #define pg_attribute_aligned(a) __attribute__((aligned(a))) #define pg_attribute_packed() __attribute__((packed)) #elif defined(_MSC_VER) /* * MSVC supports aligned. * * Packing is also possible but only by wrapping the entire struct definition * which doesn't fit into our current macro declarations. */ #define pg_attribute_aligned(a) __declspec(align(a)) #else /* * NB: aligned and packed are not given default definitions because they * affect code functionality; they *must* be implemented by the compiler * if they are to be used. */ #endif " and what the patch adds: +/* + * If compiler understands aligned pragma, use it to align the struct at cache + * line boundaries. This is just for performance, to (a) avoid false sharing + * and (b) to make the multiplication / division to convert between PGPROC * + * and ProcNumber be a little cheaper. + */ +#if defined(pg_attribute_aligned) + pg_attribute_aligned(PG_CACHE_LINE_SIZE) +#endif +PGPROC; It means that PGPROC is "acceptable" without padding (on compiler that does not understand the aligned attribute). OTOH, looking at: " typedef union WALInsertLockPadded { WALInsertLock l; char pad[PG_CACHE_LINE_SIZE]; } WALInsertLockPadded; " It seems to mean that WALInsertLockPadded is unacceptable without padding (since it's not using pg_attribute_aligned()). That looks ok to see PGPROC as an "acceptable" one, if not, should we use the union trick? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com