pgsql: Convert Sharedsort's worker counters to atomic variables.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Convert Sharedsort's worker counters to atomic variables.
Date: 2026-09-22 18:51:19
Message-ID: E1x95aJ-00000000oE4-2Oyy@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Convert Sharedsort's worker counters to atomic variables.

Currently, currentWorker and workersFinished are ints protected by
a spinlock. By converting them to atomic variables, we can remove
the spinlock. Note that the spinlock also covered the write of
each worker's tape metadata. Removing it is still okay: each
worker writes only its own slot, and the atomic increment that
follows is a full barrier. Furthermore, the leader doesn't read
the slot values until all workers have finished.

Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Tested-by: solai v <solai(dot)cdac(at)gmail(dot)com>
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ee97eef695e8be9153595131f8b63e4b1b3e8196

Modified Files
--------------
src/backend/utils/sort/tuplesort.c | 30 ++++++++----------------------
1 file changed, 8 insertions(+), 22 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-09-22 19:23:32 pgsql: Convert SharedFileSet->refcnt to an atomic variable.
Previous Message Nathan Bossart 2026-09-22 18:22:28 pgsql: Convert PROC_HDR->startupBufferPinWaitBuf to an atomic variable.