Pre-warm cipher decryption on desktop to remove vault search lag#20482
Open
mikolajbuczak wants to merge 1 commit intobitwarden:mainfrom
Open
Pre-warm cipher decryption on desktop to remove vault search lag#20482mikolajbuczak wants to merge 1 commit intobitwarden:mainfrom
mikolajbuczak wants to merge 1 commit intobitwarden:mainfrom
Conversation
`cipherListViews$` is a per-user `shareReplay`-cached observable whose first subscription triggers SDK decryption of the entire vault. The desktop vault component subscribes to it on mount, so users hit a multi-second delay between typing in the search input and seeing filtered results immediately after login. Subscribe to `cipherListViews$` in `AppComponent` for the active user so the cache is hot by the time the vault page renders. `switchMap` swaps the subscription on account changes; `takeUntil(this.destroy$)` matches the existing teardown pattern in this file. Add specs in `libs/common/src/vault/services/`: - `search.service.perf.spec.ts` baselines basic search performance (median 6ms for 10000 ciphers). - `vault-search-pipeline.lag.spec.ts` reproduces the lag (~3000ms) and verifies the pre-warm pattern eliminates it (<200ms, observed 9ms).
|
|
|
Thank you for your contribution! We've added this to our internal tracking system for review. Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🎟️ Tracking
Community contribution. No Jira ticket.
📔 Objective
After signing in to the desktop app, typing in the vault search bar produces no
filtered results for the first few seconds (~3s on a typical vault). The lag
scales with vault size.
The vault component composes its filtered list as
combineLatest([cipherListViews$, filter$, searchText$])(seeapps/desktop/src/vault/app/vault-v3/vault.component.ts:397-419). The firstsubscription to
cipherListViews$is what triggers SDK decryption of theentire vault, and that only happens when the user navigates to the vault page.
Until decryption completes,
combineLatestdoes not fire, so the search inputappears unresponsive.
This change adds a pre-warm subscription to
cipherListViews$inAppComponentfor the active user. BecausecipherListViews$is wrapped in aper-user
shareReplay(libs/common/src/vault/utils/observable-utilities.ts),by the time the vault page mounts the cache is hot and basic search is
instantaneous.
switchMap(account => account?.id ? cipherListViews$(account.id) : EMPTY)handles login/logout/account switches automatically;
takeUntil(this.destroy$)matches the existing teardown pattern in this file.
Verification
Two new specs in
libs/common/src/vault/services/:search.service.perf.spec.tsbenchmarks basic search across100/1000/5000/10000 ciphers. Median for 10000 ciphers: 5.97ms — confirms
SearchServiceitself is not the bottleneck.vault-search-pipeline.lag.spec.tsreproduces the multi-second lag in aunit test by simulating a delayed
cipherListViews$first emission, andasserts that pre-warming reduces user-visible latency from ~3010ms to <200ms
(observed 9ms locally).
All 642 specs in
libs/common/src/vault/pass. ESLint and Prettier pass onthe modified files.
📸 Screenshots
N/A — no UI changes.