Skip to content

fix(rust): scope Windows CLI thread lookup to the child process - #2829

Closed
Chuxel wants to merge 1 commit into
mainfrom
chuxel-windows-sdk-launch-overhead
Closed

Chuxel wants to merge 1 commit into
mainfrom
chuxel-windows-sdk-launch-overhead

Conversation

@Chuxel

@Chuxel Chuxel commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the Rust SDK's machine-wide Toolhelp thread scan with a process-scoped PSS thread snapshot for managed Windows stdio and TCP CLI launches. Verify the successfully opened thread handle's owning process before resuming it, protecting against stale or reused thread IDs.

Preserve suspended process creation, private per-client kill-on-close Jobs, assignment before execution, initial-thread resume, cancellation and descendant cleanup. Snapshot and walk-marker resources use their documented freeing APIs, and capture/walk/open/query/resume failures propagate while the suspended root is terminated. No public API, launch flags, deadlines or CLI pins change.

Add private ownership/error-path regressions and public-client fixtures for both transports, cancelled startup, descendant cleanup, final-clone/private-Job isolation and abrupt host termination. Update the Windows startup documentation.

Refresh generated Rust Bazel metadata for the Windows feature declarations and already-locked development dependencies. Regeneration also brings stale AHP/HPKE/rand_core development-dependency metadata up to date; dependency versions and lockfiles are unchanged.

Validation

  • 337 runtime/test-support library tests passed, including 9 private process-tree tests.
  • 24 client-options E2Es passed, including the new Windows lifecycle fixtures.
  • Stdio/TCP startup and abrupt-host cleanup smoke passed using the prepared 1.0.95-2 runtime bundle; in-process smoke and 15 external-stream protocol tests passed.
  • All-target/all-feature Clippy with warnings denied, external-stream-only compilation, pinned formatting, shared fixture syntax and whitespace checks passed.

Compiled SDK seam measurement

Same SDK base (341a526b), Rust 1.94.0, debug profile, runtime/test-support features and owned exit-only cmd.exe fixture. Alternate the instrumented Toolhelp and PSS helpers, with one warmup batch and six measured batches per arm and worker count. The regression reaps its child before emitting the phase measurement; all 42 children including warmups were reaped.

Workers Samples per arm Toolhelp lookup p50 / p95 PSS lookup p50 / p95
1 6 88.940 / 111.589 ms 0.227 / 0.368 ms
2 12 103.692 / 142.251 ms 0.247 / 0.342 ms

Toolhelp inspected 8,157-8,261 entries; PSS inspected one. Percentiles use nearest rank. These are small-sample measurements on a shared Windows machine, not CLI handshake or inference measurements. OS spawn outliers remain, and the measurements do not establish a startup timeout's cause.

Replace machine-wide Toolhelp enumeration with process-scoped PSS thread
snapshots. Verify the opened thread handle's owner before resume while
preserving suspended startup and private kill-on-close Job ownership.

Add Windows ownership, failure-path and lifecycle regressions and document
the startup guarantees.

Refresh generated Bazel metadata for the Windows feature declarations and
already-locked SDK development dependencies without changing versions or pins.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 64381057-4f81-414b-b1e0-33f4d1cde243
}
}
Err(error) if error.kind() == io::ErrorKind::NotFound => {}
Err(error) => panic!("read fixture PID: {error}"),
@Chuxel Chuxel closed this Oct 9, 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.

2 participants