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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to