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

Memory error in API Live.getLastVisitsDetails when filter_offset is large #7458

Closed
mattab opened this issue Mar 17, 2015 · 1 comment
Closed
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. 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

@mattab
Copy link
Member

mattab commented Mar 17, 2015

The goal of this issue is to investigate and solve a Live API request performance issue, when the request contains a high filter_offset paramater value.

The system runs out of memory, when requesting the following Query:

index.php?module=API&method=Live.getLastVisitsDetails&idSite=4&period=day&date=yesterday&format=xml&token_auth=&filter_limit=1&filter_offset=60000

This API request will return only one row. Instead, Piwik API currently errors out with a memory error (1G exhausted) as it seems to iterate over rows in memory. Instead we should aim to make this API call blazing fast and memory efficient, as users expect it to be.

@mattab mattab added Bug For errors / faults / flaws / inconsistencies etc. c: Performance For when we could improve the performance / speed of Matomo. labels Mar 17, 2015
@mattab mattab added this to the Piwik 2.13.0 milestone Mar 17, 2015
@mattab mattab changed the title Memory error Memory error in API Live.getLastVisitsDetails when filter_offset is large Mar 17, 2015
@mattab mattab added the Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. label Mar 17, 2015
@tsteur
Copy link
Member

tsteur commented Mar 18, 2015

I had a quick look and noticed it is not easy to fix. It takes probably 1.5 days to find a proper working solution.

Problem 1: If we apply filter_limit and filter_offset in getLastVisitDetails then the same would be applied again during GenericFilter and in the end it would not return anything. That's why we currently fetch filter_limit + filter_offset so the GenericFilter can apply the limit.
Problem 2: Adding a LIMIT 5, $offset is not trivial. While the API supports already to specify a limit it does not support to specify a $offset. Changing this results in touching many classes as it goes down till Segments etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. 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

2 participants