Skip to content

perf(sync): render all skills in one bash process per adapter - #139

Closed
panesofglass wants to merge 1 commit into
danielvm-git:mainfrom
panesofglass:fix/srp-engine-single-pass-render
Closed

panesofglass wants to merge 1 commit into
danielvm-git:mainfrom
panesofglass:fix/srp-engine-single-pass-render

Conversation

@panesofglass

Copy link
Copy Markdown
Contributor

Fixes #138.

Problem

srp-engine.py --all spawned one bash (plus three jq) per skill×adapter — about 1,539 bash and 4,600 jq processes from a single Python process. On a constrained Windows session that exhausts process-creation resources: the run dies with STATUS_DLL_INIT_FAILED (0xC0000142) and then hangs, because the failed spawn's orphaned descendants keep the stdio pipes open. bigpowers setup always runs this step, so it affects every install.

Change

  • Serialize every skill's IR once to a NUL-delimited stream (_write_ir_stream).
  • New scripts/lib/adapter-render-all.sh: sources one adapter and calls its render_skill() for each record, in-process.
  • render_all() spawns one bash per adapter; the IR no longer travels as JSON on stdin, so the per-render jq calls disappear.
  • Adapters without a stdin entrypoint (continue, omp, zed) still no-op, matching today's behaviour.
  • A failing render_skill exits non-zero, so the engine aborts instead of hanging.
before: 1,539 bash + ~4,600 jq      after: 19 bash + 0 jq

Verification

  • python3 tests/test_srp_engine.py — 26 tests OK; adds coverage for _write_ir_stream field layout, render_all batching (one process per adapter, not per skill×adapter), failure/missing-adapter exits, and the bash driver end-to-end.
  • Full python3 scripts/lib/srp-engine.py --all with the sync-skills.sh environment on Windows: exit 0 and git status clean — the tracked generated artifacts are unchanged. The old path additionally emitted CRLF in rendered bodies on Windows (native jq writing text mode); this writes LF, matching the committed artifacts and CI.
  • bash scripts/golden-g14-adapter-dispatch.sh — PASS (and --self-test PASS).

Notes

srp-engine.py --all spawned one bash (plus three jq) per skill×adapter:
~1,539 bash and ~4,600 jq processes from a single Python process. On a
constrained Windows session that exhausts process-creation resources, so
the run dies with STATUS_DLL_INIT_FAILED (0xC0000142) and then hangs on
orphaned children (the failed spawn's descendants keep the stdio pipes
open, so the caller blocks on EOF).

Serialize every skill's IR once to a NUL-delimited stream and drive a
small bash helper (adapter-render-all.sh) that sources one adapter and
calls render_skill() in a loop. The rendering code is unchanged; the
per-render jq calls and per-skill×adapter bash spawns are gone:

  before: 1,539 bash + ~4,600 jq (from one Python process)
  after:  19 bash + 0 jq

Adapters without a stdin entrypoint (continue, omp, zed) keep no-opping,
and a failing render_skill now exits non-zero so the engine aborts
instead of hanging. Generated artifacts are byte-identical: a full --all
on Windows leaves the tracked output unchanged (and no longer emits CRLF
in rendered bodies, which the old native-jq path did).

Refs danielvm-git#138.
@danielvm-git

Copy link
Copy Markdown
Owner

before: 1,539 bash + ~4,600 jq → after: 19 bash + 0 jq — that says it all. The test coverage you added for _write_ir_stream, render_all batching, and the bash driver end-to-end is what separates a fix from a contribution. Thank you for bringing the Windows story all the way home.

@danielvm-git

Copy link
Copy Markdown
Owner

Closing in favour of #155, which rebases your changes on top of #137 (merged). Your render_all approach is the right fix — the rebase only swaps the inline bash-resolution for the resolve_bash() function from #137 to keep both improvements. All your tests are included. Thank you for the excellent work, @panesofglass!

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.

sync-skills --all spawns ~1,539 bash + ~4,600 jq processes; exhausts resources and hangs on constrained Windows sessions

2 participants