Repository navigation
perf(signal): sample the signal-hint event every 8th command boundary (#682) - #989
Merged
Merged
Conversation
…#682) take_pending_signals runs WaitForSingleObject(,0) on the signal-hint event at EVERY command boundary — a real syscall (~0.5-0.7us measured) inside the shape-independent per-command floor. The auto-reset event latches a sender's pulse until a wait consumes it, so sampling it every 8th poll loses no delivery; worst-case added latency ~7 boundaries (~25us) sits far inside the 1024-tick filesystem fallback eventless senders already tolerate. GNU's catch_flag is a memory flag set by the kernel handler (trap.c:336 run_pending_traps, execute_cmd.c:643 call site) — zero-cost — so the per-command poll has no upstream analog to amortize against. Measured (release, rotating interleaved, min-of-11, D-series host): marginal `:`/`true` in a loop body 3.47/3.63us -> ~3.08us per command (-0.4..-0.7us/cmd); flat-colon-80000 998.9 -> 941.1ms; jobs profile bucket 298 -> 99ms over 420k commands. Delivery batteries green: issue357 mailbox split (6/6 incl. busy-loop TERM trap), issue382 (6/6), issue343_345 (9/9), issue524 (12/12), cli_tests kill|signal|trap (21/21). issue526's two -1-signaled asserts fail identically on baseline (Windows exit-code shape, pre-existing). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
:/true(marginal loop-body cost), essentially unchanged from the ~2.8µs recorded during [perf][P2] Split #619 (1/4): if/case compound-dispatch residual after #624 (~2.5–2.8×, +5.2/+3.7µs per exec) #661.RUBASH_EXEC_PROFILEattribution: dispatch ~2.3µs, ast-side jobs+chain ~1.5-2.4µs, linecmd ~0.6µs.take_pending_signalsrunsWaitForSingleObject(,0)on the signal-hint event at every command boundary — a real syscall (~0.5-0.7µs measured here) with no upstream analog (GNU'scatch_flagis a memory flag set by the kernel handler, trap.c:336run_pending_traps).kill $$) bypass the event entirely;take_pending_signals_now(wait-poll,THIS_SHchild boundary) stays unthrottled.Measured (release, rotating interleaved ABBA, min-of-9/11)
:in loop bodyOut of scope (issue ledger, unchanged)
if :;then :;fi~11.7µs/stmt (3 traversals ≈ 3.9µs/slot)if … >/dev/null~83.5µs/stmt (+72µs vs plainif): the compound-redirect model splices>>into every leaf, each leaf re-opens the target — fixing that is redirect-architecture work, not a P3 sliceTest plan
-1-signaled asserts fail identically on baseline (Windows has no signaled ExitStatus; pre-existing platform assertion)Generated with Devin