-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[BEEEP] Improve speed performance of Admin Console Collections page #20243
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
Open
JaredScar
wants to merge
10
commits into
main
Choose a base branch
from
beeep/improve-collections-page-speeds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ca7d11e
Optimize performance of vault component and services by running heavyβ¦
JaredScar 92b3827
Merge branch 'main' into beeep/improve-collections-page-speeds
JaredScar 7f942f6
Merge branch 'main' into beeep/improve-collections-page-speeds
JaredScar 5e54847
Refactor VaultComponent to subscribe to collectionAdminViews$ outsideβ¦
JaredScar 6d27d40
Merge branch 'main' of https://github.com/bitwarden/clients into beeeβ¦
JaredScar a3b16f8
Update extractors in search.worker.ts to return default values insteaβ¦
JaredScar 650d811
Refactor SearchService to improve code readability by adding braces fβ¦
JaredScar e7cf40f
Enhance VaultComponent logging to track loading times and collection/β¦
JaredScar 1962e86
Merge branch 'main' of https://github.com/bitwarden/clients into beeeβ¦
JaredScar f659f8c
refactor(vault): remove redundant cipher indexing call in search process
JaredScar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,24 +134,28 @@ export class DefaultCollectionAdminService implements CollectionAdminService { | |
| collections: CollectionResponse[] | CollectionAccessDetailsResponse[], | ||
| orgKeys: Record<OrganizationId, OrgKey>, | ||
| ): Promise<CollectionAdminView[]> { | ||
| const promises = collections.map(async (c) => { | ||
| if (isCollectionAccessDetailsResponse(c)) { | ||
| return CollectionAdminView.fromCollectionAccessDetails( | ||
| c, | ||
| this.encryptService, | ||
| orgKeys[organizationId as OrganizationId], | ||
| ); | ||
| } | ||
|
|
||
| return await CollectionAdminView.fromCollectionResponse( | ||
| c, | ||
| this.encryptService, | ||
| orgKeys[organizationId as OrganizationId], | ||
| const orgKey = orgKeys[organizationId as OrganizationId]; | ||
|
|
||
| // Promise.all(8K) floods the microtask queue β decrypt in chunks with event-loop | ||
| // yields so the browser can paint and handle input between each batch. | ||
| const DECRYPT_CHUNK_SIZE = 2_000; | ||
| const results: CollectionAdminView[] = []; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Porting state to the SDK will give better speed improvements. |
||
| for (let i = 0; i < collections.length; i += DECRYPT_CHUNK_SIZE) { | ||
| const chunk = collections.slice(i, i + DECRYPT_CHUNK_SIZE); | ||
| const decrypted = await Promise.all( | ||
| chunk.map(async (c) => { | ||
| if (isCollectionAccessDetailsResponse(c)) { | ||
| return CollectionAdminView.fromCollectionAccessDetails(c, this.encryptService, orgKey); | ||
| } | ||
| return await CollectionAdminView.fromCollectionResponse(c, this.encryptService, orgKey); | ||
| }), | ||
| ); | ||
| }); | ||
|
|
||
| const r = await Promise.all(promises); | ||
| return r; | ||
| results.push(...decrypted); | ||
| if (i + DECRYPT_CHUNK_SIZE < collections.length) { | ||
| await new Promise<void>((r) => setTimeout(r, 0)); | ||
| } | ||
| } | ||
| return results; | ||
| } | ||
|
|
||
| private async encrypt( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.