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 1x6Rqi-000F1c-0i for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Sep 2026 12:01:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x6Rqh-001idv-24 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Sep 2026 12:01:19 +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 1x6Rci-001deH-1l for pgsql-hackers@lists.postgresql.org; Tue, 15 Sep 2026 11:46:52 +0000 Received: from pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com ([35.83.148.184]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x6Rcd-00000000Z3w-3aHO for pgsql-hackers@lists.postgresql.org; Tue, 15 Sep 2026 11:46:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.it; i=@amazon.it; q=dns/txt; s=amazoncorp2; t=1789472809; x=1821008809; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=91+LlUgfwzbbdegYkfSKY8YogUK5p2rgRUb19NjSV4w=; b=QWu9rp/PR1ZAFj2BjDKqnJg0PKPcw4/lfVWHVZquihX9d3vKom6OHmcR O9/S95ipnvXYtxrUuCjvuiM1EqgbKIJBr9B/VdwZ8ASmqU6LBwPT+u9RW onvfF65FaFBOUQtHiebSTJbI6LMu8hxAW217MUnKQWkbvBbhQwRUZ4o90 3qm/J/ReVVXu8dhq+RznEa2FHbH7QbYLvyr8VB9OzRWNWr96/FH9LJvhJ +kg+AKUMXphTJHoJScn0a4VPlfY8c1Qm8h4Lr4fPrmfo3GABVOa3Ae1+Q UTExTg1Q1Tn5oQzcN8/dkJNssYDuBFMwjFTv9elLWqGaWomCZ7juP/PEL w==; X-CSE-ConnectionGUID: ZnRqaMQDQGK/24ptBv3Cig== X-CSE-MsgGUID: sYGdVr64T8OCg77t/mdWJw== X-IronPort-AV: E=Sophos;i="6.27,103,1787011200"; d="scan'208";a="28512238" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 11:46:43 +0000 Received: from EX19MTAUWC002.ant.amazon.com [205.251.233.51:20428] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.22.113:2525] with esmtp (Farcaster) id 0274f228-7e09-4afb-a6a4-2cfedfed2d68; Tue, 15 Sep 2026 11:46:43 +0000 (UTC) X-Farcaster-Flow-ID: 0274f228-7e09-4afb-a6a4-2cfedfed2d68 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.46; Tue, 15 Sep 2026 11:46:43 +0000 Received: from dev-dsk-dipiets-1b-77b833da.eu-west-1.amazon.com (10.253.66.177) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.46; Tue, 15 Sep 2026 11:46:41 +0000 From: Salvatore Dipietro To: CC: , , , , Subject: Re: use a non-locking initial test in TAS_SPIN on AArch64 Date: Tue, 15 Sep 2026 11:46:23 +0000 Message-ID: <20260915114623.431827-1-dipiets@amazon.it> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.253.66.177] X-ClientProxiedBy: EX19D037UWC003.ant.amazon.com (10.13.139.231) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I'd like to propose backporting this commit 3d0b4b1068 ("Use a non-locking initial test in TAS_SPIN on AArch64.", Nathan Bossart, 2025-01-10), which first shipped in PostgreSQL 18, to the supported back branches: REL_17_STABLE, REL_16_STABLE and REL_15_STABLE. The trigger is a kernel change, not a PostgreSQL one: Linux made PREEMPT_LAZY the default in v7.0. A backend can now be preempted while holding a spinlock, causing a drop in performance. Setup: AWS Graviton4 (m8g.24xlarge, 96 vCPU, 384 GB), Amazon Linux 2023, pgbench built-in simple-update, scale 8470, prepared protocol, 1024 clients, 1200 s per run, shared_buffers 95 GB. PostgreSQL 15.18, 16.14, 17.10, 18.4. Two kernels: AL2023 stock 6.1.182-227.379 (no PREEMPT_LAZY) and linux-next 7.2.0-8d3ae5928 (PREEMPT_LAZY by default). Kernel v6.5+ also carries a second, unrelated regression in the folio allocation for which we have proposed a kernel fix separately [1]. Both defects cap TPS at roughly the same level, so the paging one hides most of the spinlock effect. Look at the "v7.2+fix" columns to see the spinlock on its own. TPS with huge_pages=off, and the TTAS-vs-stock gain per kernel: | PG | 6.1 | v7.2 | v7.2+fix | |-------------|--------:|-------:|---------:| | 15.18 stock | 75,799 | 41,155 | 43,636 | | 15.18 TTAS | 80,858 | 56,198 | 82,212 | | 15.18 gain | +6.7% | +36.6% | +88% | | 16.14 stock | 75,667 | 39,952 | 39,592 | | 16.14 TTAS | 80,746 | 57,604 | 77,747 | | 16.14 gain | +6.7% | +44.2% | +96% | | 17.10 stock | 137,630 | 69,751 | 69,003 | | 17.10 TTAS | 150,794 | 81,487 | 157,436 | | 17.10 gain | +9.6% | +16.8% | +128% | | 18.4 native | 148,467 | 79,820 | 143,473 | So on a PREEMPT_LAZY kernel with the paging defect fixed, the one-line change is worth +88% to +128% on PG 15-17. PG 17.10 with the backport also tracks PG 18.4's native behaviour closely on both kernels. With huge_pages=on both effects largely disappear: huge pages mask the paging defect, and TTAS is neutral. The change is a one-line, so a backport looks low-risk and would spare pre-18 AArch64 users a severe regression as PREEMPT_LAZY kernels ship. Thanks, Salvatore [1] https://lore.kernel.org/linux-mm/20260911142102.2294202-1-dipiets@amazon.it/T/#u AMAZON DEVELOPMENT CENTER ITALY SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro delle Imprese di Milano Monza Brianza Lodi REA n. 2504859, Capitale Sociale: 10.000 EUR i.v., Cod. Fisc. e P.IVA 10100050961, Societa con Socio Unico