perf: skip redundant synchronous settings writes - #2528
Open
OskarEichler wants to merge 2 commits into
Open
Conversation
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.
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.preval-build-info-cliandnode 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-summaryto 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.