Skip to content

perf(frecency): memoize sorting defaults#493

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-frecency-sorting-memo
Closed

perf(frecency): memoize sorting defaults#493
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-frecency-sorting-memo

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

Summary

  • Hoists the default useFrecencySorting key resolver so stable rerenders do not invalidate useMemo.
  • Captures one frecency scoring timestamp per sort recompute instead of calling Date.now() for each score.
  • Adds a node test harness for stable rerenders, timestamp count, ordering, visit tracking, and reset behavior.

Evidence

  • Baseline before the production change: node --test scripts/test-use-frecency-sorting.mjs failed with stable rerender comparisons increasing 4 -> 8, and one sort reading Date.now() 8 times instead of 1.
  • After the change: node --test scripts/test-use-frecency-sorting.mjs passes all 3 tests.

Validation

  • npm test passes: 27 passed, 1 skipped.
  • npm run check:i18n exits 0; it still reports pre-existing Italian locale gaps for settings.ai.whisper.vocabulary and settings.extensions.appSearchScope.
  • npm run build:main passes.
  • npm run build:renderer passes.
  • LSP diagnostics for the edited hook report no diagnostics.

Risks

  • The default key now stringifies id values explicitly; object property access already coerced those keys for persisted records, so existing storage keys should continue to match.

@JustYannicc JustYannicc changed the title [codex] Memoize frecency sorting defaults perf(frecency): memoize sorting defaults Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated upstream PR #535: #535

@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