Skip to content

perf(export/unset): single-probe mirror, gated env fallback, bulk unmark (#916) - #920

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/export-unset-cost
Oct 20, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/export-unset-cost

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Follow-up to #917/#918. export: 3x is_marked -> single attr_of probe, miss skips mirror instead of set_scalar-creating; drop 6 env::var fallbacks (locked O(n) scan per fresh op, also resurrected stale values after unset - now matches bash). unset: 10x unmark_name -> single attrs.remove. Tests: lib 636 + cli green (9 examples fails are missing third_party/bash submodule, identical on baseline); executor 1540 pass, 12 fails identical to pristine origin/master (Android-env). Bench (debug build, interleaved 2k): within noise, needs release re-measure.

…ark (#916)

- export/readonly sync_setattr_typed_assignments: one attr_of probe for
  array/assoc/nameref; skip mirror when no typed cell (expansion falls
  back to env_vars), no more set_scalar creation on fresh names.
- setattr apply (export + readonly): fresh names short-circuit on
  contains_key; drop env::var fallback (locked O(n) scan per fresh op,
  resurrected stale process values after unset - bash leaves them empty,
  verified by FOO_INHERIT对照实验).
- unset: ten unmark_name calls merged into single
  VarTable::remove_unset_marks (one attrs.remove + ASSOC_128 string drop).
@caomengxuan666
caomengxuan666 merged commit 9d88562 into master Oct 20, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/export-unset-cost branch October 20, 2026 15:34
caomengxuan666 added a commit that referenced this pull request Oct 21, 2026
…est platform status, current architecture (#982)

* docs(readme): overhaul — Performance section with pinned numbers, honest platform status, current architecture

- New Performance section, every number pinned to its measuring issue/PR:
  - Android-matrix interpreter triage closed with numbers (#607/#608/#609
    -> #665/#671/#679, #666, #672/#678; net ~1.06x GNU scalar assign)
  - array store O(n^2)->O(1) amortized (#618/#616: assoc 445x->9.9x,
    indexed 736x->3.8x vs GNU at 5000 keys; docs/performance.md ledger)
  - literal fast-path wave with measured deltas: #967 (177->155 ms),
    #966 (1.41x->1.10x), #974 (~11%), #959 (3.65x->3.16x), #958 (-10%),
    #956/#973/#954 family
  - export/unset economics: #916 measured costs stated, write lane landed
    (#917/#918/#920, #943 correctness rework), issue open on residual
  - Windows process economics: #913 one hidden console per session
    (~22 ms/spawn -> <=1 per session; tests/console_window_gate.rs),
    #884 tput inline arm (1165 ms -> 47 ms, 269-row oracle matrix),
    WinuxCmd#1269 twin (~17 ms -> ~0.4 ms in-process), #800 face B open
- Platform status made verifiable: Linux CI lanes + upstream-corpus replay
  job named; 19/24 Linux pass dated and cited (#500) instead of 'and
  climbing'; macOS now runs lib tests in CI, not just compiles
- Architecture tree updated to the real src/ layout (bin/expand/fd/jobs/
  shell added); builtin count 40+ -> 62 engine builtins per the
  test-guarded docs/builtins.md + hidden fast-path builtins
- Testing section: regression suite, console gate, corpus replay commands
- Compatibility baseline line updated to vendored Bash-5.3 patch 20
  (#957) with local+WSL 5.3.20 oracles (#978)
- zh README rewritten to full parity with EN (was still describing the
  pre-dialect path model, missing the identity section, claiming 5.3.0)
- Last-updated stamp refreshed

* docs(readme): date the Linux corpus pass from the archive — 2026-09-27 wt4/linuxrun, 17/24 per its own ledger

The "(2026-09-26, #500)" tag was wrong on both counts: 09-26 is the
earlier "not-yet-usable" judgment (first smoke 8/10, gap-ledger C4) that
the 2026-09-27 wt4/linuxrun lane explicitly declared obsolete, and #500
only carried the figure forward — it is not the measuring record. No
archived record supports 19/24: the lane's own corpus-slice table
(docs/LINUX-RUN-STATUS.md, deleted in #478, archived in #477 section 4
and #581) tallies 17 suites at 0 diff + trap/redir/glob/extglob/new-exp/
read/ifs-posix with diffs = 17/24. README now reads "17/24 byte-identical
(2026-09-27 wt4/linuxrun lane, ledger archived in #477/#581)" in both
the platform-status paragraph and the compatibility table, EN + zh-CN
at parity. Addresses review comment 6319063190 on #982.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant