From owner-freebsd-current@FreeBSD.ORG Wed Apr 4 07:42:36 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E85FA16A402 for ; Wed, 4 Apr 2007 07:42:36 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe02.swip.net [212.247.154.33]) by mx1.freebsd.org (Postfix) with ESMTP id C8A7413C483 for ; Wed, 4 Apr 2007 07:42:35 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [193.217.102.48] (account mc467741@c2i.net HELO [10.0.0.249]) by mailfe02.swip.net (CommuniGate Pro SMTP 5.1.7) with ESMTPA id 458318639; Wed, 04 Apr 2007 09:42:29 +0200 From: Hans Petter Selasky To: freebsd-current@freebsd.org Date: Wed, 4 Apr 2007 09:42:08 +0200 User-Agent: KMail/1.9.5 References: <20070401155910.O75869@fledge.watson.org> <20070403175953.A25236@fledge.watson.org> In-Reply-To: <20070403175953.A25236@fledge.watson.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704040942.08839.hselasky@c2i.net> Cc: performance@freebsd.org, Robert Watson , current@freebsd.org, Andrzej Tobola Subject: Re: filedesc_sx patch (20070401a) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2007 07:42:37 -0000 On Wednesday 04 April 2007 00:01, Robert Watson wrote: > On Sun, 1 Apr 2007, Robert Watson wrote: > > The attached patch moves file descriptor locks from being a custom > > mutex/sleep lock implemented using msleep() to an sx lock. With the new > > sx lock optimizations in place, this is now sensible, avoiding both a > > custom lock type and significantly improving performance. Kris has > > reported 2x-4x improvement in transactions/sec with MySQL using this > > patch, as it greatly reduces the cost of lock contention during file > > descriptor lookup for threaded applications, and also moves to shared > > locking to avoid exclusive acquisition for read-only operations (the vast > > majority in most workloads). Patch is below, but you can also download > > from: > > > > http://www.watson.org/~robert/freebsd/netperf/20070401a-filedesc-sx.diff > > > > I'm currently waiting for the sx lock changes to settle for a few days > > before committing, so will plan to commit this around Wednesday/Thursday > > of this week (unless serious problems arise). > > Andrzej has pointed out that shortly after I posted the patch, it came into > conflict with changes in VFS. I've updated the patch and posted it at: > > http://www.watson.org/~robert/freebsd/netperf/20070403-filedesc-sx.diff Just a small comment: @@ -60,10 +60,7 @@ u_short fd_cmask; /* mask for file creation */ u_short fd_refcnt; /* thread reference count */ u_short fd_holdcnt; /* hold count on structure + mutex */ - - struct mtx fd_mtx; /* protects members of this struct */ - int fd_locked; /* long lock flag */ - int fd_wanted; /* "" */ + struct sx fd_sx; /* protects members of this struct */ struct kqlist fd_kqlist; /* list of kqueues on this filedesc */ int fd_holdleaderscount; /* block fdfree() for shared close() */ int fd_holdleaderswakeup; /* fdfree() needs wakeup */ Maybe it is better if you order the elements by size. Then you don't waste so many extra bytes on platforms where the fields must be aligned. struct { struct sx fd_sx; struct kqlist fd_kqlist; int ...; u_short ....; }; --HPS