Re: Fine-grained locking for POSIX local sockets (UNIX domain sockets)

From: Kris Kennaway <kris_at_obsecurity.org>
Date: Mon, 8 May 2006 14:43:22 -0400
On Mon, May 08, 2006 at 06:43:31PM +0800, David Xu wrote:
> On Monday 08 May 2006 14:52, Kris Kennaway wrote:
> > OK, David's patch fixes the umtx thundering herd (and seems to give a
> > 4-6% boost).  I also fixed a thundering herd in FILEDESC_UNLOCK (which
> > was also waking up 2-7 CPUs at once about 30% of the time) by doing
> > s/wakeup/wakeup_one/.  This did not seem to give a performance impact
> > on this test though.
> >....
> > filedesc contention is down by a factor of 3-4, with corresponding
> > reduction in the average hold time.  The process lock contention
> > coming from the signal delivery wakeup has also gone way down for some
> > reason.
> >
> 
> I found that mysqld frequently calls alarm() in its file thr_alarm.c and 
> thr_kill() to send SIGALRM to its timer thread to wake it up, the timer 
> thread itself is being blocked in sigwait(), normally the alarm timer will
> be expired in a second, so the kernel will periodically call psignal to find
> a thread which can handle the signal, it means kernel has to periodically
> walk through thread list with process lock and scheduler held, this is
> very expensive.
> 
> thr_kill will in most time wake up the timer thread earlier, in thr_kill
> syscall,  kernel has to walk through thread list to find a thread whose
> thread is matching the given id, the function thread_find()
> uses a linear searching algorithm, it is slow, if there are lots of thread in
> the process,  the process lock will be holden too long, I think that's the 
> reason why you have seen so many process lock contention, if you
> define USE_ALARM_THREAD in mysql header file, the contention should
> be decreased ( I hope ), patch:

Hmm, with this patch mysql 4.1 seems to crash at startup.  I haven't
yet had time to investigate.  Is anyone else seeing this?

Kris

Received on Mon May 08 2006 - 16:43:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:55 UTC