Re: Spinlocks and compiler/memory barriers

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Spinlocks and compiler/memory barriers
Date: 2014-09-09 22:00:24
Message-ID: 20140909220024.GE24649@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-09-09 17:54:03 -0400, Robert Haas wrote:
> So, that's committed, then.

Yay, finally.

> I think we should pick something that uses
> spinlocks and is likely to fail spectacularly if we haven't got this
> totally right yet, and de-volatilize it. And then watch to see what
> turns red in the buildfarm and/or which users start screaming.

Good plan.

> I'm inclined to propose lwlock.c as a candidate, since that's very
> widely used and a place where we know there's significant contention.

I suggest, additionally possibly, GetSnapshotData(). It's surely one of
the hottest functions in postgres, and I've seen some performance
increases from de-volatilizing it. IIRC it requires one volatile cast in
one place to enforce that a variable is accessed only once. Not sure if
we want to add such volatile casts or use something like linux'
ACCESS_ONCE macros for some common types. Helps to grep for places
worthy of inspection.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2014-09-09 22:03:03 Re: pg_background (and more parallelism infrastructure patches)
Previous Message Robert Haas 2014-09-09 21:54:03 Re: Spinlocks and compiler/memory barriers