From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 23 12:41:35 2004 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B0F4916A4CE; Fri, 23 Jan 2004 12:41:35 -0800 (PST) Received: from mail.tiscali.cz (stateless3.tiscali.cz [213.235.135.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9625A43D1D; Fri, 23 Jan 2004 12:41:33 -0800 (PST) (envelope-from hsn@netmag.cz) Received: from asura.bsd (213.235.70.170) by mail.tiscali.cz (6.7.018) id 3FB969350110C932; Fri, 23 Jan 2004 21:41:32 +0100 Received: from hsn by asura.bsd with local (Exim 4.24 #4 (Debian)) id 1Ak36p-0000c5-ML; Fri, 23 Jan 2004 16:20:35 +0100 Date: Fri, 23 Jan 2004 16:20:35 +0100 From: Radim Kolar To: Poul-Henning Kamp Message-ID: <20040123152035.GA2311@asura.bsd> References: <200401221457.i0MEvpXF075936@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200401221457.i0MEvpXF075936@freefall.freebsd.org> User-Agent: Mutt/1.4.1i cc: freebsd-bugs@FreeBSD.org cc: bug-followup@freebsd.org Subject: Re: kern/61691: very bad performance of realloc()/brk() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jan 2004 20:41:35 -0000 > 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. FreeBSD 5.2 =========== It looks that brk() syscall is quite slow in FreeBSD when comparing against Linux. FreeBSD calls 32 times brk() and 10 times mmap+munmap (for page directory). (hsn@ttyv0):~/forkbomb% time ./forkbomb -l 32 -i 256 -M --quit 12:45 Safety alarm at 300 sec. enabled. Actions: alloc 32 MB (step 1024 kB) and touch it. Forkbomb 1.2 started. ./forkbomb -l 32 -i 256 -M --quit 4.58s user 5.28s system 74% cpu 13.159 total linux2.4+glibc2.3.2 =================== Linux does 1 times mmap + 31 times mremap syscall Safety alarm at 300 sec. enabled. Actions: alloc 32 MB (step 1024 kB) and touch it. Forkbomb 1.2 started. ./forkbomb -l 32 -i 256 -M --quit 0.00s user 0.30s system 107% cpu 0.280 total Well my pr-report/wish is: optimize realloc() function (which is about 3 pages long) to avoid copying data while brk() is sufficient , because the reallocated block is last block.