Bug #48197 [Asn->Csd]: __call performs extra allocs
| From: | dmitry@php.net | Date: | Wed, 08 Apr 2015 10:58:13 +0000 |
| Subject: | Bug #48197 [Asn->Csd]: __call performs extra allocs | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191898@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=48197&edit=1
ID: 48197
Updated by: dmitry@php.net
Reported by: rodricg at sellingsource dot com
Summary: __call performs extra allocs
-Status: Assigned
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.3.0RC2
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
This seems to be fixed in PHP-5.6 and above.
Previous Comments:
------------------------------------------------------------------------
[2013-07-27 21:32:43] vitalif at mail dot ru
Related To: Bug #65340
------------------------------------------------------------------------
[2013-07-26 01:51:01] felipe@php.net
Related To: Bug #65340
------------------------------------------------------------------------
[2009-05-14 10:05:42] dmitry@php.net
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.
------------------------------------------------------------------------
[2009-05-09 03:59:40] jani@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 https://bugs.php.net/bug.php?id=48197&edit=1