Skip to content

perf(commands): cache script command icon data#568

Closed
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-script-command-icon-cache
Closed

perf(commands): cache script command icon data#568
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-script-command-icon-cache

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added a module-level file icon data URL cache for script commands, keyed by resolved absolute icon path plus the icon file size and mtime signature.
  • Kept script command discovery invalidation focused on script metadata while reusing unchanged file icon data across cold discoveries.
  • Extended the script command discovery benchmark with an icon-heavy fixture and invalidated discovery/execution measurements.
  • Added focused coverage that verifies cached file icons avoid repeat byte reads and changed icon files refresh.

Why

Running a script command after the 12s discovery TTL can force a cold rediscovery. File-based script icons were re-read and base64 encoded on every cold discovery, so icon-heavy command sets repeatedly paid the full icon I/O cost even when icon files had not changed.

Compatibility impact

  • Emoji icons and https:// icon values still bypass file icon reads.
  • File icon support remains limited to the existing SVG, PNG, JPG, and JPEG data URL behavior.
  • Raycast metadata parsing and iconDark/icon precedence are unchanged.
  • Script metadata is still refreshed on discovery cache invalidation; changed file icons are picked up when their file signature changes.

How tested

  • node --test scripts/test-script-command-runner.mjs
  • node --test 'scripts/test-*.mjs' (236 pass, 1 skipped)
  • ./node_modules/.bin/tsc -p tsconfig.main.json --noEmit
  • Codex LSP diagnostics for src/main/script-command-runner.ts: no diagnostics found
  • node scripts/bench-script-command-discovery.mjs

Performance evidence

Command: SUPERCMD_BENCH_SCRIPT_COUNT=250 SUPERCMD_BENCH_SCRIPT_BODY_BYTES=0 SUPERCMD_BENCH_SCRIPT_ICON_BYTES=98304 node scripts/bench-script-command-discovery.mjs

Before cache:

  • initial discovery: 31.7ms, 250 readFileSync calls, 23.4 MiB icon bytes
  • invalidated discovery: 28.1ms, 250 readFileSync calls, 23.4 MiB icon bytes, 23.5 MiB total runner bytes
  • invalidated execution lookup: 27.4ms, 250 readFileSync calls, 23.4 MiB icon bytes, 23.5 MiB total runner bytes

After cache:

  • initial discovery: 33.5ms, 250 readFileSync calls, 23.4 MiB icon bytes
  • invalidated discovery: 8.5ms, 0 readFileSync calls, 0 B icon bytes, 76.1 KiB total runner bytes
  • invalidated execution lookup: 11.1ms, 0 readFileSync calls, 0 B icon bytes, 76.1 KiB total runner bytes

Default emoji benchmark remains healthy: node scripts/bench-script-command-discovery.mjs reported initial discovery 11.9ms and 0 readFileSync bytes.

Stack validation

Started from codex/perf-consolidated-integration-stack / fork/codex/perf-consolidated-integration-stack at 264fb89dc5c867d6c3d77bc4b95e26e235e326ea. Implementation branch is codex/perf-script-command-icon-cache at 7405505.

Replaces

None.

…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
… into codex/perf-consolidated-integration-stack
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated upstream PR #573: #573. Closing this smaller PR to keep the command/file wave consolidated.

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