Repository navigation
perf(export): skip identity IFS-marking passes on quoteless words - #986
Merged
Merged
Conversation
`export BK_V$i=x` / `unset BK_V$i` words carry an unquoted `$i`, so they miss the literal fast paths (#956/#974) and every iteration runs the full mark_literal_ifs_chars + mark_quoted_ifs_from_raw pair (~8 allocs/word) to prove what is already true: with default whitespace-only IFS there is nothing to mark, and a quoteless raw records no quoted positions. GNU subst.c:11229 expand_word_internal always CTLESC-protects quoted source chars (subst.c:11639-11673; skipped by subst.c:3119 list_string); this skip only removes passes whose output is byte-identical to their input (whitelist admission, rubash#117 discipline: any doubt falls through to the full pipeline). ~3-4% body-time reduction on the export/unset 2k loop; zero behavior change (probes byte-identical to bash/pristine on default + custom-IFS + quoted shapes).
caomengxuan666
added a commit
that referenced
this pull request
Oct 22, 2026
…eave loop (#984/#986/#920 follow-up) The export/unset 2k interleave sat at ~2x vs GNU bash after the short-circuit (#984), IFS fast lane (#986) and single-probe (#920) passes. Release best-of-7 curves on this host (Termux aarch64): interleave 2k/4k/8k: 1.88x / 2.18x / 2.25x (was 1.9x / 2.7x / 2.9x) export-only 2k/4k/8k: 1.64x / 1.74x / 1.98x (was 1.45x / 2.3x / 2.4x) unset-only 2k/4k/8k: 1.71x / 2.00x / 2.02x (was 2.2x / 2.4x / 2.4x) same-machine A/B vs pristine: -16% (2k) / -22% (4k) / -24% (8k) 30-sample gdb profile of the loop body (release) pointed at the same shape everywhere: no single hot function, but ~15 redundant per-word pre-scans plus 2-4 small allocs per word in the expand tail, the BASH_COMMAND re-render, the pathname probe, and the declare rewrite. Each cut below is a whitelist/dedup with a provable identity (any doubt falls through to the slow path, rubash#117): - pathname_expand_word: byte gate (no `*?[]()+@!` -> NoMatch), skips seven option lookups + the quote-aware scan per plain word. - set_current_command: raw-join fast render (raw == word for every word, no `$(`/backtick, no assignments/redirects) -> words.join(" "), pinned fast == slow by unit test. - scan_substitution_spans: early empty-Vec without `$(`/backtick (only two push sites, both need a trigger byte). - raw_word_contains_process_substitution (x2 sites) + raw_word_has_unquoted_process_substitution: early false without `<(`/`>(`. - expand_simple_substitution_fragments call site: skip without `$(`/backtick (splitter provably returns None). - strip_ifs_protection_markers + decode_command_substitution_payload: Cow forms on the hot tail (borrow when unmarked). - splits_unquoted_expanded_word: default-IFS no-split pre-check (no IFS whitespace/marker bytes -> false, skips guard-convert alloc + split materialization). - rewrite_declare_operand_subscripts: whole-list fast path for plain operands (no dash args, no `[`, no `(`, no compound marker). - export mirror loop: borrow instead of clone; unset names/variable_args borrowed; unset_name borrow; raw_word_is_fully_single_quoted first-byte gate. Probes byte-identical to bash and to the pristine binary (glob, custom-IFS splits, ANSI-C guards, nullglob/failglob, declare -a/-A/ -i/subscript/append, unset -v/-f/readonly/function, BASH_COMMAND, process substitution, backtick/nested $()). lib 689 green; executor_tests failure set identical to pristine (13 pre-existing Termux-env failures); cli_tests 10 failures are missing-submodule fixtures + dirty-tree version hash (both pre-date this change and clear on a clean tree). Next Top (post-cut 15-sample): allocator frames dominate (scudo ~60% of innermost hits) — per-word String/Vec churn remains the frontier; bind_underscore / tempenv restore are at GNU parity.
This was referenced Oct 22, 2026
caomengxuan666
added a commit
that referenced
this pull request
Oct 22, 2026
…eave loop (#984/#986/#920 follow-up) 13 files, all whitelist/alloc-elision, doubt falls through: no-pattern gates for glob/procsub/substitution scans, Cow for IFS/payload decodes, raw-join BASH_COMMAND render with fast==slow contract test, export mirror borrow, unset borrowed names/flags, first-byte gate for single-quote tiling, plain-operand declare rewrite. Interleave 2k: 60ms->51ms vs bash 27-30ms (~2.2x->~1.9x, ~15%). Note: the splits_unquoted_expanded_word no-IFS short-circuit was reverted before merge — Windows-only upstream-suite (exp) snapshot divergence, root cause not yet isolated; Linux runs were byte-identical. Tracked separately.
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.
export/unset words carrying unquoted $ (BK_V$i=x) run full mark_literal_ifs_chars + mark_quoted_ifs_from_raw per word (~8 allocs). Two independent identities, each unit-pinned: default blank-only IFS can't insert marks; quote-free raws can't record quoted positions. GNU subst.c:11229/11639-11673. Tests: new admission unit test + lib/fuzz/cli green; byte-identical vs bash on default/custom-IFS/quoted shapes. export/unset 2k: 2.14x->1.97x (~3-4%).