From owner-freebsd-current@FreeBSD.ORG Mon Dec 12 03:47:33 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DEC0316A41F for ; Mon, 12 Dec 2005 03:47:33 +0000 (GMT) (envelope-from bucht@acc.umu.se) Received: from mail.acc.umu.se (mail.acc.umu.se [130.239.18.156]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0F25943D6D for ; Mon, 12 Dec 2005 03:47:32 +0000 (GMT) (envelope-from bucht@acc.umu.se) Received: from localhost (localhost [127.0.0.1]) by amavisd-new (Postfix) with ESMTP id E7E5B498E; Mon, 12 Dec 2005 04:47:31 +0100 (MET) Received: from [192.168.1.100] (53dbce07.umea.cust.skycom.se [83.219.206.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.acc.umu.se (Postfix) with ESMTP id ADAFC498A; Mon, 12 Dec 2005 04:47:30 +0100 (MET) Message-ID: <439CF318.4070903@acc.umu.se> Date: Mon, 12 Dec 2005 04:48:40 +0100 From: Johan Bucht User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jason Evans References: <20051212014852.GA8775@shaka.acc.umu.se> <9FAD2B4B-C167-42D7-A8E7-BE03F4C07543@canonware.com> <439CEB74.9080505@acc.umu.se> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at acc.umu.se Cc: current@freebsd.org Subject: Re: New libc malloc patch 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: Mon, 12 Dec 2005 03:47:34 -0000 Jason Evans wrote: >> Isn't 8 byte alignment expected by some applications? > > > Yes, 8 or 16 byte alignment is expected (in fact I'm of the opinion > that we should be using 16 byte alignment on i386 due to SSE2/SSE3). > If I understand your question correctly, you're asking how I get away > with 4 byte tags. Consider that (assuming 8-byte quantum) a malloc > (16) call must actually be serviced by at least 24 bytes internally, > in order to pad to the next quantum size. If I used 8 byte tags, > then malloc(17) would require 32 bytes internally. By using 4 byte > tags, malloc(13)..malloc(20) can be serviced by 24 bytes internally. > At least one implementation (the OS X malloc implementation) uses 2 > byte tags, but this has two problems: 1) unaligned memory access is > slow on some architectures, and 2) it's too small to handle large > object sizes, so a different allocation strategy has to be used > starting at ~12 KB. > Well, I just wondered how you avoided unaligned accesses with a 4 byte tag. >> How do you know if a allocation is huge if you don't have a tag? > > > I know an allocation is huge if its base address is chunk-aligned. > The actual size is stored in a red-black tree node, which is > allocated separately. Ok, expected it was through the address, thanks for answering anyway. Gonna take some time reading through the code before asking more stupid questions. =) /Johan Bucht