Skip to content

perf(notes): coalesce autosave persistence#497

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-notes-async-saves
Closed

perf(notes): coalesce autosave persistence#497
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-notes-async-saves

Conversation

@JustYannicc

@JustYannicc JustYannicc commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace synchronous Notes JSON writes on each mutation with a debounced async atomic write queue.
  • Keep notesCache as the authoritative in-memory state for immediate reads while persistence drains in the background.
  • Add flushNotesToDisk() / hasPendingNotesSave() and defer Electron quit only when a Notes save is pending or in-flight.
  • Add a focused Notes persistence regression harness that counts physical Notes JSON writes and verifies shutdown flush behavior.

Before / After Evidence

  • Baseline before production edits: 20 repeated autosaves produced 20 synchronous writes, loopMs=23.77, syncWriteMs=23.11.
  • After: 20 repeated autosaves produce 1 async atomic write, 0 sync writes, latest observed full-suite metric loopMs=2.62, syncWriteMs=0.00.

Validation

  • node --test scripts/test-notes-async-saves.mjs
  • node --test scripts/test-*.mjs (26 pass, 1 live Electron test skipped because Electron is not launchable here)
  • ./node_modules/.bin/tsc -p tsconfig.main.json
  • Codex LSP diagnostics for src/main: 0 errors
  • node scripts/check-i18n.mjs (exits 0; reports existing Italian locale gaps for settings.ai.whisper.vocabulary and settings.extensions.appSearchScope)
  • git diff --check

Remote Checks

  • claude-review failed before running review logic because the action could not fetch an OIDC token: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable; log suggests adding id-token: write to workflow permissions.

Risks / Notes

  • Persistence now returns to callers before disk rename completes; pending/in-flight writes are flushed on app quit.
  • If an async disk write fails, behavior matches the prior non-throwing save path by logging the error and preserving in-memory state.

@JustYannicc JustYannicc changed the title [codex] coalesce notes autosave persistence perf(notes): coalesce autosave persistence Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated upstream PR #534 (perf(mac): reduce native polling and async IO stalls), which carries this change together with the related macOS/native/audio/camera async IO performance fixes. Closing this source PR so review can continue on #534.

@JustYannicc JustYannicc closed this Jul 3, 2026
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