fix(graph): [OCISDEV-1466] speed up user search when sharing from the vault - #13023
gauravsoni119 wants to merge 1 commit into
Conversation
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
I guess it's out of scope, but the In addition, we're traversing all of those users twice. Even with the parallel processing, I'm not sure this will improve the speed in large environments. I think we'll need some performance data with a large number of users in order to prove that the PR really improves the performance on all scenarios. |
I wonder if the problem is that the |
Thanks for the careful look. I ran a benchmark to check it with numbers. Setup: a local
The first vault search after a restart (cold cache, M = 1) took 5,149 ms with the old code and 46 ms with the new. On the request count: you're right that the old code makes 3 gRPC calls and the new one makes M + 1. The difference is what each call costs inside settings.
On the cache: Once the settings cache is warm, the old path is fast, and at 1,000 matched users the two are level. But whoever searches first after the cache expires or the service restarts pays for the whole scan (5 s here, growing with the number of accounts). The cache is per settings instance, so it happens again on every replica. That fits the roughly 2 minutes reported in the ticket. The new code has no such cliff; its cost grows with the size of the search result. On On a role-keyed cache or index in settings: I agree that's the proper fix for I ran it on a single machine, with all services in one oCIS process and the settings data on local disk, so each storage round trip is very cheap. In a production deployment those round trips go over the network, often to NFS or S3. I'd expect that to hurt the old sequential scan much more than the per-user lookups (10 at a time), but I haven't measured it. |
|
Ok , I think I get it now. The expectation is that the Basically, there are some details that explain those results:
Without touching how the information is stored in the FS, this solution is fine 👍 |
jvillafanez
left a comment
There was a problem hiding this comment.
Just a couple of minor things:
- Include a comment in the line with
g.identityBackend.GetUsers(ctx, req)to clarify we expect to get a few users, but not all of them. - Please run the code with the race detector enabled if not done already (need to build the binary with the
-raceoption). This is mostly to check that theelegiblelist doesn't cause problems. I don't think it will, but better to double check and get confirmation.
1ae92c4 to
e75a8e8
Compare
|
… vault
Searching for share recipients in the vault ("Safe") could take minutes,
because each search scanned the role assignments of every account in the
system. Vault eligibility is now checked only for the users the search
matched, a few at a time in parallel, so the search is about as fast as
outside the vault.
e75a8e8 to
75eecbc
Compare
Description
The user search behind
$filter=vaultEligible eq truenow checks vault eligibility only for the users the directory search matched. It fetches the roles once, then looks up each matched user's role assignments, up to 10 in parallel, keeping the search order. It no longer asks the settings service for every holder of a vault role, which made settings scan every account's assignments. The same users come back as before, and the request still fails closed on any lookup error.Related Issue
Motivation and Context
Searching for share recipients in the vault ("Safe") took seconds to minutes, because each search's cost grew with the total number of accounts in the system. With 3,000 role assignments it took 7.4 s, against 26 ms outside the vault; it now takes about 40 ms.
How Has This Been Tested?
Screenshots (if appropriate):
N.A
Types of changes
Checklist: