Skip to content
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

Document using Matomo with OPcache and JIT compilation #17390

Open
Findus23 opened this issue Mar 24, 2021 · 4 comments
Open

Document using Matomo with OPcache and JIT compilation #17390

Findus23 opened this issue Mar 24, 2021 · 4 comments
Labels
c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. c: Performance For when we could improve the performance / speed of Matomo. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.

Comments

@Findus23
Copy link
Member

Using OPcache can speed up Matomo quite a bit as it avoids having to interpret the same PHP with every single page request.
Especially now with PHP 8 and JIT compiling (which is implemented as a part of OPcache) it might bring even more of a performance benefit.
There also should be no disadvantages (apart from a bit of memory usage from the cache) as Matomo already clears the cache on update/installs and for an application like Matomo everyone should be using opcache.validate_timestamps=1 which slows down the cache a bit, but should avoid ever serving something different than the PHP file (maybe check opcache.revalidate_freq).

So I think we should:

  • encourage more Matomo users to enable OPcache
  • document recommended settings
  • add a system check to warn against bad settings and generally recommend setting it up
    (for reference: Nextcloud shows a system check warning if it isn't set up)

A bit more experimental, but especially with the JIT feature of PHP 8 it might also be interesting to look into opcache for php-cli. Generally most people recommend not using OPcache for php-cli as it is a in-memory cache which would mean that a new php-cli process would start with a fresh cache making it useless. But since PHP 7 one can alternatively use a file cache (opcache.file_cache) which would stay between calls and with the JIT compiler some hot loop during archiving might receive
quite a bit of speedup. (I have not yet tested Matomo with JIT)

Slightly related: If someone wants to do testing with OPcache, I can recommend https://github.com/amnuts/opcache-gui which gives a nice overview over the current cache status

@Findus23 Findus23 added c: Performance For when we could improve the performance / speed of Matomo. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. labels Mar 24, 2021
@tsteur tsteur added this to the 4.5.0 milestone Mar 24, 2021
@Findus23
Copy link
Member Author

https://plugins.matomo.org/DiagnosticsExtended contains a system check urging people to enable OPcache and checks a few options for correctness.

@tsteur
Copy link
Member

tsteur commented Jul 27, 2021

We can add a system check opcache but we won't add it for now for JIT as it takes too much time to performance test it etc.

When system check is executed on CLI then we don't expect opcache to be enabled as it's usually not recommended and won't really help with performace. Eg when archiving on the CLI most of the time will be spent in database and aggregating data in PHP.

@tassoman
Copy link
Contributor

I've enabled OPCache in PHP8.1 caching a buffer of 256M. CPU time is only executing the huge queries don't fit the buffer

@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/matomo-and-opcache-recommended-settings/50205/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. c: Performance For when we could improve the performance / speed of Matomo. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.
Projects
None yet
Development

No branches or pull requests

5 participants