Re: Wait free LW_SHARED acquisition - v0.9 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Wait free LW_SHARED acquisition - v0.9
Date
Msg-id 20141008133533.GA5053@alap3.anarazel.de
Whole thread Raw
In response to Wait free LW_SHARED acquisition  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Wait free LW_SHARED acquisition - v0.9
Re: Wait free LW_SHARED acquisition - v0.9
Re: Wait free LW_SHARED acquisition - v0.9
Re: Wait free LW_SHARED acquisition - v0.9
List pgsql-hackers
Hi,

Attached you can find the next version of my LW_SHARED patchset. Now
that atomics are committed, it seems like a good idea to also add their
raison d'être.

Since the last public version I have:
* Addressed lots of Amit's comments. Thanks!
* Peformed a fair amount of testing.
* Rebased the code. The volatile removal made that not entirely
  trivial...
* Significantly cleaned up and simplified the code.
* Updated comments and such
* Fixed a minor bug (unpaired HOLD/RESUME_INTERRUPTS in a corner case)

The feature currently consists out of two patches:
1) Convert PGPROC->lwWaitLink into a dlist. The old code was frail and
   verbose. This also does:
    * changes the logic in LWLockRelease() to release all shared lockers
      when waking up any. This can yield some significant performance
      improvements - and the fairness isn't really much worse than
      before,
      as we always allowed new shared lockers to jump the queue.

    * adds a memory pg_write_barrier() in the wakeup paths between
      dequeuing and unsetting ->lwWaiting. That was always required on
      weakly ordered machines, but f4077cda2 made it more urgent. I can
      reproduce crashes without it.
2) Implement the wait free LW_SHARED algorithm.

Personally I'm quite happy with the new state. I think it needs more
review, but I personally don't know of anything that needs
changing. There's lots of further improvements that could be done, but
let's get this in first.

Greetings,

Andres Freund

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

Attachment

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Promise index tuples for UPSERT
Next
From: Fujii Masao
Date:
Subject: Re: PENDING_LIST_CLEANUP_SIZE - maximum size of GIN pending list Re: HEAD seems to generate larger WAL regarding GIN index