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

Improve performance of tracker by speeding up dependency injection PHP DI #20215

Open
tsteur opened this issue Jan 15, 2023 · 3 comments
Open
Labels
c: Performance For when we could improve the performance / speed of Matomo. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Jan 15, 2023

See profile of a tracker request below.

image

Around 70% (105 out of 150ms in total) of the time is spend in exclusively in the first 5 methods related to DI.

Typically, methods are executed very often are over-reported in Xhprof so it might be more like 30% or so but that would be still quite a lot of time.

Not sure if there's anything we can do ourselves in terms of configuring it, or if we would need to tweak PHP DI (which we could consider paying for if there's anything that can be done).

see https://php-di.org/doc/performances.html

Maybe enabling definition cache and/or compilation is something we can look into. Any solution would need to support https://developer.matomo.org/guides/multi-tenants where a Matomo runs with hundreds or thousands of different config files / instances. Seems we could eg configure a cache directory per account for example.

@tsteur tsteur added c: Performance For when we could improve the performance / speed of Matomo. To Triage An issue awaiting triage by a Matomo core team member labels Jan 15, 2023
@tsteur
Copy link
Member Author

tsteur commented Jan 15, 2023

Enabling definition cache via apcu locally made the time spent in these methods up to 5 times faster for me (without xhprof might be only 3 times).

@tsteur tsteur added the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label Jan 16, 2023
@tsteur tsteur added this to the For Prioritization milestone Jan 16, 2023
@bx80 bx80 removed the To Triage An issue awaiting triage by a Matomo core team member label Jan 16, 2023
@mattab mattab modified the milestones: Impact Backlog, 5.1.0 Dec 10, 2023
@rr-it
Copy link
Contributor

rr-it commented Jan 31, 2024

@tsteur Is this performance data from a productive install e.g. composer install -o --no-dev?


Composer optimization

How about using the composer optimization classmap-authoritative to boost the performance?

See: https://getcomposer.org/doc/articles/autoloader-optimization.md#optimization-level-2-a-authoritative-class-maps

Activate on install:
composer install --no-dev --classmap-authoritative

Or afterwards via:
composer dump-autoload --no-dev --classmap-authoritative

Or add to composer.json

{
    "config": {
        "classmap-authoritative": true
    }
}

Performance in general

System: PHP-FPM with OPCache

Track page view:

grafik

Server response time under 60 ms - thats pretty awesome! 🚀

  • 25 ms: server stack
  • 35 ms: Matomo and database

For comparison: simple call to php-file

<?php
echo 'test';

grafik

@sgiehl
Copy link
Member

sgiehl commented Feb 1, 2024

@rr-it Thanks for the suggestion. Unfortunately we can't easily use classmap-authoritative. For all classes in core that might not be a problem, but when a new plugin is installed, those classes would be missing in the class map. So we would need autoloading nevertheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

5 participants