Skip to content

perf(icons): cache local asset existence checks#484

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

perf(icons): cache local asset existence checks#484
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-icon-asset-cache

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What Changed

  • Added a bounded positive cache for local icon/asset existence checks in icon-runtime-assets.tsx.
  • Kept negative checks uncached so newly-created extension assets can resolve without waiting for invalidation.
  • Added a focused Node test harness for resolveIconSrc that stubs window.electron.statSync and covers extension-relative assets, sc-asset:// URLs, absolute paths, missing assets, configured assetsPath, and the repeated-resolution measurement.

Why

resolveIconSrc was calling window.electron.statSync synchronously every time a local icon or asset source was normalized. List rows, grid cells, and action overlays can all hit this path repeatedly, so resolving the same known-good asset caused repeated sync renderer-to-main IPC/stat work.

Compatibility Impact

  • sc-asset://ext-asset URL formatting and local path resolution are unchanged.
  • Missing files are intentionally not cached, preserving fallback behavior for assets that appear later.
  • Positive results may stay warm until the 4096-entry cache clears. If an asset is deleted after a positive check, the renderer may still emit its sc-asset:// URL until the cache is cleared; this matches the accepted positive-only caching tradeoff for stable extension asset paths.

Metrics

Baseline before code changes, 10,000 resolves of the same stubbed local asset path:

Case statSync calls elapsedMs
relative-positive 10,000 18.216
sc-asset-positive 10,000 31.312
absolute-positive 10,000 14.656
relative-negative 10,000 3.197

After change, same 10,000-resolve measurement with a fresh module per case:

Case statSync calls elapsedMs
relative-positive 1 15.771
sc-asset-positive 1 33.430
absolute-positive 1 15.359
relative-negative 10,000 5.770

The checked-in focused test also reports: iterations=10000 statSync=1 elapsedMs=14.997.

Checks

  • node --test scripts/test-icon-asset-cache.mjs
  • pnpm test — 30 passed, 1 skipped live Electron test
  • pnpm build:renderer
  • pnpm check:i18n — command exited 0; reported existing missing Italian keys settings.ai.whisper.vocabulary and settings.extensions.appSearchScope
  • Codex LSP diagnostics on src/renderer/src/raycast-api/icon-runtime-assets.tsx — no errors

Notes / Risks

  • A broader LSP scan of src/renderer/src/raycast-api still reports unrelated pre-existing TypeScript diagnostics in context-scope-runtime.ts and hooks/use-cached-promise.ts.
  • Full pnpm build was not run because this change is renderer-only and the full build compiles native Swift/addon artifacts; pnpm build:renderer was run for the touched surface.

@JustYannicc JustYannicc changed the title [codex] Cache local icon asset existence checks perf(icons): cache local asset existence checks 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