Re: Reduce ProcArrayLock contention

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reduce ProcArrayLock contention
Date: 2015-06-30 03:21:11
Message-ID: CAA4eK1+k0ekVhvta6Ms90TAqbpHL_kP3Pj94MBYTwx=c7HTLqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 29, 2015 at 10:52 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
>
> On 29 June 2015 at 18:11, Andres Freund <andres(at)anarazel(dot)de> wrote:
>>
>> On June 29, 2015 7:02:10 PM GMT+02:00, Simon Riggs <simon(at)2ndQuadrant(dot)com>
wrote:
>> >On 29 June 2015 at 16:27, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> >
>> >
>> >> Thanks to Robert Haas for having discussion (offlist) about the idea
>> >> and suggestions to improve it and also Andres Freund for having
>> >> discussion and sharing thoughts about this idea at PGCon.
>> >>
>> >
>> >Weird. This patch is implemented exactly the way I said to implement it
>> >publicly at PgCon.
>> >
>> >Was nobody recording the discussion at the unconference??
>>
>> Amit presented an earlier version of this at the in unconference?
>
>
> Yes, I know. And we all had a long conversation about how to do it
without waking up the other procs.
>
> Forming a list, like we use for sync rep and having just a single process
walk the queue was the way I suggested then and previously.
>

Yes, I remember very well about your suggestion which you have
given during Unconference and I really value that idea/suggestion.
Here, the point is that I could get chance to have in-person discussion
with Robert and Andres where they have spent more time discussing
about the problem (Robert has discussed about this much more apart
from PGCon as well), but that doesn't mean I am not thankful of the
ideas or suggestions I got from you and or others during Unconference.

Thank you for participating in the discussion and giving suggestions
and I really mean it, as I felt good about it even after wards.

Now, I would like to briefly explain how allow-one-waker idea has
helped to improve the patch as not every body here was present
in that Un-conference. The basic problem I was seeing during
initial version of patch was that I was using LWLockAcquireOrWait
call for all the clients who are not able to get ProcArrayLock
(conditionally in the first attempt) and then after waking each proc
was checking if it's XID is cleared and if not they were again try
to AcquireOrWait for ProcArrayLock, this was limiting the patch
to improve performance at somewhat moderate client count like
32 or 64 because even trying for LWLock in exclusive mode again
and again was the limiting factor (I have tried with
LWLockAcquireConditional as well instead of LWLockAcquireOrWait,
though it helped a bit but not very much). Allowing just one-client
to become kind of Group leader to clear the other proc's xid and wake
them-up and all the other proc's waiting after adding them to
pendingClearXid
list has helped to reduce the bottleneck around procarraylock significantly.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-06-30 03:54:29 Re: Bug in bttext_abbrev_convert()
Previous Message Robert Haas 2015-06-30 03:05:55 Re: anole: assorted stability problems