Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Oct 2002 21:39:17 +0100
From:      Tony Finch <dot@dotat.at>
To:        Terry Lambert <tlambert2@mindspring.com>
Cc:        Tony Finch <dot@dotat.at>, hackers@freebsd.org
Subject:   Re: malloc
Message-ID:  <20021022213917.B29425@chiark.greenend.org.uk>
In-Reply-To: <3DB5AB73.E334629@mindspring.com>; from tlambert2@mindspring.com on Tue, Oct 22, 2002 at 12:48:03PM -0700
References:  <E183u5Y-0003Yc-00@cse.cs.huji.ac.il> <E183xYK-0003aB-00@chiark.greenend.org.uk> <3DB5A07F.AA118FA6@mindspring.com> <20021022202533.A29425@chiark.greenend.org.uk> <3DB5AB73.E334629@mindspring.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 22, 2002 at 12:48:03PM -0700, Terry Lambert wrote:
> Tony Finch wrote:
> > 
> > Linux [clears memory in the kernel before handing it over to
> > userland], and you appeared to be saying that it doesn't which
> > is clearly wrong for the security reasons that you stated. It
> > therefore won't affect the relative performance.
> 
> Yes, it will.  It has to do with the use of anonymous memory
> being different between the systems.

The only significant difference I can see is that large callocs
are mmapped by gnu malloc which doesn't then re-clear them, whereas
phk malloc only mmaps its page table (not memory returned to the
user) so calloc always clears memory, which happens to be redundant
if the pages have just come from brk (which isn't always the case).

However calloc isn't relevant to this benchmark.

[If you are talking about a different difference, perhaps you
should say what it is so that this thread doesn't get even more
unnecessarily long.]

> You are arguing that there is nothing that can account for the
> performance difference, when in fact there is a measured
> performance difference.

No, I'm saying that some of what you said is either wrong or
misleading, and the comment about security was especially stupid.

> > PHK malloc uses MAP_ANON on FreeBSD, not /dev/zero -- it uses the
> > latter only if compiled for Solaris.
> 
> And tell me, what does the Linux malloc use?

Exactly the same, and it uses MAP_ANONYMOUS on Linux. It uses mmap for
large allocations whereas phk malloc does not. Since both mmap and
sbrk get zero-filled pages from the kernel this shoudld make little
difference, except in the calloc case explained above.

Tony.
-- 
f.a.n.finch <dot@dotat.at> http://dotat.at/
FORTIES CROMARTY: EAST BECOMING CYCLONIC 7 TO SEVERE GALE 9, OCCASIONALLY
STORM 10 LATER. RAIN. MODERATE OR POOR.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021022213917.B29425>