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

Faster access loading - Make dashboard etc faster when having thousands of sites #7641

Merged
merged 7 commits into from Apr 17, 2015

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Apr 8, 2015

Currently, we do always load the sites a user has access to even though when never requested. Eg most dashboard widgets do not need to fetch all siteIds from the database when someone is a superuser. When someone is a user we still often need to do it but often users maybe do not have access to eg all 50k sites so it should be fast.

Basically we want to lazy load the sites a user has access to. This improves performance quite a bit especially when opening the dashboard and when many requests to request 50k sites in parallel. On a fast server the difference is not that obvious but one can feel it is faster.


// if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail
if (is_null($this->auth)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This if is not need as we would check for hasSuperUserAccess afterwards anyway

@tsteur tsteur added the c: Performance For when we could improve the performance / speed of Matomo. label Apr 8, 2015
@tsteur tsteur added this to the Piwik 2.13.0 milestone Apr 8, 2015
@tsteur tsteur added the Needs Review PRs that need a code review label Apr 8, 2015
if ($bool) {
$this->reloadAccessSuperUser();
$this->makeSureLoginNameIsSet();
Copy link
Member

Choose a reason for hiding this comment

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

Should we resetSites in this case too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think it's needed. It would rather end up in loading more sites eg if superuser sites were already set we do not need to reload them.

Copy link
Member

Choose a reason for hiding this comment

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

You're right, when super user access is set, only the 'superuser' element in idsitesByAccess or whatever is used.

@diosmosis
Copy link
Member

In general, looks good to me, can merge when comment threads are dealt w/.

diosmosis added a commit that referenced this pull request Apr 17, 2015
Performance optimization: Load access levels in Access singleton lazily, making dashboard and other operations that do not require access faster when having thousands+ sites.
@diosmosis diosmosis merged commit 693649d into master Apr 17, 2015
@diosmosis diosmosis deleted the load_all_sites_only_if_needed branch April 17, 2015 02:46
@diosmosis diosmosis removed the Needs Review PRs that need a code review label Apr 17, 2015
@mattab
Copy link
Member

mattab commented Apr 17, 2015

fyi: the build was broken at this commit: https://travis-ci.org/piwik/piwik/jobs/58851183

edit: any idea why it broke the build?

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants