Re: LWLock contention: I think I understand the problem - Mailing list pgsql-hackers

From Jeffrey W. Baker
Subject Re: LWLock contention: I think I understand the problem
Date
Msg-id Pine.LNX.4.33.0112291220230.30167-100000@windmill.gghcwest.com
Whole thread Raw
In response to LWLock contention: I think I understand the problem  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

On Sat, 29 Dec 2001, Tom Lane wrote:

> After some further experimentation, I believe I understand the reason for
> the reports we've had of 7.2 producing heavy context-swap activity where
> 7.1 didn't.  Here is an extract from tracing lwlock activity for one
> backend in a pgbench run:

...

> It would seem, therefore, that lwlock.c's behavior of immediately
> granting the lock to released waiters is not such a good idea after all.
> Perhaps we should release waiters but NOT grant them the lock; when they
> get to run, they have to loop back, try to get the lock, and possibly go
> back to sleep if they fail.  This apparent waste of cycles is actually
> beneficial because it saves context swaps overall.

Sounds reasonable enough, but there seems to be a possibility of a process
starving.  For example, if A releases the lock, B and C wake up, B gets
the lock.  Then B releases the lock, A and C wake, and A gets the lock
back.  C gets CPU time but never gets the lock.

BTW I am not on this list.

-jwb



pgsql-hackers by date:

Previous
From: james@unifiedmind.com (James Thornton)
Date:
Subject: DDLs in Transactions...?
Next
From: Tom Lane
Date:
Subject: Re: Are we accepting cancel interrupts too often?