ID: 48197 Updated by: dmi...@php.net Reported By: rodricg at sellingsource dot com Status: Assigned Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 5.3.0RC2 Assigned To: dmitry New Comment:
I confirm the problem, however I'm not able to fix it in this moment. Regular "user" functions are able to return zval** however internal functions (__call implemented through internal function) are able to return only zval*. As result we can't return pointer to the original zval* and need to separate it. Previous Comments: ------------------------------------------------------------------------ [2009-05-09 03:59:40] j...@php.net Dmitry, can you please check this out.. ------------------------------------------------------------------------ [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