Repository navigation
perf(executor): skip the mapfile whole-input encode roundtrip (#680) - #688
Merged
Merged
Conversation
split_mapfile_input encoded the whole input to raw bytes then re-encoded every segment, even for ASCII input where both directions are identity. Admission: ASCII-only, no carrier bytes, ASCII non-NUL delim; admitted inputs split directly (one alloc/segment). seq1M 0.686s -> 0.645s (-6%). 4 contract tests; mapfile 24/24. GNU: builtins/mapfile.def:177-209.
caomengxuan666
added a commit
that referenced
this pull request
Oct 17, 2026
caomengxuan666
added a commit
that referenced
this pull request
Oct 18, 2026
…itative carrier set (#680 followup) Fuses the two #680 slice-2 variants that were floating apart: master's merged fast path (31d1f0f, #688) required the WHOLE input to be ASCII, so any multi-byte payload (CJK, accented text) fell back to the whole-input decode + per-segment encode roundtrip, while rescue/stash-perf-680 (a stash rescue of the same slice) already rode UTF-8 but gated on a hand-rolled C0 whitelist that over-excluded 0x0B/0x0E/0x0F/0x10/0x12 — bytes outside the authoritative carrier set that encode to themselves — and coupled the gate to markers.rs by hand. The fused gate is `is_assignment_carrier_byte` (lexer/ansi.rs — the authoritative set {0x0c, CTLESC 0x11, 0x13, 0x14..=0x1f} shared with bytes_to_assignment_shell_text) plus the 0xEE lead of the U+E000..U+EFFF registry-marker zone, on both the delimiter and every input byte. A future carrier registration automatically tightens the gate instead of relying on a synced copy. Correctness of the UTF-8 coverage rests on the Rust String invariant (input is always valid UTF-8, so an ASCII delimiter can never cut a multi-byte sequence and every segment is either ASCII or carries complete sequences that re-encode to themselves); non-carrier C0 bytes (tab/LF/CR/VT) and DEL encode to themselves and stay on the fast path; NUL keeps the decode path by contract (delim != 0, rubash#117). Oracle-verified against the locally built bash-5.3.0(1)-release: mapfile -t with UTF-8 payloads, carrier bytes (0x0c/0x11) and a registry-marker stream all render byte-identically to GNU, including the -d delimiter variants. Two new pins in issue680_mapfile_quote_fastpath_regressions.rs cover the UTF-8 ride and the carrier/marker gate; the issue680 pair, marker_leak_golden and the lib suite stay green. rescue/stash-perf-680-mapfile-input-side is superseded by this and can be deleted.
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): skip the mapfile whole-input encode roundtrip (#680)
What
Second slice of the mapfile store-side residual:
split_mapfile_inputran the whole input through
shell_text_to_raw_bytesand thenre-encoded every segment via
bytes_to_shell_text, even for plainASCII input where both directions are the identity.
Fix
Admission predicate (single byte pass): ASCII-only input, no carrier
bytes (
0x0c/0x11/0x13/0x14..=0x1f— the only bytes that makebytes_to_shell_textdiffer from its input), ASCII non-NULdelimiter. Admitted inputs split the text directly (one alloc per
segment); anything else keeps the decode path (rubash#117). NUL-delim
stays on the decode path by contract.
GNU:
builtins/mapfile.def:177-209(split raw bytes, no re-encode).Measured (release, same-tree fresh binaries)
of the original 243ms per the [perf][P2] Split #619 (3/4): mapfile input split + encode path (store half already fixed by #652) #663 split).
Small but sound; same bar as #671/#679.
Verification
issue680_mapfile_encoded_split_regressions(4 tests:plain, custom delim ±
-t, NUL-delim decode path, carrier-bytefallthrough pinned against GNU output).
mapfile_diff.sh30/30.except the new regression file itself (4/4). Test-level 3 NEW, all in
the known-nondeterministic
part_080coproc family (all pass inisolation on branch). No regression.
6295367, only rubash[patch]switched): failure sets byte-identical (8=8). Note: the product
failure set shrank 49→8 since the [perf][P2] Split #619 (2/4): case per-arm pattern re-expansion constant (~1.27 vs 0.51µs/arm) #662 era — the engine campaign
fixed 41 niubash product tests as a side effect (the 8 are a strict
subset of the old 49).