From owner-freebsd-current Mon Sep 3 1:52: 6 2001 Delivered-To: freebsd-current@freebsd.org Received: from elvis.mu.org (elvis.mu.org [216.33.66.196]) by hub.freebsd.org (Postfix) with ESMTP id 2387E37B403 for ; Mon, 3 Sep 2001 01:52:04 -0700 (PDT) Received: by elvis.mu.org (Postfix, from userid 1192) id 2367E81D01; Mon, 3 Sep 2001 03:52:04 -0500 (CDT) Date: Mon, 3 Sep 2001 03:52:04 -0500 From: Alfred Perlstein To: Bruce Evans Cc: John Polstra , current@FreeBSD.ORG, gersh@sonn.com Subject: Re: MALLOC/FREE macro useage. Message-ID: <20010903035204.M81307@elvis.mu.org> References: <20010902211606.I81307@elvis.mu.org> <20010903183414.X6804-100000@alphplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010903183414.X6804-100000@alphplex.bde.org>; from bde@zeta.org.au on Mon, Sep 03, 2001 at 06:47:22PM +1000 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Bruce Evans [010903 03:47] wrote: > On Sun, 2 Sep 2001, Alfred Perlstein wrote: > > > The reason for the macro is that when the size paramter is a constant > > there's an evil trick that makes selecting the malloc bucket really > > cheap. > > That's not the reason. The size parameter is not constant since MALLOC() > just calls malloc(). I wouldn't call the big conditional statement in > BUCKETINDX() an evil trick. But perhaps it should be replaced by fls(). > A builtin fls() could handle constants just as well. Well it was the original intent, in fact it was done such that when a constant was used and the bucket wasn't empty the code would expand to just a handful of instructions. This is mentioned in "Design and Implementation". As far as BUCKETINDX(), i almost thought that instead of doing power of two buckets, we could use mod-32, this would do nifty things like when we just barely go over 128 bytes for something we don't waste nearly double our allocation. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' '"Java" developer, like "special" Olympics, right?' - Bill Paul To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message