Repository navigation
perf: shave shape-independent per-command floor edges (#682) - #2160
Merged
Merged
Conversation
Three bounded, behavior-neutral slices off the per-command boundary, from a two-round RUBASH_EXEC_PROFILE attribution pass (flat 50k `:`, release): dispatch 2.44us (of which matcmd 1.24, expand 0.23), chain 0.86, jobs 0.66, linecmd 0.44 per command. The funnel floor itself is structural (matches the #989 ledger); these remove the boundary's avoidable fixed costs: 1. stamped-by-caller line stamp (ast_exec.rs, command_execute.rs): the execute_ast loop stamped __RUBASH_CURRENT_LINE/ __RUBASH_CMD_START_LINE and then execute_command re-stamped the identical pair from the same node + unchanged ambient. GNU stamps line_number ONCE per command (execute_cmd.c SET_LINE_NUMBER; :936 for cm_simple). New Executor::pre_stamped_line (Cell<bool>): armed by the loop immediately before its funnel call, consumed on entry (nested execute_command / pipeline stages / trap actions always stamp), suppressed when the funnel's trap-scope branch would stamp debug_trap_function_line, and suppressed when a DEBUG fire or debugger seam ran this iteration (run_debug_trap leaves the action's lines behind — trap_exec.rs:1325 — so the post-trap restamp is GNU's :936 behavior and must run). 2. run_pending_signal_traps (trap_exec.rs): Vec::with_capacity(4) heap-allocated at every command boundary with no delivery pending; Vec::new() defers the allocation to the first push (capacity is unobservable). 3. Windows lock-free self-queue gate (kill.rs): rubash#437's PENDING_ANY gate existed only on the unix drain (take_all_signals); the Windows take_pending_signals locked SELF_SIGNALS at every boundary unconditionally. Flag stores are now unconditional across platforms (queue_self_signal, requeue_pending_signals), and the Windows branch gates the mutex on the flag with the same acquire/release + drain-then-clear discipline; a delivery racing the clear is delivered, never dropped. Moves Windows closer to GNU's catch_flag memory check (trap.c:336) instead of a syscall. Measured (interleaved A/B, min-of-36, Xeon w5-3433, release): loop 1x `:` 6188->5808 ns/iter (-6.1%), loop 2x `:` 9202->8822 (-4.1%), `true` 6400->6132, flat 50k 10123->9885 ns/cmd (-2.4%); every case improved or tied; the funnel marginal floor itself (~3.0us) is unchanged and stands as the structural ledger. Battery A/B vs pristine 2503977: issue357/382/343_345/524/1473 delivery battery 34/34 green; executor_tests failure set on this branch (27) is a strict SUBSET of pristine's (28) — zero new failures; cli kill/signal/trap 20/21 with the 1 failure identical on pristine; issue1363 2, issue0085-family 3, issue1493 1 failures all reproduced identically on pristine (pre-existing, environment-bound); LINENO behavioral probe byte-identical on both binaries. Disclosure: cargo fmt cannot run on this host (rustfmt spawn fails with os error 206, the documented hook precedent), so committed with --no-verify; diff is hand-formatted to rustfmt style.
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.
References #682 (partial — floor attribution landed; the structural remainder stays on the issue as the ledger; keeping it open per the #989 disposition).
Three bounded, behavior-neutral slices off the per-command boundary, from a two-round
RUBASH_EXEC_PROFILEattribution pass (flat 50k:, release): dispatch 2.44us (matcmd 1.24, expand 0.23, …), chain 0.86, jobs 0.66, linecmd 0.44 per command. The funnel floor itself is structural (matches the #989 ledger); these remove the boundary's avoidable fixed costs.Changes
ast_exec.rs,command_execute.rs,mod.rs,init.rs,command_substitution.rs): the execute_ast loop stamped__RUBASH_CURRENT_LINE/__RUBASH_CMD_START_LINEand thenexecute_commandre-stamped the identical pair from the same node + unchanged ambient. GNU stampsline_numberONCE per command (execute_cmd.cSET_LINE_NUMBER; :936 forcm_simple). NewExecutor::pre_stamped_line: Cell<bool>: armed by the loop immediately before its funnel call, consumed on entry (nested execute_command / pipeline stages / trap actions always stamp), suppressed when the funnel's trap-scope branch would stampdebug_trap_function_line, and suppressed when a DEBUG fire / debugger seam ran this iteration (run_debug_trapleaves the action's lines behind, so the post-trap restamp is GNU's :936 behavior and must run).trap_exec.rs):Vec::with_capacity(4)→Vec::new()inrun_pending_signal_traps— one malloc/free per command boundary removed; capacity unobservable.kill.rs): rubash#437'sPENDING_ANYgate existed only on the unix drain (take_all_signals); the Windowstake_pending_signalslockedSELF_SIGNALSat every boundary unconditionally. Flag stores are now unconditional across platforms (queue_self_signal,requeue_pending_signals), and the Windows branch gates the mutex on the flag with the same acquire/release + drain-then-clear discipline; a delivery racing the clear is delivered, never dropped. GNU basis:trap.c:336catch_flagis a memory check, not a lock/syscall.Measured (interleaved A/B, min-of-36, Xeon w5-3433, release, per command /50000)
::trueif :; then :; fi: >/dev/null:(the floor)Battery A/B vs pristine 2503977
$LINENO, assignments): byte-identical output on both binaries.Disclosure
cargo fmtcannot run on this host (rustfmt spawn fails with os error 206 — the documented hook precedent), so the commit was created with--no-verifyequivalence; the diff is hand-formatted to rustfmt style. (Also: this branch was published via the git-data API because the github.com HTTPS git endpoint was unreachable from this host; the tree sha7fdbe32cmatches the locally verified commit byte-for-byte.)