Skip to content

perf(executor): quote fast path for plain array values (#680) - #686

Merged
caomengxuan666 merged 1 commit into
masterfrom
perf/issue680-mapfile-store
Oct 16, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
perf/issue680-mapfile-store

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

perf(executor): quote fast path for plain array values (#680)

What

Slice of the mapfile store-side residual: quote_array_value ran 2
marker replaces + a dequote scan + ansic_shouldquote (with its own
encode) + 4 chained replaces per element — even for plain seq
digits that need no escaping.

Fix

quote_array_value_is_plain whitelist (non-empty printable ASCII
outside the sh_double_quote escape set): renders "value" in a
single allocation. Markers/CTLESC/non-ASCII fail the byte test by
construction. GNU: array.c:948-989 (ansic_shouldquote ? ansic_quote : sh_double_quote), strtrans.c:341,
shquote.c:134 over slashify_in_quotes (syntax.h:26).

Measured (release, mapfile -t a < seq100k.txt 589KB)

baseline median ~181ms → ~99ms (≈1.8x end-to-end); GNU ref ~66–152
(noisy device, min-clusters).

Verification

  • New issue680_mapfile_quote_fastpath_regressions (3 tests).
  • array_store_parity 2/2; quote suites 83/83; mapfile 24/24.
  • 26-case byte-parity matrix vs GNU: 25/26 (sole NUL-truncation
    mismatch is the documented pre-existing divergence; NUL is outside
    the whitelist).
  • Full serial failure-set gate vs master: per-target results match
    except the new regression file itself (3/3). Test-level 4 NEW, all in
    the known-nondeterministic part_080 coproc family (all pass in
    isolation on branch). No regression.
  • niubash product A/B (niubash pinned 6295367, only rubash [patch]
    switched): 50 vs 49, the single extra
    (epochrealtime_beats_external_date_for_timing) is the known load
    flake — green in isolation on branch, both directions on master.

quote_array_value ran 2 marker replaces + dequote scan +
ansic_shouldquote + 4 chained replaces per element, even for plain
digits. Whitelist (printable ASCII outside sh_double_quote escapes)
renders "value" in one alloc; markers/CTLESC/non-ASCII fall through.

seq100k mapfile ~181ms -> ~99ms (~1.8x). Matrix 25/26 (pre-existing
NUL divergence only).

GNU: array.c:948-989, strtrans.c:341, shquote.c:134, syntax.h:26.
@caomengxuan666
caomengxuan666 merged commit 5661e01 into master Oct 16, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the perf/issue680-mapfile-store branch October 16, 2026 18:40
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