Repository navigation
perf(executor): batch mapfile input split + store (#663) - #670
Merged
Merged
Conversation
mapfile -t a < 100k lines: 243ms vs GNU 52ms (~4.7x); split was only ~10% (18ms), the caller-side intermediate BTreeMap build+drop was 141ms. split_mapfile_input decodes once, splits raw bytes as ranges, strips -t in the byte domain, encodes each segment once. The builtin fast path (no -O/-C) pushes the batch straight into the dense bulk store, skipping the intermediate index map. Attr checks and epilogue unchanged; -O/-C paths untouched. 100k bench 243ms -> 174ms (4.7x -> 3.3x vs GNU). Matrix 25/26 vs GNU (1 pre-existing NUL divergence, identical old/new). GNU: builtins/mapfile.def:177-209 zgetline + bind_array_element.
This was referenced Oct 16, 2026
This was referenced Oct 28, 2026
Closed
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): batch mapfile input split + store (#663)
What
mapfile -t a < lines.txt(100k lines): 243ms vs GNU 52ms (~4.7x).Instrumentation showed split = 18ms, store = 141ms of the gap — the
caller's intermediate
BTreeMapbuild plus its drop dominated, not justsplit_mapfile_input(~10%).Fix
split_mapfile_input: decode once, split raw bytes as ranges (noper-byte push buffer), strip
-tin the byte domain, encode eachsegment exactly once. Capped reserve.
mapfile_builtin: fast path whenorigin.is_none() && callback.is_none()— batch pushes straight into the dense bulk store(
replace_typed_indexed_array+store_indexed_array), skipping theintermediate index map. All attribute checks (readonly/nameref/
identifier) and the epilogue stay upstream/identical;
-O/-Cpathsuntouched.
GNU owners:
builtins/mapfile.def:177-209zgetline loop +bind_array_element.Measured (release, 3 mapfiles/process, per-call)
Remaining ~3.3x is store-side (per-element quote allocs, typed-cell
double-keep, whole-input encode→decode roundtrip) — each its own
follow-up PR.
Verification
executor_tests mapfile24 passed;readarray11 passed;issue3245/6 (the 1 failure writes/tmp, unwritable here —fails identically on base).
-t/-O/-d/-n/-s/-c/-C, NUL, missingnewline, CRLF,
\xff, UTF-8, procsub, pipe, callbacks): 25/26 vs GNU;the 1 divergence (NUL-in-data truncation) is pre-existing and
byte-identical between old and new split.
(NEW=0/DISAPPEARED=0). Test-level 4 NEWs all pass in isolation on
branch (3
part_080coproc = known flake family;pipeline_allows_newline_after_operatorgreen on both legs) —no regression.
6295367, only rubash[patch]switched): failure sets byte-identical (49=49).