Skip to content

perf: skip redundant synchronous settings writes - #2528

Open
OskarEichler wants to merge 2 commits into
ferdium:developfrom
OskarEichler:codex/skip-unchanged-settings-writes
Open

perf: skip redundant synchronous settings writes#2528
OskarEichler wants to merge 2 commits into
ferdium:developfrom
OskarEichler:codex/skip-unchanged-settings-writes

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 27, 2026

Copy link
Copy Markdown

Pre-flight Checklist

Description of Change

Merge settings into a fresh object, then skip observable replacement and synchronous JSON writes when the merged settings are unchanged.

This avoids repeated main-process filesystem work for duplicate settings updates, including the startup settings round-trip. Actual changes are written before publishing the new observable state, so a failed write leaves the old state intact and can be retried. No debounce or shutdown-flush behavior is introduced.

The non-mutating merge also keeps the supplied defaults from being overwritten during hydration and subsequent updates. This uses the existing lodash dependency.

Reproduction and Verification

An isolated check sending 100 identical nested settings updates records 100 synchronous writes before the change and zero after it. A subsequent real change still writes once. Hydration/merge behavior, initial file creation, immutable defaults, preservation of existing keys, and retry after a simulated disk-write failure were also checked.

Validated independently on this branch with Node 24.18.1 / pnpm 11.20.0:

  • pnpm typecheck.
  • ESLint with zero warnings, Prettier, and Biome on the changed files.
  • Existing Jest suite: 14 suites passed; 119 tests passed, 2 existing skips.
  • Source build via preval-build-info-cli and node esbuild.mjs.
  • git diff --check.

The Node-only Jest run used ELECTRON_OVERRIDE_DIST_PATH="$PWD/node_modules/electron/dist" pnpm test --runInBand --coverageReporters=text-summary to avoid Electron's lazy binary download. No Electron GUI was launched, and native cross-platform interaction / packaged installers were not tested. No test files were added or changed; the targeted old/new comparisons were isolated runtime checks.

Release Notes

Avoid redundant synchronous settings writes and preserve default settings during merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant