pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Cc: dipiets@amazon.com
Subject: Re: use a non-locking initial test in TAS_SPIN on AArch64
Date: Wed, 8 Jan 2025 16:38:02 -0600
Message-ID: <Z37-Svaqt7XCBcXP@nathan> (raw)
In-Reply-To: <tb6d2bg5a3so2325opkaow3ptkvpgpxzz3nnkehb3x7d77g3sx@xjid7uptuoni>
References: <ZxgDEb_VpWyNZKB_@nathan>
	<Z37AA6-SsJoLaifa@nathan>
	<tdex7aj3zrvdu22dfgtljbrybrjezbjpr374otnadi6qxywkmc@rzxtb2fbubpy>
	<Z371r_AVOU0WCrBr@nathan>
	<tb6d2bg5a3so2325opkaow3ptkvpgpxzz3nnkehb3x7d77g3sx@xjid7uptuoni>

On Wed, Jan 08, 2025 at 05:25:24PM -0500, Andres Freund wrote:
> On 2025-01-08 16:01:19 -0600, Nathan Bossart wrote:
>> But I did retry my test from upthread without pg_stat_statements and was
>> surprised to find a reproducible 4-6% regression.
> 
> Uh, huh. I assume this was readonly pgbench with 256 clients just as you had
> tested upthread? I don't think there's any hot spinlock meaningfully involved
> in that workload?  A r/w workload is a different story, but upthread you
> mentioned select-only.
> 
> Do you see any spinlock in profiles?

Yes, this was using 256 clients.  Looking closer, I don't see anything
spinlock related anywhere near the top of perf.

>> I'm not seeing any obvious differences in perf, but I do see that the thread
>> for adding TAS_SPIN() for PPC mentions a regression at lower contention
>> levels [0].  Perhaps the non-locked test is failing often enough to hurt
>> performance in this case...  Whatever it is, it'll be mighty frustrating to
>> miss out on a
>> >7x gain because of a 4% regression.
> 
> I don't think the explanation can be that simple - even with TAS_SPIN defined,
> we do try to acquire the lock once without using TAS_SPIN:
> 
> #if !defined(S_LOCK)
> #define S_LOCK(lock) \
> 	(TAS(lock) ? s_lock((lock), __FILE__, __LINE__, __func__) : 0)
> #endif	 /* S_LOCK */
> 
> Only s_lock() then uses TAS_SPIN(lock).

Ah, right.  FWIW I tried setting a cap on the number of times we do a
non-locked test, and the results still showed the regression, which seems
to match your intuition here.

> I wonder if you're hitting an extreme case of binary-layout related effects?
> I've never seen them at this magnitude though.  I'd suggest using either lld
> or mold as linker and comparing the numbers for a few
> -Wl,--shuffle-sections=$seed seed values.

Will do.

-- 
nathan





view thread (22+ messages)  latest in thread

Message-ID: <Z37-Svaqt7XCBcXP@nathan>
Permalink:  ../Z37-Svaqt7XCBcXP@nathan/
Also on:    postgresql.org/message-id/Z37-Svaqt7XCBcXP@nathan

 · 

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: nathandbossart@gmail.com, andres@anarazel.de, dipiets@amazon.com
  Subject: Re: use a non-locking initial test in TAS_SPIN on AArch64
  In-Reply-To: <Z37-Svaqt7XCBcXP@nathan>

* 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