Skip site navigation (1) Skip section navigation (2)

Re: LWLock contention: I think I understand the problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, "Jeffrey W(dot) Baker" <jwbaker(at)acm(dot)org>
Subject: Re: LWLock contention: I think I understand the problem
Date: 2001-12-29 20:49:33
Message-ID: 19822.1009658973@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-odbc
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> What you want to do is to wake up the sleeper but not give them the lock
> until they are actually running and can aquire it themselves.  

Yeah.  Essentially this is a partial reversion to the idea of a
spinlock.  But it's more efficient than our old implementation with
timed waits between retries, because (a) a process will not be awoken
unless it has a chance at getting the lock, and (b) when a contended-for
lock is freed, a waiting process will be made ready immediately, rather
than waiting for a time tick to elapse.  So, if the lock-releasing
process does block before the end of its quantum, the released process
is available to run immediately.  Under the old scheme, a process that
had failed to get a spinlock couldn't run until its select wait timed
out, even if the lock were now available.  So I think it's still a net
win to have the LWLock mechanism in there, rather than just changing
them back to spinlocks.

> If you code up a patch, I will test it on my SMP machine using pgbench. 
> Hopefully this will help Tatsuo's 4-way AIX machine too, and Linux.

Attached is a proposed patch (against the current-CVS version of
lwlock.c).  I haven't committed this yet, but it seems to be a win on
a single CPU.  Can people try it on multi CPUs?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-12-29 20:56:33
Subject: Re: TODO question
Previous:From: Jeffrey W. BakerDate: 2001-12-29 20:23:20
Subject: Re: LWLock contention: I think I understand the problem

pgsql-odbc by date

Next:From: Tom LaneDate: 2001-12-29 20:58:52
Subject: Re: LWLock contention: I think I understand the problem
Previous:From: Jeffrey W. BakerDate: 2001-12-29 20:23:20
Subject: Re: LWLock contention: I think I understand the problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group