Re: Reducing ClogControlLock contention

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reducing ClogControlLock contention
Date: 2015-06-30 07:22:51
Message-ID: CANP8+jKXq8Xt4_o7nVUrHZu8AkPtvCL-QR_sOVa091Ft7nZ-Tg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 30 June 2015 at 08:13, Michael Paquier <michael(dot)paquier(at)gmail(dot)com> wrote:

>
>
> On Tue, Jun 30, 2015 at 4:02 PM, Simon Riggs <simon(at)2ndquadrant(dot)com>
> wrote:
>
>> ClogControlLock contention is high at commit time. This appears to be due
>> to the fact that ClogControlLock is acquired in Exclusive mode prior to
>> marking commit, which then gets starved by backends running
>> TransactionIdGetStatus().
>>
>> Proposal for improving this is to acquire the ClogControlLock in Shared
>> mode, if possible.
>>
>> This is safe because people checking visibility of an xid must always run
>> TransactionIdIsInProgress() first to avoid race conditions, which will
>> always return true for the transaction we are currently committing. As a
>> result, we never get concurrent access to the same bits in clog, which
>> would require a barrier.
>>
>> Two concurrent writers might access the same word concurrently, so we
>> protect against that with a new CommitLock. We could partition that by
>> pageno also, if needed.
>>
>
> Could it be possible to see some performance numbers? For example with a
> simple pgbench script doing a bunch of tiny transactions, with many
> concurrent sessions (perhaps hundreds).
>

I'm more interested to see if people think it is safe.

This contention is masked by contention elsewhere, e.g. ProcArrayLock, so
the need for testing here should come once other patches ahead of this are
in.

--
Simon Riggs http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2015-06-30 07:31:10 Re: Reducing ClogControlLock contention
Previous Message Michael Paquier 2015-06-30 07:22:26 Missing return value checks in jsonfuncs.c