Skip to content

perf(script-command): avoid full script reads for headers#505

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-script-command-header-read
Closed

perf(script-command): avoid full script reads for headers#505
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-script-command-header-read

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

Summary

  • Replace full script reads during discovery with bounded prefix reads for the first Raycast metadata lines.
  • Cache shebang interpreter metadata on discovered script commands and reuse it during execution.
  • Add a source-backed benchmark plus regression tests for metadata parsing, shebang execution, no-shebang fallback, and large scripts.

Metrics

Benchmark: node scripts/bench-script-command-discovery.mjs with 40 script command files, each with a 1.0 MiB body.

Scenario Before After
Discovery time 98.8ms 16.4ms
Discovery runner bytes read 40.0 MiB 1.3 MiB
Cached execution shebang lookup time 8.7ms 4.4ms
Cached execution shebang lookup runner bytes read 1.0 MiB 0 B

Validation

  • node scripts/bench-script-command-discovery.mjs
  • pnpm test (29 passed, 1 existing live Electron skip)
  • pnpm run build:main
  • pnpm run check:i18n (exits 0; reports existing Italian locale gaps for settings.ai.whisper.vocabulary and settings.extensions.appSearchScope)
  • Codex LSP diagnostics on src/main: 0 errors

Risks

  • Header discovery now reads up to the first 120 lines with a 256 KiB cap. That preserves the existing 120-line metadata window for normal Raycast headers, but a script with extraordinarily long header lines could need its metadata moved closer to the top.

@JustYannicc JustYannicc changed the title [codex] Avoid full script reads for command headers perf(scripts): avoid full reads for command headers Jul 3, 2026
@JustYannicc JustYannicc changed the title perf(scripts): avoid full reads for command headers perf(script-command): avoid full script reads for headers 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