Skip to content

[PM-45308] perf(cli): Skip storage writes that change nothing - #23957

Merged
quexten merged 1 commit into
cli-perf/04-copy-jsonfrom
cli-perf/05-skip-unchanged-writes
Oct 21, 2026
Merged

quexten merged 1 commit into
cli-perf/04-copy-jsonfrom
cli-perf/05-skip-unchanged-writes

Conversation

@quexten

@quexten quexten commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-45308

📔 Objective

Each save rewrites the whole data.json (~19 MB with a large vault), and bw get item saved two values that were already stored. The stored JSON is now compared first and the write skipped when it would not change. The update is still emitted, as before.

⏱️ Benchmark

Before = the previous PR in this stack, after = this PR.

Command Output before Output after Change Exit before Exit after Change
bw get item <id> 428 ms 392 ms −9% 434 ms 397 ms −9%
bw get password <id> 436 ms 400 ms −8% 442 ms 406 ms −8%
bw list items 925 ms 884 ms −4% 937 ms 896 ms −4%
bw status 399 ms 364 ms −9% 405 ms 370 ms −9%

Prod build (npm run build:oss:prod) run as node 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. Harness apps/cli/perf/bench.mjs: 3 interleaved rounds of 1 warmup + 5 runs per command; fastest run per round, median across rounds. Every run's output is checked.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (cli-perf/04-copy-json@d07650a). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...cli/src/platform/services/lowdb-storage.service.ts 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##             cli-perf/04-copy-json   #23957   +/-   ##
========================================================
  Coverage                         ?   59.32%           
========================================================
  Files                            ?     4699           
  Lines                            ?   148737           
  Branches                         ?    23722           
========================================================
  Hits                             ?    88232           
  Misses                           ?    54343           
  Partials                         ?     6162           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quexten quexten added the t:bugfix Change Type - Bugfix label Oct 19, 2026
@quexten
quexten marked this pull request as ready for review October 19, 2026 13:40
@quexten
quexten requested a review from a team as a code owner October 19, 2026 13:40
@quexten
quexten requested a review from djsmith85 October 19, 2026 13:40
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR changes LowdbStorageService.save in the CLI: it now compares the serialized value with what is already stored and skips the full data.json rewrite when they match. It still emits the save update as before. I checked the edge cases (a missing key saved as undefined or null, the in-memory state after readForNoCache, objects with the same content but different key order, and allowCache mode). In each case the result is the same as before, or the PR writes anyway. The new specs cover the skip, the emitted update, and the changed-value write.

@quexten
quexten force-pushed the cli-perf/05-skip-unchanged-writes branch from 370a380 to fda5fb2 Compare October 19, 2026 13:59
@quexten
quexten force-pushed the cli-perf/05-skip-unchanged-writes branch from fda5fb2 to 741f4f2 Compare October 19, 2026 14:04
@quexten
quexten requested review from dani-garcia and removed request for djsmith85 October 21, 2026 08:23
Each save rewrites the whole data.json, ~19 MB with a large vault, and
`bw get item` saved two values that were already stored. Compare the
stored JSON first and skip the write when it would not change. The
update is still emitted, as before.
@quexten
quexten force-pushed the cli-perf/05-skip-unchanged-writes branch from 741f4f2 to 222c618 Compare October 21, 2026 10:42
@quexten
quexten merged commit 60694f7 into main Oct 21, 2026
76 of 77 checks passed
@quexten
quexten deleted the cli-perf/05-skip-unchanged-writes branch October 21, 2026 11:50
@djsmith85 djsmith85 added the cli CLI Application label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI Application t:bugfix Change Type - Bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants