From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 23 13:00:46 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3465316A4CE for ; Fri, 23 Jan 2004 13:00:46 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D4F8143D5A for ; Fri, 23 Jan 2004 13:00:39 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i0NL0dFR060311 for ; Fri, 23 Jan 2004 13:00:39 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i0NL0d6o060310; Fri, 23 Jan 2004 13:00:39 -0800 (PST) (envelope-from gnats) Date: Fri, 23 Jan 2004 13:00:39 -0800 (PST) Message-Id: <200401232100.i0NL0d6o060310@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Poul-Henning Kamp" Subject: Re: kern/61691: very bad performance of realloc()/brk() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Poul-Henning Kamp List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jan 2004 21:00:46 -0000 The following reply was made to PR kern/61691; it has been noted by GNATS. From: "Poul-Henning Kamp" To: Radim Kolar Cc: freebsd-bugs@FreeBSD.org, bug-followup@FreeBSD.org Subject: Re: kern/61691: very bad performance of realloc()/brk() Date: Fri, 23 Jan 2004 21:51:36 +0100 In message <20040123152035.GA2311@asura.bsd>, Radim Kolar writes: >> You seem to be confused as to what responsibilities the programmer >> has when it comes to practicing sensible memory management. >I have run some benchmarks for you. There are doing 32 times realloc() in >1 MB chunks. I don't think that this is example of bad programming >practice. The major problem is that realloc() copies data while Linux >doesn't. No, as I said, the problem is you use realloc the wrong way. You should not malloc(1M) realloc(2M) realloc(3M) You should realloc(32M) do stuff realloc(now_i_know_the_size) For whatever value of 32M 99% of your data fit in. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.