-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Feature Request: re-enable php opcache for dev-environments? #1442
Comments
🤔 interesting idea! Basically the theory is that having opcaching enabled is worthwhile even when re-validating every 1 second. I'm also curious about this setting:
Because we'd always have |
I wrote a small script ... #!/bin/bash
# benchmark.sh
URL="$1" # Pass as firs parameter or just add an url here...
COUNT=10
TOTAL=0
for i in $(seq 1 $COUNT); do
T=$( curl -o /dev/null -s -w '%{time_total}' "$URL" )
echo -e "$i/$COUNT:\t$T"
TOTAL=$( awk "BEGIN{ print $TOTAL + $T }" )
done
echo -e "---\nTotal:\t$( awk "BEGIN{ print $TOTAL/$COUNT }" )" ... and did some benchmarks in the following manner: sudo vim /etc/php/8.0/fpm/php.ini # change the value
sudo service php8.0-fpm restart # then restart php.ini
bash benchmark.sh "https://example.com" # then run the script tldr.:
I use this ini-setting (below) as the default setting, and only show changed values (in the following benchmarks). opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 512
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 1
opcache.fast_shutdown = 1
opcache.validate_timestamps = 1
opcache.enable_file_override = 1 1/10: 2.192602
2/10: 1.417862
3/10: 1.329829
4/10: 1.352817
5/10: 1.350337
6/10: 1.214131
7/10: 1.529780
8/10: 1.332163
9/10: 1.487570
10/10: 1.309430
---
Total: 1.45166 Another run with the same settings: 1/10: 2.212923
2/10: 1.270493
3/10: 1.220274
4/10: 1.247268
5/10: 1.277368
6/10: 1.330988
7/10: 1.247622
8/10: 1.161211
9/10: 1.512393
10/10: 1.280042
---
Total: 1.37605 opcache.validate_timestamps = 0 1/10: 2.037866
2/10: 1.356562
3/10: 1.318341
4/10: 1.239954
5/10: 1.335589
6/10: 1.267463
7/10: 1.441167
8/10: 1.315683
9/10: 1.320554
10/10: 1.295416
---
Total: 1.39286 opcache.enable = 0 1/10: 1.990889
2/10: 2.220091
3/10: 1.991241
4/10: 2.000759
5/10: 2.037611
6/10: 1.922285
7/10: 2.066977
8/10: 1.986670
9/10: 2.048466
10/10: 2.009548
---
Total: 2.02746 opcache.enable_file_override = 0 1/10: 2.365654
2/10: 1.445723
3/10: 1.356475
4/10: 1.493420
5/10: 1.291487
6/10: 1.497339
7/10: 1.313832
8/10: 1.460188
9/10: 1.255856
10/10: 1.324482
---
Total: 1.48045 opcache.revalidate_freq = 60 1/10: 2.197011
2/10: 1.305936
3/10: 1.235971
4/10: 1.205744
5/10: 1.371293
6/10: 1.160303
7/10: 1.276416
8/10: 1.170768
9/10: 1.216995
10/10: 1.226870
---
Total: 1.33673 opcache.revalidate_freq = 60
opcache.validate_timestamps = 0 1/10: 2.101342
2/10: 1.249363
3/10: 1.258679
4/10: 1.228603
5/10: 1.195424
6/10: 1.224175
7/10: 1.217903
8/10: 1.270338
9/10: 1.298442
10/10: 1.199673
---
Total: 1.32439 |
I ran your script and saw similar numbers (but much lower) using a default install and default theme: Without opcache:
With opcache enabled:
This was true even with |
OPcache was previously disabled in development to ensure no stale cached PHP. However, there are still performance benefits to having OPcache enabled with a `revalidate_freq` of `0` which will result in OPcache checking for updates on every request (instead of the default of `60` in production). This also enables the `enable_file_override` setting which can provide better performance as long as `validate_timestamps` is enabled (and it is by default).
#1447 is up but we'll do some more testing. |
OPcache was previously disabled in development to ensure no stale cached PHP. However, there are still performance benefits to having OPcache enabled with a `revalidate_freq` of `0` which will result in OPcache checking for updates on every request (instead of the default of `60` in production). This also enables the `enable_file_override` setting which can provide better performance as long as `validate_timestamps` is enabled (and it is by default).
OPcache was previously disabled in development to ensure no stale cached PHP. However, there are still performance benefits to having OPcache enabled with a `revalidate_freq` of `0` which will result in OPcache checking for updates on every request (instead of the default of `60` in production).
OPcache was previously disabled in development to ensure no stale cached PHP. However, there are still performance benefits to having OPcache enabled with a `revalidate_freq` of `0` which will result in OPcache checking for updates on every request (instead of the default of `60` in production).
OPcache was previously disabled in development to ensure no stale cached PHP. However, there are still performance benefits to having OPcache enabled with a `revalidate_freq` of `0` which will result in OPcache checking for updates on every request (instead of the default of `60` in production).
OPcache was previously disabled in development to ensure no stale cached PHP. However, there are still performance benefits to having OPcache enabled with a `revalidate_freq` of `0` which will result in OPcache checking for updates on every request (instead of the default of `60` in production).
Terms
Summary
Re-enabling opcache for dev decreases load time (in my case) by ~30%.
Motivation
I'm developing on Windows and my VM is slow (0.3s on production vs. 2.5s on dev for the same page).
I tried re-enabling opcache and obviously ran into the problem discussed here.
So I added/changed the following settings (group_vars/development/php.yml):
This brings down loading times for the same page (mentioned above) to 1.7s.
I don't have any problems with file-changes. In my case
php_opcache_revalidate_freq
can even stay at 60. This would even bring the dev-configuration closer to the one on the production environment.I'm not sure, how it is for other environments, so we might be able to collect different experiences for other OSes/Configurations here.
Additional Context
I used several runs of Performance Insights (within Chrome's dev-tools) for the benchmarks.
The text was updated successfully, but these errors were encountered: