-
Notifications
You must be signed in to change notification settings - Fork 26
Use best options for Symfony, fix Cobalt+Joomla prototype containers #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Awesome! I couldn't configure the file-based container myself properly when I tried to play with it so thank you very much for the help! I'll rerun the test suite soon. |
ping us when you do, I think a lot of people will be excited to see the results as a lot of work has been done there :) |
Having to restart my computer and shut down all the apps in order to improve the accuracy is blocking the re-run. :D But I'll be able to do that in an hour! :) |
@nicolas-grekas, @theofidry, I've just generated the results (many-many times, even with different setups), but unfortunately Symfony seems to be a bit slower now. :( (though the difference is usually negligible) I am a bit disappointed because I expected - and wanted to see - big performance improvements. How much difference do you have on your systems? What did Blackfire say? Although I am not very familiar with the internals of autoloading, I wonder if it tricks us. I think so because the biggest change was that Composer's autoloader is replaced with I would be happy if you had a good explanation about this weird phenomenon. :/ :) |
Haha :)
|
True and the benchmark is not lying: the difference between rank 7 (Symfony) and rank 1 (Zen) for those is around .2ms... Also compared to before (3.4), the results are significantly better :) |
For reference, if we make this change, Symfony comes always first in the 3rd ranking group where it ranks 6th/7th for now: --- a/src/Symfony/Component/DependencyInjection/Container.php
+++ b/src/Symfony/Component/DependencyInjection/Container.php
@@ -217,6 +217,11 @@ class Container implements ResettableContainerInterface
*/
public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
{
+ return $this->services[$id] ?? ($this->factories[$id] ?? array($this, 'make'))($id, $invalidBehavior);
+ }
+
+ private function make($id, $invalidBehavior)
+ {
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
} |
I also agree that the last two test suites are the least useful and I hardly ever pay attention to them. I'll only leave them there because still, they might help someone who wants to optimize Initially, my main source of confusion was that Symfony is not much faster in the first 2 suites. But Nicolas is right, the test suite 3 and 4 are much more affected by the changes. And when I talked about the "autoloader's trick", I suspected that the I happily regenerate the results with Symfony 4.1 if you want :) I am also curious! |
With Symfony 4.0.4:With Symfony 4.1:@nicolas-grekas Big congratulations :) This is fascinating! |
And Symfony might come always 1st within the error margin if symfony/symfony#26161 is merged :) |
I'll keep an eye on the PR and will publish the updated results as soon as I can :) |
This PR was merged into the 4.1-dev branch. Discussion ---------- [DI] Top micro benchmarks | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This makes Symfony rank 1st most of the time, 2nd within the margin error otherwise. Follow up of kocsismate/php-di-container-benchmarks#21 Commits ------- 3edf5f1 [DI] Top micro benchmarks
Now merged :) |
No need for a PR, I'll do that now! |
Done! Symfony is really on the top for almost all the tests :) |
Let's celebrate :) |
🎉 A small note regarding the results. As you can see below, sometimes the ranking doesn't make sense, maybe it would be good to adjust the second ranking criteria: In some cases, the difference is incredibly small (0.009ms = 20%) and this for up to rank 6 sometimes. I would suggest to for example calculate a delta and for the the rank 1 + delta add a color indicating that the results are sensibly the same. For example:
For above from rank 1 to rank 8, the difference is so small they should kind of all appear as "super good" |
@theofidry Great idea! But what would you think about if I increased the number of iterations in the last 2 test suites? They will become even more synthetic this way, but I guess it is not a problem in this case. @nicolas-grekas I couldn't resist the temptation of trying to optimize Zen... After many attempts in the past, I finally found a "nice" way to eliminate some opcodes in the So Zen is the first now in the last 2 test suites! But I'll be happy if you can squeeze out even more speed from Symfony and it comes first again! A little competition helps us to do our best :) Update: I've just realized by checking your last optimization again (but more carefully now) that essentially I did the same as you: optimized the |
Haha how unexpected. |
as_files
andinline_class_loader
options, that's the default for skeleton Symfony 4 apps