#48197 [Opn->Asn]: __call performs extra allocs
| From: | jani@php.net | Date: | Sat, 09 May 2009 03:59:41 +0000 |
| Subject: | #48197 [Opn->Asn]: __call performs extra allocs | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137012@lists.php.net to get a copy of this message | ||
ID: 48197
Updated by: jani@php.net
Reported By: rodricg at sellingsource dot com
-Status: Open
+Status: Assigned
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.3.0RC2
-Assigned To:
+Assigned To: dmitry
New Comment:
Dmitry, can you please check this out..
Previous Comments:
------------------------------------------------------------------------
[2009-05-08 20:43:02] rodricg at sellingsource dot com
Description:
------------
When returning a value from __call (as compared to a non-dynamic
method) extra memory is allocated. This leads to performance
degradation dependent on the size of the returned value.
Hopefully this is a better description/example of bug #47525.
Reproduce code:
---------------
http://rodric.org/mem.phps
This script takes 3 arguments. ie.
mem.php <iterations> <method> <size>
See "Actual Result" for invocations.
Expected result:
----------------
Bytes allocated when using __call should be similar to not using
__call.
When using __call the time taken should not degrade linearly as the
size of the result value increases.
Actual result:
--------------
Change USE_ZEND_ALLOC to 1 and you will see that "magic" performs
exactly <iterations> more allocs than "getStr".
Using __call:
USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100
magic 1000000 2>&1 | pcregrep "Time|allocs"
Time: 1.5781
==25158== malloc/free: 19,564 allocs, 18,033 frees, 104,476,083 bytes
allocated.
USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100
magic 2000000 2>&1 | pcregrep "Time|allocs"
Time: 3.1066
==25161== malloc/free: 19,564 allocs, 18,033 frees, 205,476,083 bytes
allocated.
Not Using __call:
USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100
getStr 1000000 2>&1 | pcregrep "Time|allocs"
Time: 0.0280
==25181== malloc/free: 18,764 allocs, 17,233 frees, 4,444,183 bytes
allocated.
USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100
getStr 2000000 2>&1 | pcregrep "Time|allocs"
Time: 0.0281
==25183== malloc/free: 18,764 allocs, 17,233 frees, 5,444,183 bytes
allocated.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48197&edit=1