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

Cache API.getSegmentMetadata better in Segment - Improve performance on every UI request #17944

Closed
tsteur opened this issue Aug 31, 2021 · 2 comments · Fixed by #18333
Closed
Assignees
Labels
c: Performance For when we could improve the performance / speed of Matomo. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Aug 31, 2021

I have here a regular UI call, and it triggers more than 90 API.getSegmentMetadata calls which then triggers calls to funnels, heatmaps, goals, ... That's a site with like 50 segments.

This is executed here: https://github.com/matomo-org/matomo/blob/4.5.0-b1/core/Segment.php#L186-L194

It's cached in a property but we often create a new segment instance like new Piwik/Segment(). So the cache isn't really used and for every segment we create a new instance and fetch segment metadata over and over again.

The goal of this issue is to have a cache be reused across segment instances. Meaning when a new segment instance is created, and we fetched this data previously, then it should reuse the cache from the other instance. The data may need to be cached per site and maybe other criteria.

image

image

This all can be quite slow.

@tsteur tsteur added the c: Performance For when we could improve the performance / speed of Matomo. label Aug 31, 2021
@tsteur tsteur added this to the 4.7.0 milestone Aug 31, 2021
@tsteur tsteur added the Regression Indicates a feature used to work in a certain way but it no longer does even though it should. label Aug 31, 2021
@peterhashair peterhashair self-assigned this Nov 16, 2021
@peterhashair
Copy link
Contributor

peterhashair commented Nov 17, 2021

@tsteur ah, I think the problem is getTransientCache won't be persisted between requests, and other caches won't accept closure. return segment has some closure. I guess we need some kind of format to format the data that translate the data, to be cached.

@sgiehl
Copy link
Member

sgiehl commented Nov 22, 2021

@tsteur feel free to reopen (or open a new issues), if we should work on a solution using a cache that persists between requests somewhen later.

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. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants