Req #72224 [NoF->Opn]: Optimize reflection initialization
Edit report at https://bugs.php.net/bug.php?id=72224&edit=1
ID: 72224
Updated by: requinix@php.net
Reported by: dmri87 at hotmail dot com
Summary: Optimize reflection initialization
-Status: No Feedback
+Status: Open
Type: Feature/Change Request
Package: Reflection related
PHP Version: 7.0.7RC1
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2016-05-29 04:22:18] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2016-05-23 20:20:58] dmri87 at hotmail dot com
The example would probably make more sense if I assigned the object to a variable.
Also notice how I left out the constructor. I'd expect ReflectionClass to compare in
performance to the creation of an object without calling its constructor.
Sorry for the multiple replies.
------------------------------------------------------------------------
[2016-05-23 20:03:46] dmri87 at hotmail dot com
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
------------------------------------------------------------------------
[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
Thread (9 messages)