From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 23 22:25:15 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15225106564A for ; Mon, 23 Jan 2012 22:25:15 +0000 (UTC) (envelope-from etnapierala@googlemail.com) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by mx1.freebsd.org (Postfix) with ESMTP id A04358FC1C for ; Mon, 23 Jan 2012 22:25:14 +0000 (UTC) Received: by wibhn14 with SMTP id hn14so3898935wib.13 for ; Mon, 23 Jan 2012 14:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=kTkSq6JifGlEPicaq2BJN5gSYgZ8AO9FB0kPolsVBqs=; b=Cbnm0xgWV5d5qXsbL4Z9ted6F6hmw8MsNodYJWR/OrCV2PhH75a5ecb49hQDES5tIY 7HaxZ59AXNDLKXa4b1hvvY6MaWTlcGtfsNWStg0Esmc3vg/xAmozj3QnRPCM2t40qPvF kY4WJdlRzFrVjvyhGqpiiUBmF+cbUjnuwmx6w= Received: by 10.180.107.99 with SMTP id hb3mr16330159wib.0.1327355708621; Mon, 23 Jan 2012 13:55:08 -0800 (PST) Received: from geosci (45.81.datacomsa.pl. [195.34.81.45]) by mx.google.com with ESMTPS id ex2sm45560828wib.1.2012.01.23.13.55.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Jan 2012 13:55:07 -0800 (PST) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Mon, 23 Jan 2012 22:55:03 +0100 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: freebsd-hackers@freebsd.org Message-ID: <20120123215503.GA64787@geosci> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Speeding up the loader(8). X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2012 22:25:15 -0000 Some time ago I've spent some time on trying to speed up loading modules by the loader(8). Result can be found at: http://people.freebsd.org/~trasz/fast-loader-3.diff This patch solves three issues: 1. As it is now, the code in biosdisk.c tries very hard to split reasonably sized (up to 64kB, IIRC) requests into smaller ones. 2. The code in biosdisk.c rereads the partition table and probably some filesystem metadata every time a file gets opened, i.e. for every module. These reads bypass the bcache. 3. The code in bcache.c doesn't really implement an LRU - it implements 'least recently added' algorithm, i.e. a kind of queue. Not that it matters much, since it flushes the elements two seconds after caching them anyway. I replaced it with Least Frequently Used. LRU didn't behave well, as it tended to replace metadata with data used only once. In my tests under VMWare Fusion, this cut the modules loading time by half. I don't intend to commit the patch as-is - the first part looks dangerous (the splitting was probably done for a reason), the second is hackish, and the third doesn't improve anything by itself. I'm working on something else at a moment; feel free to pick this up. -- If you cut off my head, what would I say? Me and my head, or me and my body?