Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jan 2004 21:59:24 +0100
From:      Radim Kolar <hsn@netmag.cz>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/61691: very bad performance of realloc()
Message-ID:  <E1AjPRc-0000PN-1v@asura.bsd>
Resent-Message-ID: <200401212220.i0LMKAaJ058969@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         61691
>Category:       kern
>Synopsis:       very bad performance of realloc()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 21 14:20:10 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Radim Kolar
>Release:        FreeBSD 5.2-RELEASE i386
>Organization:
Sanatana Dharma
>Environment:
System: FreeBSD asura.bsd 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Thu Jan 15 18:35:03 CET 2004 root@asura.bsd:/usr/obj/usr/src/sys/GENERIC i386

>Description:
Prob 1: 
Current implementation of realloc(3) is slow, it looks like it copies data
on reallocation even when it is not needed. This causes that programs
which are using more realloc calls runs very slowly. I think that
default malloc flag do not includes 'R', so it should run very fast.

Prob 2: Second problem is if you reallocate to more than 18 MB of memory,
malloc eats  about  3  times  more memory from system, than needed for
allocation. Maybe this have something to do with possible exhausting malloc
cache size (default 16 pages). 

I have used default malloc flags, using madvice has zero effect.
>How-To-Repeat:
I have wrote a small testing program.
You can get it from http://home.worldonline.cz/~cz210552/forkbomb.html

prob1:
run it ./forkbomb -m -l 64 under FreeBSD and Linux/gnulibc 2.3.2.

prob2:
run it ./forkbomb -m -l 20, see top(1) how many memory  is allocated (61MB)
run it ./forkbomb -m -l 16, looks okay (except slowness) (17.7MB)
>Fix:
Port glibc2.3 memory allocation alg. to freebsd libc.
	
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1AjPRc-0000PN-1v>