-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Performance benchmarks #18
Comments
I'm confused as to why preloading improves the first request time. Preload does load files on boot so they are available within the request right? So shouldn't the first request be slower because it loads stuff it does not need? Or is the preload time within the init time and therefore not counted? |
Actually no. Preload loads stuff before the first request. Ie, when PHP-Fpm is starting. That does technically happen before we get the "request data" from AWS. So my "initialisation" should be a little bit slower when using preload. But that was nothing I noticed. |
Preload is btw also faster as the init process has more CPU power: https://medium.com/@hichaelmart/shave-99-93-off-your-lambda-bill-with-this-one-weird-trick-33c0acebb2ea |
First, awesome job man @Nyholm . Thank you. Just some future prospects thoughts here. With every day, and especially with bref, we are moving more and more towards pre-packaged PHP releases. Something that is quite unusual in PHP world - we are packaging compiled assets, compiled/installed vendors, soon compiled code, and one day i hope precompiled container itself. We might as well look into how other ecosystems do it and why. I briefly asked Nikita about the theorethical possibility of precompiling the whole thing into a binary release, but he said that apart from some little CPU benefit he did not see any real value. Back to topic at hand... There might be a future possibility of compiling and baking the preloaded opcodes as well as symfony cache into the distribution layer.
|
@markomitranic what I usually do is compile the Symfony cache in a Bref docker image -> the paths are all good then. |
Out of curiosity I benched my project too with different php versions and preload on/off. I now used the configuration i mentioned in #21 (comment) even though that is irrelevant for my test request since it uses no validators or property-info. It is therefore similar to @Nyholm's test since his test had not copied the pools directory (what this library currently mainly does) I always ran 2 requests to check for cold start and warm run. php 7.3
php 7.4
php 7.4 with
php 7.4 with preload configured like
So php 7.4 is faster in any way. Although you should enable the Not this is for symfony 4.4 which is the first version to include the preload feature. There are improvements in 5.1. |
So I did some testing on a small app. I tested with #17 included (that PR does not have any performance impact).
A normal request: 10ms
First request: 1805ms
First request with BrefKernel: 510ms
BrefKernel spent 88ms preparing cache directory. It spent 77 ms out of those 88ms to copy the "pools" directory.
So thanks so #17, I disabled copying "pools" and enabled opcache.preload.
A normal request: 7.5ms
First request: 1144ms
First request with BrefKernel: 160ms
Yes. The first (cold) request is still 20 times slower. (Or 51x slower without preloading) But it is better than 180x slower as we began with.
Note: These sample data may not be reliable. I only did 2 samples of each. To get better data I should take 5-10 samples and show the average. However, I did deploy over CI so I know the process of warmup etc is the same.
The text was updated successfully, but these errors were encountered: