From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 4 13:38:24 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5622616A4CF; Fri, 4 Jun 2004 13:38:24 -0700 (PDT) Received: from relay.transip.nl (relay.transip.nl [80.69.66.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2258143D39; Fri, 4 Jun 2004 13:38:24 -0700 (PDT) (envelope-from ali@transip.nl) Received: from redguy (peris.demon.nl [212.238.139.202]) by relay.transip.nl (Postfix) with SMTP id 1968E34A36B; Fri, 4 Jun 2004 22:37:36 +0200 (CEST) Message-ID: <017001c44a73$c64d5db0$0400a8c0@redguy> From: "Ali Niknam" To: "Robert Watson" References: Date: Fri, 4 Jun 2004 22:37:36 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Mailman-Approved-At: Sat, 05 Jun 2004 04:47:53 -0700 cc: freebsd-hackers@freebsd.org Subject: Re: FreeBSD 5.2.1: Mutex/Spinlock starvation? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jun 2004 20:38:24 -0000 > 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 | tel 0182-504424 | fax 0182-504460 Transip B.V. | http://www.transip.nl/ | Mensen met verstand van zaken.