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
Conversation
…is superuser and has many sites
|
||
// if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail | ||
if (is_null($this->auth)) { |
There was a problem hiding this comment.
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
if ($bool) { | ||
$this->reloadAccessSuperUser(); | ||
$this->makeSureLoginNameIsSet(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
In general, looks good to me, can merge when comment threads are dealt w/. |
…heduled task to keep it out of getUserPreference method.
Performance optimization: Load access levels in Access singleton lazily, making dashboard and other operations that do not require access faster when having thousands+ sites.
fyi: the build was broken at this commit: https://travis-ci.org/piwik/piwik/jobs/58851183 edit: any idea why it broke the build? |
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.