-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improve performance by avoiding access() calls to non-existing files #14420
Improve performance by avoiding access() calls to non-existing files #14420
Comments
That's a good find. I suppose PHP can cache these files. I suppose it be an easy fix to add the Those stats you show from how many requests is that? Maybe it's a very minor thing compared to the whole request? I reckon it can be helpful though to avoid the filesystem being a bottleneck when there's heaps of traffic. I reckon I'd be keen to actually create those files for all of our core plugins. |
I don't understand what you mean by the "building the dependency injection container".
I can create some stats for you if you need it. The best approach might be to benchmark a single php process, with and without the missing files present. It should provide with an estimate on how much more performance a single process would be able to gain. But for multiple processes I would assume the gain is bigger, since the kernel would have to do less work overall.
We have for now added the |
We have implemented the change permanently now in our env. 'strace' now show much less time is spent on access syscalls:
There are still some files that isn't cached by opcache:
This was for ~2000 requests and 60s duration. |
We would likely not add any more files. Maybe we could add some plugin files like |
fixes matomo-org/tag-manager#174 related #14420 related #14625
Hi,
We see a high number of access() errors when tracing Matomo, and it is related to matomo trying to access() files which isn't present.
Since files are not present, opcache is unable to cache the code. There is a decent amount of files, here is a sample, I can provide a full list if needed. The number is the frequency seen in our stracing for 10s in our dev environment:
When these files are not present, strace gives the following summary when stracing all php-fpm7 processes. Notice a lot of time is spent on access() calls:
For a simple test, we added {config,tracker}.php to all plugins-folders where it was not present already, and returned an empty array:
After adding this change, we restarted php-fpm7. Notice how much less time is spent with access() calls:
For low level traffic, we don't see any improvements. But, when sudden peaks (16req/s to 1000req/s) occurs within 30s, we no longer have issues with increased latency on our Tracker API requests. Before this change, certain (5-10%) Tracking API calls would time out, since unneeded CPU time was spent on access() calls.
We have not fixed all identified "missing files", but if this is of interest I can provide some feedback on what other files might benefit from this. It is not enough to just
touch
files, e.g. Matomo expects an array() returned from {config,tracker}.php.We haven't looked at increasing
realpath-cache-ttl
(https://www.php.net/manual/en/ini.core.php#ini.realpath-cache-ttl) but will look at it, but I suspect this will have less impact sin Opcache uses a shared cache.I'm not sure what I expect Matomo devs to do with this, but it would be nice to avoid unnecessary access() syscalls in general. I suspect very few actually hit this issue at all, but still.
Our opcache settings:
The text was updated successfully, but these errors were encountered: