Skip to content

perf(icons): memoize Phosphor icon resolution#503

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-phosphor-icon-cache
Closed

perf(icons): memoize Phosphor icon resolution#503
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-phosphor-icon-cache

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

Summary

  • Add bounded module-level caches for Raycast icon-name lookup, Phosphor export lookup, and final Raycast-to-Phosphor resolution, including misses.
  • Preserve existing alias, fuzzy, filled-weight, and fallback behavior while avoiding repeated Phosphor export scans in hot render paths.
  • Add a focused resolver measurement script and cache tests for exact mappings, fallback behavior, and cache-clear assumptions.
  • Add a narrow ambient declaration for the existing direct Phosphor ESM import so the TypeScript LSP can type-check the runtime.

Metrics

Command: node scripts/measure-icon-resolution.mjs

Before caching:

  • exact/repeated: 20,000 calls, 37,496.837 ms, 0.533 calls/ms
  • unknown-fuzzy/repeated: 1,500 calls, 4,628.764 ms, 0.324 calls/ms

After caching:

  • exact/repeated: 20,000 calls, 5.085 ms, 3,933.362 calls/ms
  • unknown-fuzzy/repeated: 1,500 calls, 5.453 ms, 275.074 calls/ms

Validation

  • mcp__lsp.diagnostics on src/renderer/src/raycast-api/icon-runtime-phosphor.tsx: no diagnostics
  • mcp__lsp.diagnostics on src/renderer/src/vite-env.d.ts: no diagnostics
  • node --test 'scripts/test-*.mjs' passes; live Electron crash recovery test is skipped because Electron is not launchable here
  • PNPM_CONFIG_LOCKFILE=false pnpm run build:renderer passes
  • PNPM_CONFIG_LOCKFILE=false pnpm run check:i18n exits 0; it still reports pre-existing Italian missing keys: settings.ai.whisper.vocabulary, settings.extensions.appSearchScope

Risks

  • Caches assume the imported Phosphor namespace and generated Raycast icon maps are immutable for the lifetime of the renderer module.
  • Cache maps are bounded at 2,048 entries and clear wholesale when exceeded, so pathological streams of unique custom names trade occasional recomputation for bounded memory.

@JustYannicc JustYannicc changed the title [codex] Memoize Phosphor icon resolution perf(icons): memoize Phosphor icon resolution Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated renderer performance PR #533: #533. Closing this scoped source PR so review stays centralized there.

@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