Lock contention (was Re: [PATCHES] update i386 spinlock for hyperthreading)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Manfred Spraul <manfred(at)colorfullife(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org, markw(at)osdl(dot)org
Subject: Lock contention (was Re: [PATCHES] update i386 spinlock for hyperthreading)
Date: 2003-12-29 22:50:52
Message-ID: 17465.1072738252@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

Manfred Spraul <manfred(at)colorfullife(dot)com> writes:
> Mark ran a DBT-2 testrun with the attached statistics patch applied: It
> collects stats about all lightweight locks and dumps them during
> shutdown. The hottest locks are

> Lock Acquire %contention sleep calls
> 8(WALInsertLock) 8679205 0.030410 263934
> 5(SInvalLock) 68396470 0.001298 88812
> 1(LockMgrLock) 64089418 0.079783 5113215
> 0(BufMgrLock) 246307425 0.120293 29629089

Okay, that more or less squares with my gut feelings about the system.
Good to have some proof.

> I remember there were patches that tried other algorithms instead of the
> simple LRU for the buffer manager. Has anyone tried to change the
> locking of the buffer manager?

LRU etc have nothing to do with this. The majority of trips into the
buffer manager are for ReadBuffer/ReleaseBuffer. What we need is to
figure a way for those operations to use finer-grain locks so they don't
contend so much. However, given that they need to access and possibly
modify global structures (the buffer lookup hashtable and free list),
it's not obvious how to do it. If we could think of a way to divide
those structures into separately lockable portions, we might get somewhere.

> The effect of padding the lightweight locks to a full cacheline appears
> to be negligable:

Good, that squares with what the Linux kernel people seem to think.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hunter Hillegas 2003-12-29 23:11:07 Select Non Alpha Contents of a Column
Previous Message Keith C. Perry 2003-12-29 22:33:35 Re: Is my MySQL Gaining ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Frank Finner 2003-12-29 23:17:45 Re: Is my MySQL Gaining ?
Previous Message William Yu 2003-12-29 22:36:19 Re: IEEE 754

Browse pgsql-patches by date

  From Date Subject
Next Message Christopher Browne 2003-12-30 02:01:45 Some Documentation Changes
Previous Message Manfred Spraul 2003-12-29 22:28:08 Re: update i386 spinlock for hyperthreading