Re: Wierd context-switching issue on Xeon - Mailing list pgsql-performance

From Kenneth Marshall
Subject Re: Wierd context-switching issue on Xeon
Date
Msg-id 20040421220231.GA18010@it.is.rice.edu
Whole thread Raw
In response to Re: Wierd context-switching issue on Xeon  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
On Wed, Apr 21, 2004 at 02:51:31PM -0400, Tom Lane wrote:
> The context swap storm is happening because of contention at the next
> level up (LWLocks rather than spinlocks).  It could be an independent
> issue that just happens to be triggered by the same sort of access
> pattern.  I put forward a hypothesis that the cache miss storm caused by
> the test-and-set ops induces the context swap storm by making the code
> more likely to be executing in certain places at certain times ... but
> it's only a hypothesis.
>
If the context swap storm derives from LWLock contention, maybe using
a random order to assign buffer locks in buf_init.c would prevent
simple adjacency of buffer allocation to cause the storm. Just offsetting
the assignment by the cacheline size should work. I notice that when
initializing the buffers in shared memory, both the buf->meta_data_lock
and the buf->cntx_lock are immediately adjacent in memory. I am not
familiar enough with the flow through postgres to see if there could
be "fighting" for those two locks. If so, offsetting those by the cache
line size would also stop the context swap storm.

--Ken

pgsql-performance by date:

Previous
From: brad-pgperf@duttonbros.com
Date:
Subject: index usage
Next
From: CoL
Date:
Subject: Re: Looking for ideas on how to speed up warehouse loading