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 1vq21u-003BWW-1o for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Feb 2026 04:40:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vq21t-002SBb-2N for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Feb 2026 04:40:46 +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 1vq21t-002SBT-1Q for pgsql-hackers@lists.postgresql.org; Wed, 11 Feb 2026 04:40:46 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vq21s-000000005zm-0gzt for pgsql-hackers@postgresql.org; Wed, 11 Feb 2026 04:40:45 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-47ff94b46afso4650705e9.1 for ; Tue, 10 Feb 2026 20:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770784843; x=1771389643; 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=4OV2DTV5oU9o7vAhXc1afHYQ36Li2GMCpfnl6pf7KzM=; b=QevIh25tgG9cUT4QPNRcEFkxObMSMnKi0EdInBOZ+FXzhYUGxo730s/JVkFyk3v/YW cjpo/DjXYFl0njKExuloE0o3POWevRSF1SQBxheVzY42GeDD37H0RyFOP3y10iLzFTS6 TgZLmxS1bB2PzxjSLchpx2U7G1kdiLFUNgBLFrWkWyPohdSNeOi9H1KoYrYa7IWLtzAf 2wTNx79gH7246wgwC2Cmt5m3WssR1X6fWby8AEw96cyRS5Vu3nQpsJ5yYzVcPRU9nYZR bJF5FM7gwM6qpo5XpMykM35D/kXGR9z9mIHHmoLY+V1kmhRoo8T146eczwojjvxnNf5C mM4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770784843; x=1771389643; 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=4OV2DTV5oU9o7vAhXc1afHYQ36Li2GMCpfnl6pf7KzM=; b=o4wUQfAq1v7oZ/OKgD3wq4UoXBC+cnHRkWTFhuVa96LXQEbI42UvW3+iTYx1ZVEbph FLl8zA5WStr3hBfP9Ln+sIBHoeEqBSJzt2X0zJUGO8uJGlfhWKyLjmXVFkOR1mqnc14f hQchQQjrq3bpkbpCQ7JakXosOLd7v6k59KYy/FLLphEyVVIMfZJ4mjmewidkbV2hdpyG 40CwLB3cp2jc0+K5jBFEdmL7KOSiJux3e6PaLdPZe8XUsDVPwKSImEmwxImbqNFt6+1P DZQ3Bbxlqjf6cMvhpxhR///VkOdZtiKiEoFUWpgJKm8xJPfFMPjn5gugMTmmYHKc1qy2 XIUQ== X-Forwarded-Encrypted: i=1; AJvYcCUxivpBmy3avaNX0/OFuBQ5m6KC3EsY6VrIZMpZq8YOCkKmjNqkNJbQipUK3a/7TN/wVwVnO3HKRPSXafPT@postgresql.org X-Gm-Message-State: AOJu0YxKlDf5xAtclMwMJcvoO+WxF5nFBk+tIGYo5XNXiK2nNXNVQvUD RlQ4XtzXxe/YJDTTI9d09yx8pXkZM1lwiwvOhFaaqqOIwyXuXumb8tP3 X-Gm-Gg: AZuq6aKrbuFMqI2O/dVbP3Nj08zscroQgGVvPeNnYxhL9tWS9TN2tmpHQCULm0vNq2r 5KWo2Y2k3oPm98ewooGHsbUN887BTD7YF7nVO3NppVvDa8WH4FwCpZmqCOtFj4tU4XhnKjGNiil eKJICPOBloBkw3qxffdmOzNT5xNZjLXYPpif9E2wBVtaWD3hXD8nddkcoJ8ncXI+zaAyuLM1cnV vFp7FMwEWoLsxjRJjMPTKKWdRZIK1NxVM8UaYN2NrjYN1gw//KrdOQqRyn6oAtWB3u8ocSQad08 z4i1DhMiqHFrLhC5mOd4dfCoKyGlkyW7c5rFhK8+qSSow0miJWAzYVEshlcDTj62vp3O/B0545z stKiHk839j7QJGmrbh5uE/2eoNZ2pghEU5VGHrSvXY6CPzLs8TRrhsVLnVjGlZtNFoQKpfbZuwS t6ZxenSWbPbRcQWv/X+woD7epN3sFudgU6h80adrsFx4ZyxTYuOLeWCaBVK4QogflxxTMPerArK O7aa5mQQRjmzOsUCgJpbLZ0jCXTl4ajlN+b1wdcloTDviJae8FNcUWgkA== X-Received: by 2002:a05:600c:46cf:b0:483:4b37:8620 with SMTP id 5b1f17b1804b1-48350530e24mr63641475e9.10.1770784842349; Tue, 10 Feb 2026 20:40:42 -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-43783e3b829sm1893466f8f.27.2026.02.10.20.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 20:40:41 -0800 (PST) Date: Wed, 11 Feb 2026 04:40:40 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3dd6f70c-b94d-4428-8e75-74a7136396be@iki.fi> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Feb 10, 2026 at 10:53:58PM +0200, Heikki Linnakangas wrote: > On 10/02/2026 21:46, Andres Freund wrote: > > On 2026-02-10 19:15:27 +0000, Bertrand Drouvot wrote: > > > On Tue, Feb 10, 2026 at 01:15:01PM -0500, Andres Freund wrote: > > > > On 2026-02-10 19:14:44 +0200, Heikki Linnakangas wrote: > > > > Yea, I don't think we need to be perfect here. Just a bit less bad. And, as > > > > you say, the current order doesn't make a lot of sense. > > > > Just grouping things like > > > > - pid, pgxactoff, backendType (i.e. barely if ever changing) > > > > - wait_event_info, waitStart (i.e. very frequently changing, but typically > > > > accessed within one proc) > > > > - sem, lwWaiting, waitLockMode (i.e. stuff that is updated frequently and > > > > accessed across processes) > > > > > > With an ordering like in the attached (to apply on top of Heikki's patch), we're > > > back to 832 bytes. > > > > You'd really need to insert padding between the sections to make it work... > > Here's my attempt at grouping things more logically. Thanks! > I didn't insert padding > and also didn't try to avoid alignment padding. I tried to optimize for > readability rather than size or performance. Yeah, my attempt was to put the size back to 832 bytes but that's probably not worth it as stated by Andres up-thread. > That said, I would assume that > grouping things logically like this would also help to avoid false sharing. > If not, inserting explicit padding seems like a a good fix. > > I also think we should split 'links' into two fields. For clarity. > 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? 0002: Good catch! 0003: 1/ There is one missing change in PrintLockQueue() ("links" is still used, and that should be replaced by "waitLink"). 2/ change the comment on top of ProcWakeup? " /* * ProcWakeup -- wake up a process by setting its latch. * * Also remove the process from the wait queue and set its links invalid. " s/links/waitLink/? Also, out of curiosity, with 0003 in place PGPROC size goes from 840 to 856. 0004: The grouping looks Ok to me. Just one nit for the added comments: + /*---- Backend identity ----*/ + /*---- Transactions and snapshots ----*/ + /*---- Inter-process signaling ----*/ + /*---- LWLock waiting ----*/ + /*---- Lock manager data ----*/ + /*---- Synchronous replication waiting ----*/ + /*---- Support for group XID clearing. ----*/ + /*---- Support for group transaction status update. ----*/ + /*---- Status reporting ----*/ Some have period and some don't. > With this, sizeof(PGPROC) == 864 without the explicit alignment to > PG_CACHE_LINE_SIZE, and 896 with it. I can see 876 -> 896 on my side: /* 872 | 4 */ uint32 wait_event_info; /* XXX 20-byte padding */ /* total size (bytes): 896 */ } Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com