kern/61691: very bad performance of realloc()

Radim Kolar hsn at netmag.cz
Wed Jan 21 14:20:16 PST 2004


>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 at 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:


More information about the freebsd-bugs mailing list