Skip to content

perf(ipc): harden native helper readiness#612

Closed
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-ipc-native-helper-lifecycle
Closed

perf(ipc): harden native helper readiness#612
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-ipc-native-helper-lifecycle

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Replaced 50 ms polling startup readiness waits for Whisper.cpp, Parakeet, Qwen3, and audio capturer with event-driven readiness waiters backed by one startup timeout.
  • Added shared native-helper output buffer utilities and applied conservative caps to JSON-line stdout buffers plus plain stderr/stdout buffers found during the audit.
  • Extended the native helper lifecycle harness to cover timer count, no-poll readiness, bounded buffer behavior, pending request rejection cleanup, and stale-child regressions.

Why

Malformed native helper output could grow partial-line buffers without bound, and readiness polling allocated repeating timers while waiting for events the helpers already emit.

Compatibility impact

  • Preserves existing native helper JSON line protocol semantics for normal ready/result/error messages.
  • Preserves timeout, killed-process, superseded-child, and pending-request rejection behavior.
  • Leaves generic spawn IPC and legacy Raycast-compatible channels unchanged.

How tested

  • node --test scripts/test-native-helper-process-lifecycle.mjs passed: 8 tests.
  • ./node_modules/.bin/tsc -p tsconfig.main.json --noEmit --pretty false passed.
  • Codex LSP diagnostics on src/main/main.ts and src/main/native-helper-lifecycle.ts: no diagnostics found.
  • git diff --check passed.

Performance evidence

  • Startup readiness wait test asserts one setTimeout and zero setInterval allocations, replacing the previous 50 ms polling interval per helper startup.
  • Ready-event settlement clears the single startup timeout immediately when the helper emits ready.
  • Native helper partial-line buffers are capped at 256 KiB, and oversized completed malformed lines are dropped while normal JSON lines continue through.

Stack validation

  • Started from verified base SHA ac90ce403aeddab98d0a1b245afce268c48b8bfd on codex/perf-wave4-integrated-stack-20260705.
  • Built implementation branch codex/perf-ipc-native-helper-lifecycle.
  • Confirmed no tracked package metadata changes from local dependency installation.

Replaces

  • Supersedes the wave5 delegated implementation request for native helper readiness, buffer bounds, and subprocess lifecycle cleanup.
  • Rejected/deferred generic spawn IPC event batching because the existing path already emits unified spawn-event plus legacy channels, and batching would broaden compatibility/timing risk beyond this scoped helper fix.

(cherry picked from commit 83c2a89)
(cherry picked from commit 0a7560b)
# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…launcher surfaces

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…IO stalls

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…resh overhead

# Conflicts:
#	scripts/bench-script-command-discovery.mjs
#	scripts/benchmark-file-search-delete-batch.mjs
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-file-search-delete-batch.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/file-search-index.ts
#	src/main/main.ts
…hurn

# Conflicts:
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-extension-lifecycle-sandbox.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
… hot paths

# Conflicts:
#	scripts/test-use-frecency-sorting.mjs
#	src/renderer/src/raycast-api/form-runtime.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/grid-runtime-items.tsx
#	src/renderer/src/raycast-api/hooks/use-frecency-sorting.ts
# Conflicts:
#	.github/workflows/project-checks.yml
#	package.json
#	scripts/file-search-perf-harness.mjs
#	scripts/test-browser-search-performance.mjs
#	scripts/test-file-search-perf-harness.mjs
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/hooks/useBrowserSearch.ts
#	src/renderer/src/raycast-api/list-runtime.tsx
…cle and media fixes

# Conflicts:
#	scripts/lib/ts-import.mjs
#	scripts/measure-extension-bundle-cache.mjs
#	src/main/commands.ts
#	src/main/extension-runner.ts
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/list-runtime-hooks.ts
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated runtime/lifecycle/media PR: #622

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