Repository navigation
perf(executor): if-condition dispatch residual (#661) - #673
Merged
Merged
Conversation
Per-execute_command if/case dispatch: alias-scan ran expand_aliases (Vec clone + per-word probes) per body command; every :/true condition paid inside_compound_condition save/restore + errexit-suppression wrap. Empty alias table (or alias-streamed words): raw first word IS the expanded first word, checked directly. Bare :/true with all channels empty runs unmarked; shadowed words (function/alias) fall through to keep slow-path errexit suppression (review-caught: true() returning nonzero under set -e). 50-cmd else body -26%; guards 55/55 + 29/30 (pre-existing #17 only); 4 shadow regression tests. GNU: execute_cmd.c:3862 execute_if_command, :5200 pointer walk.
This was referenced Oct 16, 2026
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.
perf(executor): if-condition dispatch residual (#661)
What
Per-
execute_commandif/case dispatch residual (~2.5x): the alias-scanran
expand_aliases()(awords.to_vec()+ per-word table probes) perbody command, and every
:/truecondition paidinside_compound_conditionsave/restore + `with_errexit_suppressedwrapping.
Fix (whitelist-only, two slices)
raw first word IS the expanded first word — check it directly.
Mirrors
expand_aliases' own early-outs; a stateful cross-exec cachewas rejected (aliases/shopt mutate at runtime; needs
generation-counted invalidation).
:/truewith everyassignment/redirect/substitution/pipe/wrapper channel empty runs
unmarked. Review-caught soundness gate: a shadowing function/alias
makes the word execute user code that can fail (a
true()returningnonzero under
set -emust keep the slow path's suppression), soshadowed words fall through.
GNU owners:
execute_cmd.c:3862 execute_if_command,:5200pointer walk,
parse.yalias no-op on empty table.Measured (release, N=200k, order-rotated min-of-5)
#607 already took the big chunk. Toggles alone are below the noise
floor; the alias slice wins where it fires: 50-cmd never-executed else
body with empty table, 8.916s → 6.636s (−26%, −0.22µs/scanned command);
non-empty-table probe at parity (correct slow path).
Residuals for follow-ups (measured, out of scope): shape-independent
per-
execute_commandcost ~2.8µs;set_current_commandrender scaling;if…fi >/dev/nullredirect path +52µs.Verification
ifcase_diff.sh55/55,casearm_diff.sh29/30 (only pre-existingFix Winuxsh framework glob loading and hook dispatch #17) vs GNU; alias+if differentials byte-identical.
issue661_if_condition_shadow_regressions(4 tests, incl. thereview-caught
true()/alias +set -edivergence).cargo test --lib585/585; focused case/alias/trap/errexit suitesgreen.
exoneration (the
cli_testsNEW was 9examplestests failing on aworktree-empty
third_party/bashsubmodule — 9/9 green aftergit submodule update --init). Test-level 1 DISAPPEARED(
part_080coproc, passes in isolation on branch). No regression.6295367, only rubash[patch]switched): 50 vs 49, the single extra
(
epochrealtime_beats_external_date_for_timing) is the known loadflake — green in isolation on branch.