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

From Bruce Momjian
Subject Re: LWLock contention: I think I understand the problem
Date
Msg-id 200112300150.fBU1om500503@candle.pha.pa.us
Whole thread Raw
In response to Re: LWLock contention: I think I understand the problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: LWLock contention: I think I understand the problem  ("Jeffrey W. Baker" <jwbaker@acm.org>)
List pgsql-hackers
> Bruce Momjian <pgman@candle.pha.pa.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?

OK, here are the results on BSD/OS 4.2 on a 2-cpu system.  The first is
before the patch, the second after.  Both average 14tps, so the patch
has no negative effect on my system.  Of course, it has no positive
effect either.  :-)


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 1
number of transactions per client: 1000
number of transactions actually processed: 1000/1000
tps = 15.755389(including connections establishing)
tps = 15.765396(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 10
number of transactions per client: 1000
number of transactions actually processed: 10000/10000
tps = 16.926562(including connections establishing)
tps = 16.935963(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 25
number of transactions per client: 1000
number of transactions actually processed: 25000/25000
tps = 16.219866(including connections establishing)
tps = 16.228470(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 50
number of transactions per client: 1000
number of transactions actually processed: 50000/50000
tps = 12.071730(including connections establishing)
tps = 12.076470(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 1
number of transactions per client: 1000
number of transactions actually processed: 1000/1000
tps = 13.784963(including connections establishing)
tps = 13.792893(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 10
number of transactions per client: 1000
number of transactions actually processed: 10000/10000
tps = 16.287374(including connections establishing)
tps = 16.296349(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 25
number of transactions per client: 1000
number of transactions actually processed: 25000/25000
tps = 15.810789(including connections establishing)
tps = 15.819153(excluding connections establishing)
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 50
number of transactions per client: 1000
number of transactions actually processed: 50000/50000
tps = 12.030432(including connections establishing)
tps = 12.035500(excluding connections establishing)

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Latest datetime changes produce gcc complaints
Next
From: Bruce Momjian
Date:
Subject: Re: Latest datetime changes produce gcc complaints