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

Reduce duplicate queries when fetching user boards an permissions #3161

Merged
merged 1 commit into from
Jul 5, 2021

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Jul 2, 2021

First step to reduce the amounts of queries that happened during collecting incoming shares when setting up the filesystem for users.

Already gives quite some improvement in test setup with 1 shared board having 3 cards with a handful of attachments on each:
https://blackfire.io/profiles/compare/67ec272e-9530-491b-afb2-0fb2c9b06f59/graph

image

$groupBoards = $this->findAllByGroups($userId, $groups,null, null, $since, $includeArchived);
$circleBoards = $this->findAllByCircles($userId, null, null, $since, $includeArchived);
return array_unique(array_merge($userBoards, $groupBoards, $circleBoards));
if (!array_key_exists($userId, $this->userBoardCache)) {
Copy link
Member

Choose a reason for hiding this comment

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

isset() is said to be faster, but there is a small difference –https://www.php.net/manual/en/function.array-key-exists.php example #2. For consideration.

@@ -39,6 +39,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {

private $circlesEnabled;

private $userBoardCache = [];
Copy link
Member

Choose a reason for hiding this comment

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

could be also CappedMemoryCache to avoid overflow.

return $board && $userId === $board->getOwner();
} catch (DoesNotExistException | MultipleObjectsReturnedException $e) {
}
return false;
}

private function getBoard($boardId): Board {
if (!array_key_exists($boardId, $this->boardCache)) {
Copy link
Member

Choose a reason for hiding this comment

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

also isset for consideration

@juliushaertl
Copy link
Member Author

/backport to stable22

@juliushaertl
Copy link
Member Author

/backport to stable1.4

@juliushaertl
Copy link
Member Author

Looking into the tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants