Repository navigation
Conversation
`Cmd::stream`'s `forward_signals=true` path was running a `try_wait` + `thread::sleep(10ms)` + `signals.pending()` loop, imposing a ~13ms wall floor on every alias and hook subprocess dispatch — ~70% of `execute_shell_command` time for short aliases. Replace with an event-driven shape: a listener thread blocks on `Signals::forever()` and forwards SIGINT/SIGTERM to the child; the main thread blocks on `child.wait()`. After wait returns, `handle.close()` unblocks the listener and we `join()` it (always, even on wait error). First-signal-only semantics preserved via an `Arc<AtomicI32>` sentinel (0 = none, since POSIX signals are >= 1) with `compare_exchange`. Memory ordering is `Relaxed` since `JoinHandle::join` provides the synchronization edge. Re-press escalation logic (`forward_signal_with_escalation`) is unchanged. Empirical: `wt step <trivial-alias>` 30.4ms → 20.4ms (1.49× faster). Co-Authored-By: Claude <[email protected]>
worktrunk-bot
previously approved these changes
May 3, 2026
worktrunk-bot
dismissed
their stale review
May 3, 2026 00:31
codecov/patch failing — likely false positive (the uncovered branches existed on main before the refactor, just at different line numbers), but per CLAUDE.md dismissing until the coverage gap is either addressed or confirmed as a false positive.
Extract `child.wait()` and its error mapping out of the forward_signals if/else, then fold the listener-state setup into `signals.map(|...|)` and teardown into `.and_then()`. One wait, one map_err, no duplication. As a bonus this drops the separate `#[cfg(not(unix))] let status = child.wait()...` arm — Windows now takes the same `wait_result.map_err(...)?` line as Unix. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
May 3, 2026
max-sixty
added a commit
that referenced
this pull request
May 3, 2026
Follow-up to #2537. `output/concurrent.rs::spawn_signal_forwarder` was running the same kind of `pending()` + 25 ms sleep ticker that #2537 removed from `Cmd::stream`. Replace it with the same event-driven shape: the listener thread blocks on `Signals::forever()`, and `SignalForwarder::stop()` closes the signal-hook handle to unblock it before joining. Drops the `Arc<AtomicBool>` stop flag — the signal-hook handle now serves both shutdown signaling and signal delivery. Two-press SIGKILL semantics (impatient escalation on the second SIGINT) are preserved via the local `seen_once` flag in the listener. Latency under Ctrl-C improves from "up to 25 ms after the press" to "as soon as signal-hook delivers the signal" — most useful for the second SIGINT in the kill-all path. `test_alias_concurrent_second_sigint_kills` still completes within its 3 s budget. > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude <[email protected]>
Merged
max-sixty
added a commit
that referenced
this pull request
May 3, 2026
Cuts v0.47.0. Highlights: - **Integration detection fix** across `wt list`, `wt remove`, `wt merge`, `wt step prune` for the local/upstream-diverged case (#2507, #2513, #2515). - **Faster shell-command dispatch** (~10ms per invocation, 1.49× on trivial aliases) via event-driven signal forwarding (#2537, #2538), plus parallel config load (#2543) and merged cold-start prewarm rev-parse (#2541). - **`wt switch <number>` suggests `pr:N` / `mr:N`** instead of just `--create` (#2516). - **Library API breaking changes**: `RefSnapshot` cutover (#2528, #2530) and the `for-each` direct-exec change (#2465). Full list in `CHANGELOG.md`. See `CHANGELOG.md` for the complete entry. > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cmd::stream'sforward_signals=truepath was running atry_wait+thread::sleep(10ms)+signals.pending()loop, imposing a ~13ms wall floor on every alias and hook subprocess dispatch — ~70% ofexecute_shell_commandtime for short aliases.Replace the loop with an event-driven shape: a listener thread blocks on
Signals::forever()and forwards SIGINT/SIGTERM to the child; the main thread blocks onchild.wait(). After wait returns,handle.close()unblocks the listener and wejoin()it (always, even on wait error — no thread leak).First-signal-only semantics preserved via an
Arc<AtomicI32>sentinel (0 = none, since POSIX signals start at 1) withcompare_exchange. Memory ordering isRelaxedsinceJoinHandle::joinprovides the happens-before edge. Re-press escalation (SIGINT → SIGTERM → SIGKILL insideforward_signal_with_escalation) is unchanged, and the shared-pgroup branch keeps its tty-restore rationale.Second commit consolidates
child.wait()and itsmap_errso both forwarding and non-forwarding paths share one wait + one error-mapping line, and Windows takes the same line as Unix.Empirical:
wt step <trivial-alias>30.4ms → 20.4ms via hyperfine (1.49× faster).