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

Run queued filters after generic filters making visualizations much faster #7387

Merged
merged 2 commits into from Mar 9, 2015

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Mar 8, 2015

When rendering a visualization, we applied queued filters, computed processed metrics, etc. always on all rows (meaning before generic filters were applied). This means when a datatable has 25k rows (which is not so much), then we ran computeProcessedMetrics, applyQueuedFilter, ... on 25k rows instead of only 100 displayed rows. By changing this it made rendering a report with 25k rows over 3 seconds faster on my server. The time spent shrank to filter rows shrank from > 3 seconds to < 40ms.

Also before this refactoring filters were applied in a completely random order which is entirely different to what we test in system tests resulting in different displayed data compared to what we test and compared to the exported data. Apart from that there was some duplicated code in applying filters in the visualization. We do now make sure to run the filters in the same order as we test it in system tests.

Note: Some UI tests are failing but only for some rows having the same value in the filter_sort_column. So it is not really a change, rather a fix since we do now apply the filters in the correct order.

@tsteur tsteur added the c: Performance For when we could improve the performance / speed of Matomo. label Mar 8, 2015
@tsteur tsteur added this to the Piwik 2.12.0 milestone Mar 8, 2015
@tsteur tsteur added the Needs Review PRs that need a code review label Mar 8, 2015
@@ -147,6 +147,8 @@ private function getLabelVariations($originalLabel)
}
$variations[] = $label;

$variations = array_unique($variations);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small performance tweak for labelfilter

throw new PluginDeactivatedException($module);
}
$apiClassName = self::getClassNameAPI($module);
$apiClassName = $this->getClassNameAPI($module);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this reverts https://github.com/piwik/piwik/pull/7344/files but that's not wanted

@tsteur tsteur force-pushed the visualization_filter_fix branch 2 times, most recently from c4f6c61 to 3c3a11b Compare March 9, 2015 03:31
@@ -60,6 +62,16 @@ protected function getGoalMetrics(Row $row)
$alternateKey = 'idgoal=' . $this->idGoal;
if (isset($allGoalMetrics[$alternateKey])) {
return $allGoalMetrics[$alternateKey];
} elseif ($this->idGoal === Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these if statements fix a bug or add a new feature?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes ui tests as sometimes we have a string here and sometimes an integer / metric id. Wasn't needed before but now

@mattab
Copy link
Member

mattab commented Mar 9, 2015

Looks good! 👍 let's test it on demo

mattab pushed a commit that referenced this pull request Mar 9, 2015
Run queued filters after generic filters making visualizations much faster
@mattab mattab merged commit d21fcf2 into master Mar 9, 2015
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. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants