Repository navigation
WIP: perf residual batch — #1955 feeder scans, #2004 assoc length leg, #1994 compgen PATH cache, #1956 verify candidates - #2060
Merged
caomengxuan666 merged 4 commits intoOct 29, 2026
Conversation
The grouped-reader feeder re-ran three whole-token-list scans on every appended physical line while a brace group stayed open, so a group of N one-line function definitions cost Theta(N^2) token visits (measured on master 16a42d7, Linux same-machine: defs-wrap -n grew x4.0 per doubling, 8000 defs = 2.77s vs GNU 0.026s; per-pass instrumentation counted 504MB of accumulated line handed to the tokenizer and 160M token visits). GNU reads a script exactly once (parse.y:3557 read_token streams); the three scans now keep resumable state over the append-only token list, following the checkpoint discipline the param/comsub/quotes scans already use: - resume gate: the innermost bare `{` of the checkpoint list is the fold-maintained mirror (fold_pass_tokens tracks the last bare `{` over the delta on tail-resumed passes and rebuilds it on refolds), snapshotted next to the boundary checkpoint when it is stored. The per-line rposition over all checkpoint tokens is gone. - heredoc presence: a windows(2) watermark (prefix answer + straddle pair + delta pairs) answers the join decision; the delimiter structs are still computed by one full heredoc_delimiters call on the commit path, against the final source text their contexts read. - `set -o posix` flip scan: LinePosixScan folds the appended delta, re-probing a `set` word whose argument list was cut off by the previous pass's end (Undecided probe outcome), so the running result equals the from-scratch scan on every pass. After (same load window, min-of-5, Linux): defs-wrap-8000 -n 3.25s -> 0.53s, growth per doubling ~x2-3 (near-linear); 8/8 GNU differential shapes byte-identical (defs exec, heredocs in groups incl. split operator, `}` in strings/comments, split `set -o` lines, posix mid-unit deferral, nested case/procsub/dparen). Co-Authored-By: Muse Spark <[email protected]>
…h#2004) Re-measurement on master 16a42d7 (Linux same-machine, interleaved) overturned the filed plain-miss magnitude: the F3 fix (rubash#1919) already settled plain ${m[key]} reads — miss at n=10000 is 18.3us vs GNU 13.4us (1.36x), flat in n. The live residual is the LENGTH leg: ${#m[key]} re-derived the element from the serialized storage on every call (whole-storage clone + content-hash + linear scan), hit AND miss: at n=10000, 479us (hit) / 1115us (miss) per call vs GNU 16us / 4us, growing x5-11 per 10x of table size. assoc_element_value_settled answers by-key reads for callers that already hold the evaluated key, under the typed fetch's own admission (nameref resolved, assoc mark on the storage name, rubash#1510 freshness gate, structured assoc cell present); the cell — a complete mirror of the render (rubash#616 Phase 1a) — then settles hit and miss authoritatively. Both length legs (direct, and the nameref-cell leg) consult it after their single subscript evaluation and after the empty-key `bad array subscript` error (subst.c:7545-7552); unsettled reads keep the storage leg unchanged. GNU: assoc.c assoc_reference is one hash lookup, hit or miss. Pins: 4 new behavior pins in perf_assoc_element_miss_regressions.rs (length hit/miss/empty-hit, subscript evaluated once on hit and miss, nameref leg + multibyte length, empty-key error), expectations verified byte-for-byte against GNU bash 5.3.20. Co-Authored-By: Muse Spark <[email protected]>
…nt (rubash#1994) path_command_completion_candidates re-walked every PATH directory and stat'ed every entry on every compspec evaluation / compgen -c. Measured on master 16a42d7 (Linux same-machine, fat PATH of ~2900 fake executables + system PATH, 3247 unique candidates): 95ms per in-shell compgen -c call, paid again on each of 200 consecutive calls (GNU re-walks too and pays 302ms — rubash keeps the lead and drops the repeat cost). The raw walk result (duplicates across directories preserved, rubash#1089; callers merge/sort/dedup) is now cached process-wide under command_lookup_fingerprint — the executor command-lookup cache's key (PATH/PWD/PATHEXT + every env key path translation consults), now pub(crate) for this reuse. A PATH bind or cd moves the fingerprint and the next evaluation re-walks. Accepted staleness, mirroring the niubash host-side cache: filesystem-only changes under an unchanged fingerprint are observed at the next fingerprint change. Pin: issue1994_compgen_path_cache_regressions.rs — repeated calls identical, dup/exec/symlink discipline, refresh on PATH change; expectations verified against GNU bash 5.3.20. Co-Authored-By: Muse Spark <[email protected]>
…ash#1956) The debug-only command-boundary verifier iterated the whole variable store and paid a per-name freshness check for every variable — a group of N scalar assignments cost Theta(N^2) (filed: 8000 distinct assignments 19.1s in a debug build; reproduced on master 16a42d7, Linux same-machine: 39.1s under load). The non-forced pass now visits only stale ∪ cell-candidates: a celled name that is not fresh is either stale (every mirror-epoch bump is paired with the stale mark) or untracked, and every untracked celled name sits in the store's new cell registry — each VariableStore mutation that can create/replace/destroy a cell registers it (array-directed setters unconditionally, wholesale `set` by outcome, `get_mut` conservatively), and the verifier drops names it observes cell-less. Per-name treatment (freshness skip, mirror-absent skip, full proof, track on proof) is the old loop's, factored into typed_cell_coherent; the forced fuzz variant still walks the whole store. The registry is #[cfg(debug_assertions)] state, like the verifier itself — release builds pay nothing. Debug, same machine, min-of-3: assign-wrap 1000/2000/4000/8000 = 636/4147/9430/39094ms -> 276/1858/4796/12050ms. The shape keeps a second, release-visible superlinear term outside the verifier (assign-wrap-8000 release: 1.41s) — separate mechanism, flagged in the cluster report. typed_cell_coherence_fuzz + issue1719 sync regressions green. Co-Authored-By: Muse Spark <[email protected]>
caomengxuan666
marked this pull request as ready for review
October 29, 2026 05:47
This was referenced Oct 29, 2026
caomengxuan666
deleted the
perf/residual-batch-2004-2005-1994-1955-1956
branch
October 30, 2026 01:42
caomengxuan666
added a commit
that referenced
this pull request
Oct 30, 2026
- PR #2060 has merged; drop the 'still draft, numbers pending' wording - page-level platform caliber: all figures are same-machine comparisons and say nothing about Windows magnitudes; the 2026-10-28 and residual rounds are explicitly this Linux VM
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 residual cluster (4 fix commits + 1 evidence-only adjudication). All numbers release build, Linux same-machine interleaved sampling (「Linux 同机」), taken against master
16a42d78; full tables + root causes in the cluster REPORT (workspacefix-perf-residual/REPORT.md).#1955 — grouped-feeder per-pass scans (FIXED, commit 9848fb1)
Feeder re-ran three Θ(accumulated-tokens) scans per appended line inside an open brace group. Instrumentation on master: 504MB of accumulated line handed to the tokenizer, 160M token visits for defs-wrap-8000
-n; attribution: resume-gaterposition14.1s,heredoc_delimiters9.0s,line_posix_mode_change3.2s (debug-run totals). All three are now resumable/watermarked in the checkpoint discipline the param/comsub scans already use; delimiter structs still computed once on the commit path.-n(paired same-window, min-of-5): 3.248s → 0.533s; growth per doubling ≈×4.0 → ≈×2–3 (near-linear).set -olines, heredoc operator straddle, posix mid-unit deferral).#2004 — combined-table miss (PARTLY OVERTURNED + length leg FIXED, commit b5bcf59)
Re-measurement overturns the filed plain-miss magnitude on current master: the F3 fix (#1919) already settled plain
${m[key]}(miss@10000 = 18.3µs vs GNU 13.4µs, flat). The live residual was the LENGTH leg:${#m[key]}re-derived from serialized storage per call, hit AND miss (miss@10000 1115µs, growth ×5–11). Newassoc_element_value_settledanswers by-key reads under the typed fetch's own admission/freshness gate; both length legs (direct + nameref-cell) consult it after their single subscript evaluation; the empty-key error (subst.c:7545-7552) still fires first.#2005 — while-read 418µs/line (OVERTURNED as filed — NO code change)
On current master the shape decomposes to the general while+arith floor tax (already tracked by #682), not a read/procsub defect: while-read from procsub/file/pipe = 172/139/129µs/line under load vs an arith-only loop at 76µs/iter and read adding only ~21µs/iter; cat-drain of the same procsub = 1.3µs/line (the #1952 streaming fix holds). The filed 418µs/68x was measured on a268db2, pre-#1952-merge. Full evidence table in the cluster report for adjudication. (Adjacent: #1951's 0.29ms/line procsub claim is the same stale shape.)
#1994 — compspec PATH walk (FIXED, commit e8b4f07)
path_command_completion_candidatesre-walked + stat'ed the whole PATH universe per evaluation. The raw walk (duplicates preserved, #1089) is now memoized process-wide undercommand_lookup_fingerprint(PATH/PWD/PATHEXT + path-translation keys); a PATH bind or cd re-walks. Accepted staleness mirrors the niubash host-side cache.compgen -c(8.1×; GNU 277.6ms). Candidate sets identical.#1956 — debug-only verify walks whole variable table (FIXED, commit 236664a)
The boundary verifier iterated all variables per command. It now visits only stale ∪ cell-candidates (a new debug-only registry in VariableStore, fed by every cell-creating/replacing/destroying mutation;
get_mutregisters conservatively); per-name treatment unchanged, forced fuzz variant still walks everything. Release builds compile the registry out.Gates (final tree vs master baseline, same discipline)
ownership_unary_operators_check_existing_file).golden_nvm_loadis a best-of-5 timing gate that failed at load ~13.6 (10.20s vs 9.09s budget) and PASSES on re-run;issue1776_time_children_cpufails identically on the pristine baseline tree (same assertion at regression.rs:3396).cargo check --lib --binswith-D warnings: clean. Per-file rustfmt applied; CR count 0.Refs #2004, #2005, #1994, #1955, #1956 — closure adjudication left to the main session (#2005 is evidence-only; #2004's plain-path half was already fixed by #1919).