Skip to content

perf(shell): pool private channel instances across session commands - #947

Draft
Haoming9527 wants to merge 1 commit into
work/872-presentation-cachefrom
work/872-channel-pool
Draft

Haoming9527 wants to merge 1 commit into
work/872-presentation-cachefrom
work/872-channel-pool

Conversation

@Haoming9527

@Haoming9527 Haoming9527 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #872. Stacked on #946 (work/872-presentation-cache).

What was wrong

Every persistent-shell command recreated three private channels: twelve named-pipe instances and twelve reader threads. The channel-wakeup changes removed the long drain delay, but repeated allocation and teardown still contributed to roughly 9 ms command latency.

The change

Create three bounded pools per session and reuse their private pipe instances and reader threads. Each command gets fresh captures, authenticated prefixes, seal/cancel state and spill ownership. Every connect must be armed before the endpoint is published. Output still drains to authenticated natural EOF and checked spill settlement; operations and task captures retire before the generation completion event. Retiring channels clear their cancellation handles before returning the lease, and old views remain separate. Timeout or panic poisons reuse permanently.

The driver uses these pools for stdout, stderr and receipts. Receipt parsing, Job identity checks, unregistered-output detection, surviving-descendant reset and independent session cancellation remain unchanged. The pool retains twelve readers per active session and still reconnects MSYS endpoints per command; it is not a persistent framed-output protocol.

Includes bilingual docs/changelog, raw benchmark reports, owned-child regressions and a real-resident endpoint reuse regression. No dependency, runtime pin, release or model-facing schema change.

Validation

  • npm run build and release driver/worker builds: passed.
  • cargo clippy -p ops-process --all-targets --locked --manifest-path native/Cargo.toml -- -D warnings: passed.
  • Process-crate tests passed; four new pool tests cover fixed identities across generations, stale prefix refusal, separate spill files, task resource retirement and panic poisoning. A fifth test verifies timeout poisoning survives late task completion.
  • Required ownership/admission/output/slot/spill filters: 12 suites passed, 0 failed, 0 skipped.
  • Behavioral red/green with the same resident integration test: the old worker fails endpoint reuse (1 failed, 3 existing integrity checks passed); pooled worker passes all 4 checks. Session endpoints remain distinct and request generations remain fresh.
  • Full local release gate: all 13 steps passed; 745 Rust tests passed, 9 ignored child fixtures, 265 JavaScript suites passed, 4 permitted skips, 0 failures, 92 manifest checks, and staged/packed runtime closure passed. It uses the verified stock archive and explicit legacy Bash fixture, with installed GNU tar for Unicode package filenames. The subsequently added timeout-poison test and endpoint-reuse assertion passed separately; current-head CI includes both.

Same comparison harness, Windows host, stock Niubash and release profile; 300 empty samples after 30 warmups, 100 printf samples, original 256 MiB bulk arm; before then after:

Command Before p50 / p95 After p50 / p95
Empty 8.66 / 9.70 ms 6.90 / 8.84 ms
printf x 8.61 / 9.68 ms 6.52 / 7.29 ms

Raw reports and binary hashes are in bench/probes/872/channel-pool-evidence. The 1 ms / 3 ms acceptance target remains unmet. The 106-operation scenario, cold startup and full host overhead remain unmeasured; no WSL superiority or full #872 acceptance is claimed.

Pull-request-triggered CI: https://github.com/T-Auto/dsh-ops/actions/runs/43614804031 (all 10 jobs passed, including CI required).

Environment

Windows x64 10.0.26300, Ryzen 7 6800HS, Node 26.12.1, Rust 1.97.1 release, locked dependencies and an isolated Cargo target. Base #946 at 54b681f6e360571458d7cfb6c584106ae70ecc06 has all 10 CI jobs green: https://github.com/T-Auto/dsh-ops/actions/runs/43613610235. No merge, tag or release.

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