Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jun 2004 22:37:36 +0200
From:      "Ali Niknam" <ali@transip.nl>
To:        "Robert Watson" <rwatson@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD 5.2.1: Mutex/Spinlock starvation?
Message-ID:  <017001c44a73$c64d5db0$0400a8c0@redguy>
References:  <Pine.NEB.3.96L.1040604153442.34555O-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> Welcome :-).
>

Thank you :)

> Actually, by default, most mutexes in the system are sleep mutexes, so
> they sleep on contention rather than spinning.  In some cases, this
> actually hurts more than spinning, because if the mutex is released
> quickly by the holder, then you pay the context switches which cost
> more than spinning for the short period of time.
>
> You might want to try adding "options ADAPTIVE_MUTEXES" to your kernel
> configuration, which will cause mutexes to spin briefly on SMP systems
> before sleeping, and has been observed to improve performance quite a
> bit.
>

Interesting; could switching to SCHED_ULE help as well ? Since afaik the
processes get re-scheduled?
Also could this be the reason that system gets to use so much cpu (like 70%
of overal cpu)? That it needs to reschedule ~1000 processes continuesly ?

> If you have a lower tolerance for instability, there are a number of
> minor performance tweaks that can be easily back-ported to 5.2.1,
> such as the change to proc.h to make grabbing and releasing the proc
> lock conditional on p_stops having events defined.  This removes
> several mutex operations from each system call, and I've observed the
> difference in a pretty measurable way on micro-benchmarks.  It's also
> pretty low risk.  The change is src/sys/sys/proc.h:1.366.  There are
> some other related changes that can probably be dug up, including
> changes to improve the performance of the scheduler in the presence
> of threads, etc.

if all else fails i'll start doing this, thanks for the suggestion!

-- 
 Ali Niknam <ali@transip.nl> | tel 0182-504424 | fax 0182-504460
 Transip B.V. | http://www.transip.nl/ | Mensen met verstand van zaken.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?017001c44a73$c64d5db0$0400a8c0>