From owner-freebsd-performance@FreeBSD.ORG Wed Apr 20 00:30:56 2005 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A9BD16A4CE for ; Wed, 20 Apr 2005 00:30:56 +0000 (GMT) Received: from www.hotel-accommodation.net (www.hotel-accommodation.net [203.146.102.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id D056143D3F for ; Wed, 20 Apr 2005 00:30:55 +0000 (GMT) (envelope-from cws@miraclenet.co.th) Received: from secure.abatravel.net (localhost [127.0.0.1]) by www.hotel-accommodation.net (Postfix) with ESMTP id 1C31A1DA7B for ; Wed, 20 Apr 2005 07:30:54 +0700 (ICT) Received: from 210.86.179.115 (SquirrelMail authenticated user cws); by secure.abatravel.net with HTTP; Wed, 20 Apr 2005 07:30:54 +0700 (ICT) Message-ID: <13101.210.86.179.115.1113957054.squirrel@210.86.179.115> Date: Wed, 20 Apr 2005 07:30:54 +0700 (ICT) From: "Chatchawan Wongsiriprasert" To: freebsd-performance@freebsd.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Mailman-Approved-At: Wed, 20 Apr 2005 12:22:22 +0000 Subject: Slow realloc X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2005 00:30:56 -0000 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