Closed kevinpapst closed 1 year ago
I'm not sure what I need to do to test these changes, but I assume that I have to do docker build
and then running docker-compose up
.
If this is so, this changes aren't working. I looked at the Dockerfile
before and I think the changes @tobybatch mentioned in #438 is the way to go. I will try this later.
but opcache is not an extension afaik, it is built in php.
no clue, not a docker user 🤷but what about you ssh into the container, edit the file manually and apply my changes, restart fpm inside the container and check if performance improves.
we first need to confirm whether the settings do any good - and then we can ask @tobybatch to put it into the image properly.
@kevinpapst I'll take a look.
Looks like the opcache settings are not set at all. I'll fix this. I'll do it in the next couple of days.
✘ ~/usr/kimai/kimai2 [ kevinpapst-patch-1 | ✔ ] $ docker run -ti --rm --name=kimai --entrypoint bash docker.io/kimai/kimai2:fpm-1.30.1-prod
bash-5.1$ php -i | grep "opcache.enable\|opcache.memory_consumption\|opcache.interned_strings_buffer\|opcache.max_accelerated_files\|opcache.validate_timestamps\|session.gc_maxlifetime"
session.gc_maxlifetime => 604800 => 604800
@kevinpapst No, it's an extension. If you compile PHP manually you can compile it directly, but as far as I know in apt packages it is a separate package.
I tried to change the Dockerfile
and was able to confirm that this is working:
Add the following code after this: https://github.com/tobybatch/kimai2/blob/993e98e628c7c7f8d76f091682655870908f1421/Dockerfile#L122
# php extension opcache
FROM ${BASE}-php-ext-base AS php-ext-opcache
RUN docker-php-ext-install -j$(nproc) opcache
Add the following code after this: https://github.com/tobybatch/kimai2/blob/993e98e628c7c7f8d76f091682655870908f1421/Dockerfile#L228
COPY --from=php-ext-opcache /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
As hoped, I could notice a strong increase in speed.
Ok, double checked and you are right, opcache is an extension. It is even in the Kimai installation docs ... never trust your own memory ^^
Anyhow, great that we have everything together now. And great that this rather simple chance will make a huge difference.
Because I'm not able to change anything in this PR, I've created a new pr #446. I hope this is okay for you. 😊
LOL, happy that my PR pushed you to try it yourself ;-) but I would like to understand the configuration of the opcode cache.
The default settings are suboptimal: too small for a symfony application with many files, caches and long uptimes.
Can you add a phpinfo to the kimai public folder and copy & paste the result of the opcode settings? Then this PR can be used to improve them after yours activated the opcode cache.
www-data@814fec82650f:/opt/kimai/public$ php -i | grep opcache
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini,
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => On => On
opcache.file_cache_only => Off => Off
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.interned_strings_buffer => 8 => 8
opcache.jit => tracing => tracing
opcache.jit_bisect_limit => 0 => 0
opcache.jit_blacklist_root_trace => 16 => 16
opcache.jit_blacklist_side_trace => 8 => 8
opcache.jit_buffer_size => 0 => 0
opcache.jit_debug => 0 => 0
opcache.jit_hot_func => 127 => 127
opcache.jit_hot_loop => 64 => 64
opcache.jit_hot_return => 8 => 8
opcache.jit_hot_side_exit => 8 => 8
opcache.jit_max_exit_counters => 8192 => 8192
opcache.jit_max_loop_unrolls => 8 => 8
opcache.jit_max_polymorphic_calls => 2 => 2
opcache.jit_max_recursive_calls => 2 => 2
opcache.jit_max_recursive_returns => 2 => 2
opcache.jit_max_root_traces => 1024 => 1024
opcache.jit_max_side_traces => 128 => 128
opcache.jit_prof_threshold => 0.005 => 0.005
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFEBFFF => 0x7FFEBFFF
opcache.preferred_memory_model => no value => no value
opcache.preload => no value => no value
opcache.preload_user => no value => no value
opcache.protect_memory => Off => Off
opcache.record_warnings => Off => Off
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => On => On
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On
I think this should be the same settings as in web.
I don't understand that docker container.
opcache.enable_cli
is Off
Thank you very much 👍
I just saw opcache.enable => On
. Missed the second setting. Off is better on cli, so we are good for that one.
@kevinpapst Should I add your changes in this PR to my Dockerfile and try your changes?
You could test if they work, yes please. I guess you will not see much difference for a single user though.
But at least the validate_timestamps makes a huge IO difference, especially with many users.
I tried it out but it seems that your changes doesn't have any effect. It seems that the replace doesn't work. {{php.ini}} values stays on default. But I also noticed that this line also have no effect: https://github.com/tobybatch/kimai2/blob/993e98e628c7c7f8d76f091682655870908f1421/Dockerfile#L297
www-data@eeb903d9b49d:~/html$ cat /usr/local/etc/php/php.ini | grep expose_php
expose_php = On
I used build apache-1.30.2-prod
.
@tobybatch Maybe this is the wrong place for these changes?
There was core bug with my sed operations in the Dockerfile and startup.sh.
@kevinpapst I've lifted your code into a new PR #452 along with the bug fix.
can someone please test these changes. i don't know if that is even the correct file to change... 😁
while being on it, i changed the default session timeout from 14 minutes to 1 week.
the setting
opcache.validate_timestamps
might cause troubles for files changed during runtime (like updated invoice templates). we should mention in the docs, that a docker restart (actually fpm) is advised if file changes do not become visible in the containerdo not merge without testing, these changes were made blindly!!!