pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Salvatore Dipietro <dipiets@amazon.it>
To: nathandbossart@gmail.com
Cc: pgsql-hackers@lists.postgresql.org
Cc: mrdrivingduck@gmail.com
Cc: andres@anarazel.de
Cc: tgl@sss.pgh.pa.us
Cc: dipietro.salvatore@gmail.com
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> (raw)
In-Reply-To: <Z4gDWMbR6uqV1mhR@nathan>
References: <Z4gDWMbR6uqV1mhR@nathan>


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









view thread (22+ messages)  latest in thread

Message-ID: <20260915114623.431827-1-dipiets@amazon.it>
Permalink:  ../20260915114623.431827-1-dipiets@amazon.it/
Also on:    postgresql.org/message-id/20260915114623.431827-1-dipiets@amazon.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: dipiets@amazon.it, nathandbossart@gmail.com, pgsql-hackers@lists.postgresql.org, mrdrivingduck@gmail.com, andres@anarazel.de, tgl@sss.pgh.pa.us, dipietro.salvatore@gmail.com
  Subject: Re: use a non-locking initial test in TAS_SPIN on AArch64
  In-Reply-To: <20260915114623.431827-1-dipiets@amazon.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox