graph: Small improvments for filtering users by role #9326
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses some low hanging fruits for improving the GetUsers call when filtering users by role-assignment (and expanding the assignments).
The first commit avoids a lot of extra queries to the settings service when
$expand=appRoleAssignment
is used together with filtering.The second commit switch the filtering code to use the new ListRoleAssignmentsFiltered request in the settings service. Reducing the number of queries to the settings service to a single request. (Orignally it was one per existing user + one per user that matched the filter).
On my system with 1000 users (external LDAP) assigned to the
User
role and the metadata service using and NFS volume the query time for:$filter=(appRoleAssignments/any(m:m/appRoleId eq 'd7beeea8-8ff4-406b-8fb6-ab2dd81e6b11'))&$orderby=displayName&$expand=appRoleAssignments
(the query used by web). I get this:Cold Caches:
master: ~18s
this pr: ~14s
Hot Caches (mainly the settings service's cache and the kernel's buffercache):
master 0.8s
this pr: 0.4s
So the overall improvement isn't all that big yet (mainly because the settings service itself still needs to scan all assignments in the metadata backend in order to apply the filter). Still, there is some improvement.
Related Issue: #8938