Req #72224 [Com]: Optimize reflection initialization
| From: | dmri87 at hotmail dot com | Date: | Mon, 23 May 2016 20:03:47 +0000 |
| Subject: | Req #72224 [Com]: Optimize reflection initialization | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201248@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72224&edit=1
ID: 72224
Comment by: dmri87 at hotmail dot com
Reported by: dmri87 at hotmail dot com
Summary: Optimize reflection initialization
Status: Feedback
Type: Feature/Change Request
Package: Reflection related
PHP Version: 7.0.7RC1
Block user comment: N
Private report: N
New Comment:
Literally any reflection object, krakjoe.
It is comparable in performance to the creation of other objects, sure, but it is too slow
considered that reflection is basically just static information.
For instance, why is this 6 (!!!) times slower than creating the actual object?
class A{}
for($i = 0; $i < 1000000; $i++){
new A();
} // 0.3150179386 seconds
for($i = 0; $i < 1000000; $i++){
new ReflectionClass('A');
} // 1.9061090946 seconds
Previous Comments:
------------------------------------------------------------------------
[2016-05-20 19:29:35] krakjoe@php.net
I've flicked through the source code of the most common reflector constructors, and I see
nothing that is obviously causing such problems.
Can you provide some example code that behaves extra ordinarily, perhaps that will help me to
understand better ?
------------------------------------------------------------------------
[2016-05-16 14:18:20] dmri87 at hotmail dot com
Description:
------------
PHP should improve the creation of Reflection objects.
Almost literally any library or framework using Reflection non trivially I've encountered
implements its own Reflection objects caching mechanism. That because creating such objects is
incredibly expensive and it's way more expensive than caching them all, even if thousands of
them. I had to do the same to keep performance acceptable.
PHP should do this internally if possible, or try to optimize something, because again, the amount
of times I've seen this is incredible and it's a clear sign the creation of such object is
just too slow.
Just to be clear (sorry if I sound harsh but I actually just want to be clear) Reflection
object's creation performance is a problem even for those that are using it trivially. I
don't think it's acceptable if the creation of few dozens of these objects turns out to be
an important bottleneck for applications that would otherwise be extremely fast.
Thank you for reading and double thank you if you intend to work on this.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72224&edit=1