Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Apr 2005 07:30:54 +0700 (ICT)
From:      "Chatchawan Wongsiriprasert" <cws@miraclenet.co.th>
To:        freebsd-performance@freebsd.org
Subject:   Slow realloc 
Message-ID:  <13101.210.86.179.115.1113957054.squirrel@210.86.179.115>

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

    Last week I got a request from my customer to check that why his
PHP code run much slower on FreeBSD than the Linux machine. After sometime
of checking I found the the problem is in the PHP serialize function which
use a lot of realloc call with small (128 bytes) incremenent. I
had sumbited a small patch (http://bugs.php.net/bug.php?id=32727) to fix
the problem which decrease the run-time of a test code from 2 seconds to
0.2 second

    After check on gooble, I found that this is an intension in FreeBSD libc
design to increase the performance of malloc and sacrifice the less use
realloc (http://phk.freebsd.dk/pubs/malloc.pdf and
http://www.freebsd.org/cgi/query-pr.cgi?pr=61691)

    The question:

Is there another way to increase the performance of the program that use a
lot of small realloc call other than change the way that a program use
realloc (as I do and Poul-Henning Kamp suggest in pr61691)?

Becase the way I use need a lot of time to found where to fix and the fix is
localize (PHP also use realloc in other place such as string operation
which my patch does not fix -- so , concatenate a string runs 10 times
slower on FreeBSD than Linux).

Moreover, Linux realloc is fast , so many open source deveper that use
Linux as their main devepment system will overlook this problem (such as
in PHP case).

Regards,
Chatchwan Wongsiriprasert




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?13101.210.86.179.115.1113957054.squirrel>