Re: Wait free LW_SHARED acquisition - v0.2

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Wait free LW_SHARED acquisition - v0.2
Date: 2014-10-24 10:35:03
Message-ID: 20141024103503.GI5790@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-10-24 15:59:30 +0530, Amit Kapila wrote:
> > > and w.r.t performance it can lead extra
> > > function call, few checks and I think in some cases even can
> > > acquire/release spinlock.
> >
> > I fail to see how that could be the case.
>
> Won't it happen incase first backend sets releaseOK to true and another
> backend which tries to wakeup waiters on lock will acquire spinlock
> and tries to release the waiters.

Sure, that can happen.

> > And again, this is code that's
> > only executed around a couple syscalls. And the cacheline will be
> > touched around there *anyway*.
>
> Sure, but I think syscalls are required in case we need to wake any
> waiter.

It won't wake up a waiter if there's none on the list.
> > > > And it'd be a pretty pointless
> > > > behaviour, leading to useless increased contention. The only time it'd
> > > > make sense for X to be woken up is when it gets run faster than the S
> > > > processes.
> > >
> > > Do we get any major benefit by changing the logic of waking up waiters?
> >
> > Yes.
>
> I think one downside I could see of new strategy is that the chance of
> Exclusive waiter to take more time before getting woked up is increased
> as now it will by pass Exclusive waiters in queue.

Note that that *already* happens for any *new* shared locker that comes
in. It doesn't really make sense to have share lockers queued behind the
exclusive locker if others just go in front of it anyway.

> > > Code is more readable, but I don't understand why you
> > > want to do refactoring as part of this patch which ideally
> > > doesn't get any benefit from the same.
> >
> > I did it first without. But there's required stuff like
> > LWLockDequeueSelf(). And I had several bugs because of the list stuff.
> >
> > And I did separate the conversion into a separate patch?
>
> Yeah, but the main patch for wait free LW_SHARED also uses
> it.

Well, the only thing that it could have done given that the other patch
is a preqrequisite is reverting the behaviour?

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 Michael Paquier 2014-10-24 11:46:19 Re: Function array_agg(array)
Previous Message Amit Kapila 2014-10-24 10:29:30 Re: Wait free LW_SHARED acquisition - v0.2