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
Optimize Translator.php call and EventDispatcher.php #15990
Conversation
Can you validate this optimization ? I am not sure with measure. |
@tolbon could you also let us know in the cachegrind what the column name is for each number? We have been doing quite a few profiles in the past and these changes shouldn't really have an impact on performance. When doing the profiles make sure Matomo development mode is disabled and caches are warmed up for example. Also be good to make sure to test the profiles several times as they can vary sometimes quite a bit. Is there any chance you can share the full cachegrind file? I suppose the file be quite large? |
Name, Time, Own Time, Memory, OwnMemory, NbCalls
I am not sure It's a PHP7+ optimization. maybe if you do this before explain what. I am using matomo docker example |
BTW looking at the 2 screenshots again. Do you notice that the methods are called less often in the second run? Be great to profile the identical request several times and compare the several requests and to make sure there's nothing else running on the server for accurate results. We've done a lot of profiling on PHP 7+ and from what we know this should make like absolutely no difference. Could be wrong though. As mentioned with the profiling be great to ensure to compare the same request, run the profile several times cause there will be always some minor differences, check that nothing else is running on that server that might consume CPU for example. If you can send us a full cachegrind file that be really interesting to look at |
Hello, I know V2 miss one file Don’t know why. You work on it always. You have certainly right about no effect of this PR. |
Had a look at some and compared them. Quite interesting the result. To know how accurate the profiles are be great if you could confirm you tested this ideally on a server where nothing else is running, and ideally would need to run the same test quite often to basically end up with some averages. Eg if you run the same test with the same code again, you might notice also quite a difference each time you run it. |
Ok I see. that’s why I prefer you to test you or your team in your side with this modification. Add slash not change code result but let php microOptimize. |
@tsteur Why I search that ? Cause in cachegrind files check memory consumption and I see this function. |
We actually don't want to save the result as when this method is used, it's important to detect any change in plugins etc. 5MB memory doesn't sound too bad? Although it should technically free the memory each time. Not sure if you get to see peak memory usage etc. Generally that method shouldn't cause much of an issue. Be keen to learn more about your profiling. Are you having memory issues? or performance issues with Matomo? Cause the tracking requests should consume very little memory and the DB takes typically most of the time. In the UI the highest memory consumption usually comes from reading reports (unserialising all the rows, merging rows from reports when needed etc). Performance wise there's a bit that can be done here and there but it might be not that trivial to make it more than 10% faster. BTW we're using here the tideways profiler, some use https://blackfire.io/ |
No no it's not a leak I just ask. it's like compute 2 + 2 = 4 (1000 time during a request) if the result is the same 1000 times I think it's bad to recompute it 999 times. ok next time I go with blackfire profile :) |
BTW... end of the year PHP 8 should be released which might come with quite some big performance boost without needing to do any change. It's obviously to be seen if there is a performance boost and how much. |
Yeah very excited about PHP 8 + JIT. |
TAKE WITH CAUTION.
I inspect what function have lot of own time in matomo
I see this :
After some modification "own time" decreased (the 3 columns, time in ms)
cause some functions like count, is_array, is_string ... if you add \ before PHP optimize this call.
the bench is made in this page. I refresh and aggregates 8 cachegrind files