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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-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

Attachment Content-Type Size
unknown_filename text/plain 7.2 KB

In response to

Responses

Browse pgsql-hackers by date

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

Browse pgsql-odbc by date

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