From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 15 15:47:43 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4C5FB16A400 for ; Fri, 15 Jun 2007 15:47:43 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from www.pkgsrc-box.org (www.ostsee-abc.de [62.206.222.50]) by mx1.freebsd.org (Postfix) with ESMTP id 0B34813C46E for ; Fri, 15 Jun 2007 15:47:42 +0000 (UTC) (envelope-from joerg@britannica.bec.de) Received: from britannica.bec.de (www.pkgsrc-box.org [127.0.0.1]) by www.pkgsrc-box.org (Postfix) with ESMTP id 7A93DE7A3F9 for ; Fri, 15 Jun 2007 15:47:34 +0000 (UTC) Received: by britannica.bec.de (Postfix, from userid 1000) id E4C2F7D31; Fri, 15 Jun 2007 17:47:03 +0200 (CEST) Date: Fri, 15 Jun 2007 17:47:03 +0200 From: Joerg Sonnenberger To: freebsd-hackers@freebsd.org Message-ID: <20070615154703.GA2247@britannica.bec.de> Mail-Followup-To: freebsd-hackers@freebsd.org References: <200706150104.l5F14RjG001010@apollo.backplane.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200706150104.l5F14RjG001010@apollo.backplane.com> User-Agent: Mutt/1.5.13 (2006-08-11) Subject: Re: Reason for doing malloc / bzero over calloc (performance)? 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: Fri, 15 Jun 2007 15:47:43 -0000 On Thu, Jun 14, 2007 at 06:04:27PM -0700, Matthew Dillon wrote: > From this point of view it is much, much better to bzero() memory that > is already mapped then it is to map/unmap new memory. For kernel land, you are right. For userland, there's one big down-side to always bzero/memset newly allocated memory: it touches the page and thereby can add a lot of back pressure on you are not having that much memory. This can be completely uncessary at that point and at least one application of using calloc with large parameter values is creation of a hash table. Forcing it to consume memory is not such a good idea. Joerg