Skip to content

perf(icons): coalesce file icon IPC#526

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

perf(icons): coalesce file icon IPC#526
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-file-icon-cache-coalesce-pr

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added path-keyed in-flight coalescing around Raycast file icon IPC requests so concurrent identical file icons share one getFileIconDataUrl call.
  • Replaced the unbounded renderer fileIconCache with a 1024-entry LRU cache for successful data URLs and resolved null fallbacks.
  • Kept rejected IPC failures retryable by avoiding permanent negative cache writes on rejection.
  • Added a self-contained node:test harness for concurrent duplicate icons, rejection recovery, LRU eviction, and non-file image icon behavior.

Why

The file icon runtime lived on a hot render path for Raycast list/grid items. Before this change, duplicate mounted file icons could all observe a cache miss before the first IPC call resolved, so identical icons fanned out into repeated getFileIconDataUrl IPC calls. The cache was also a module-level Map with no cap, so browsing or rendering many unique paths retained every icon result for the life of the renderer.

Baseline mock-render harness for the pre-fix request/cache logic reported sameMountedIcons=100, sameIpcCalls=100, uniqueMountedIcons=5000, uniqueIpcCalls=5000, and uniqueCacheEntries=5000.

Compatibility impact

Raycast icon rendering semantics are preserved. File icons still render the same data URL image when available, and still fall back to the existing document/folder glyph while loading or after unavailable icons. Cached file icons may remain stale, matching the existing tolerance. Non-file icon paths continue through the existing remote/image/Phosphor handling. No user-facing strings or locale files changed.

How tested

  • Baseline before fix: node -e <mock old FileIcon request/cache harness> -> {"sameMountedIcons":100,"sameIpcCalls":100,"uniqueMountedIcons":5000,"uniqueIpcCalls":5000,"uniqueCacheEntries":5000}.
  • After fix on scoped branch: node --test scripts/test-icon-runtime-file-icon-cache.mjs -> pass; asserts 100 concurrent identical mounts call IPC once, rejected IPC retries later, 5,000 unique paths stay capped at 1,024 cache entries with LRU eviction, and non-file image icons do not call file icon IPC.
  • Scoped diff check: git diff --check origin/main...HEAD -> pass.
  • Renderer typecheck on scoped origin/main branch: ./node_modules/.bin/tsc -p tsconfig.renderer.json --noEmit was attempted and is blocked by existing unrelated origin/main errors, including src/renderer/src/App.tsx, src/renderer/src/CameraExtension.tsx, src/renderer/src/components/LiquidGlassSurface.tsx, and other pre-existing renderer type issues outside this PR diff.

Stack validation

The runtime fix was developed and validated from codex/perf-integration-stack, which contains the active performance stack. Before creating this scoped origin/main PR branch, the stack-based worker branch passed:

  • node --test scripts/test-icon-runtime-file-icon-cache.mjs
  • node --test scripts/test-icon-asset-cache.mjs scripts/test-icon-runtime-phosphor-cache.mjs
  • ./node_modules/.bin/tsc -p tsconfig.renderer.json --noEmit
  • git diff --check

The upstream PR branch codex/perf-file-icon-cache-coalesce-pr was created from origin/main and contains only the file-icon runtime/test diff.

@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