Repository navigation
[PM-45308] perf(cli): Copy cached storage values without structuredClone - #23956
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## cli-perf/03-storage-read-cache #23956 +/- ##
===============================================================
Coverage 59.31% 59.32%
===============================================================
Files 4699 4699
Lines 148727 148735 +8
Branches 23719 23721 +2
===============================================================
+ Hits 88220 88232 +12
+ Misses 54344 54340 -4
Partials 6163 6163 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR replaces |
dani-garcia
left a comment
There was a problem hiding this comment.
Sounds reasonable, I'm surprised structuredClone is that slow
5d9919e to
dfc98ea
Compare
dfc98ea to
2b39f26
Compare
The storage cache returns a copy on every get, and a command reads the whole ciphers value (~16 MB for a large vault) at least once. structuredClone took ~22 ms for it. The cache only ever holds plain JSON, so a direct recursive copy gives the same result in ~6 ms.
2b39f26 to
d07650a
Compare
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-45308
📔 Objective
The storage cache returns a copy on every get, and a command reads the whole ciphers value (~16 MB for a large vault) at least once.
structuredClonetook ~22 ms for it. The cache only ever holds plain JSON, so a direct recursive copy gives the same result in ~6 ms. End to end the gain is small: the medians below improve, but the rounds overlap, so it is within run-to-run noise.⏱️ Benchmark
Before = the previous PR in this stack, after = this PR.
bw get item <id>bw get password <id>bw list itemsbw statusProd build (
npm run build:oss:prod) run asnode build/bw.js, Node 25.9.0, Apple M5 Pro. Account with 11,996 items on vault.usdev.bitwarden.pw (data.json ~19 MB), Bitwarden Desktop running. Harnessapps/cli/perf/bench.mjs.