Repository navigation
[PM-46036] perf(vault): Decrypt the whole vault in batches, not get_all() - #24241
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24241 +/- ##
=======================================
Coverage 61.95% 61.95%
=======================================
Files 4928 4928
Lines 158958 158974 +16
Branches 25504 25504
=======================================
+ Hits 98483 98495 +12
- Misses 53711 53715 +4
Partials 6764 6764 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
43d61cf to
a6ed509
Compare
a6ed509 to
110455e
Compare
110455e to
5fce199
Compare
d492898 to
6a9f9d5
Compare
6a9f9d5 to
ed5a76c
Compare
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR replaces the SDK's |
ed5a76c to
4fc0b54
Compare
5538cb5 to
470ab35
Compare
get_all() has the SDK read every cipher from its state repository and return every full cipher view in one call, so all encrypted inputs and decrypted outputs sit in WebAssembly memory at once. That memory is never given back: the extension's service worker grew from 3 MB to 130 MB on a 12k item vault after login. CipherSdkService.getAllDecrypted becomes legacyDecryptFullViewList, which takes the encrypted ciphers from state and decrypts them 250 at a time with decrypt_list_full_with_failures, bounding the peak to one batch. It is named legacy because it still holds every full view at once; going over the whole vault belongs in an iterator in the SDK. The ciphers are read without localData, which is attached to the views afterwards, so a failure to read it no longer fails the decrypt.
470ab35 to
e228ce2
Compare
Replace the batching switch with a temporary serial decrypt. The getAllDecrypted call stays commented out so the switch back is trivial. One cipher per SDK call keeps WebAssembly memory from growing to the size of the vault.
Keep the temporary fix local to CipherService: decrypt each cipher with the existing single-cipher decrypt and leave CipherSdkService untouched. Stays until PM-46138 merges.
|
@quexten should the description be updated since we now handle the decryption serially? and did you re-do the benchmarks? |
|
Re-measured against
Popup WASM, service worker JS heap, decrypted cache and plaintext password count are unchanged.
Unlock is about 100 ms slower than main, consistently across runs (master password: 1371 / 1367 ms on main, 1470 / 1459 ms on the PR). The PIN figure has one PR run; the second failed on a harness flake. Not profiled; likely the serial decrypt. |
|
@gbubemismith I've added the re-measured bench numbers above. The unlock time is slightly larger for large vaults, but the follow-up PR's will reduce it again. The memory usage is still vastly decreased. |
🎟️ Tracking
PM-46036
📔 Objective
ciphers().get_all()has the SDK read every cipher from its state repository and return every full cipher view in one call: all encrypted inputs and decrypted outputs in SDK (WebAssembly) memory at once, which is never given back. The extension's service worker went from 3 MB to 130 MB of SDK memory after login on a 12k item vault.We are introducing a temporary work around until platform's other improvements merge.
Measurements (old)
Measured on
main(e44dc1f) with the e2e harness (#24239), 12k item vault, prod Chrome build. Memory from one run; footprint varies ±5% run to run. Unlock times are medians of 10, timed from the lock screen's form submit.📸 Screenshots
N/A