Skip to content

[perf] Incremental reader deep system: batch tokenizer re-lexes O(buffer) per appended line (nvm -n 720x / OpenSSH -n timeout residual) #281

Closed

Description

@caomengxuan666

Tracked umbrella for the deep system deferred by perf/perf2 lanes (#241 sibling): per-pass re-tokenization of the accumulating logical line. Includes the captain-owned continuation.rs cost centers (has_unclosed_quotes copies the remaining input per pending ${ — 1644x/4.5s on nvm; slice-passing fix shape documented in perf2's report) and the walker ${-arm recursion (2.5M allocs, needs SubXpassFrame memo semantics).

Activity

  1. added a commit that references this issue on Sep 28, 2026
  2. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    perf3 round (wt7/perf3 @ c17b6cea) landed the two non-captain umbrella items + the brace_scan twin of the continuation.rs cost:

    • Walker ${-arm recursion: expand_braced_parameter_fragment_in_word resolves =-free, non-funsub, whole-word fragments inline (GNU anchor subst.c:11229 expand_word_internal single pass → parameter_brace_expand subst.c:9777 inline). SubXpassFrame memo semantics: nested fragment entries land in the enclosing word's frame (site keys (ctx, frag-path, text); sibling fragments cannot false-hit). Probe 15 walker-guard cost 769→508ms, allocs 3.58M→3.04M.
    • Batch tokenizer complete-command-boundary checkpoint (LexerBoundaryState): a pass ending between tokens checkpoints tokens+lexer state; the next pass lexes only the appended tail (nvm -n tokenize 0.98s→0.5s; probe 17 39.2x→27.9x; probe 20 65.1x→54.0x; bash_completion -n canary 1443ms→750ms). Resume gated on the appended line carrying no } byte (prefix-open { groups fold exactly on the pass their } arrives); brace_scan_cache invalidation discipline + posix/extglob flips.
    • brace_scan.rs ${-arm zero-copy (has_unclosed_parameter_expansion, skip_braced_parameter_in_chars): the SAME per-${ copy of the entire remaining buffer as continuation.rs, fixed with the existing rubash#185 scan_braced_parameter_body_chars API (slice must INCLUDE the ${ opener).
    • continuation.rs (captain-exclusive, NOT touched): the proposed verbatim diff for its two ${-arm copies is recorded in docs/PERF-BASELINE.md (perf3 round). Temp-applied measurement: prescan 4540ms→27ms, per-line huq 5325ms→122ms → nvm -n 645x→137x, configure-head 383x→290x.

    Stays OPEN: the <60x nvm -n target needs the captain's continuation.rs fix (9.9s of nvm -n's 12.4s) AND a further ~1.6s parse/reader-phase reduction on top (GNU parses nvm.sh in 19ms). Full table + decomposition: docs/PERF-BASELINE.md, perf3 round.

  3. caomengxuan666 commented on Oct 4, 2026

    @caomengxuan666
    MemberAuthor

    wt70/lextok round landed (2e06da2 on master, one file src/lexer/mod.rs +39/-4, continuation.rs untouched):

    Landed: (1) backslash-continuation scan admission gate — ends_with_unquoted_backslash has exactly one true-exit requiring a trailing backslash; gating the call sites on ends_with('\')-parity cuts 5420→121 whole-buffer walks on nvm.sh (22.5→2.3ms); (2) physical-line stamping via newline-offset table + partition_point (3.1→0.07ms), plus removal of perf21's dead Instant residue.

    Numbers (interleaved A/B medians, 11 rounds, quiet-window re-verified): nvm -n −13% (GNU ratio 18.0x→15.6x), nvm load −9%. Gates: 537-file corpus 0 differ; true-baseline 18-suite 54/54 byte-identical; canaries byte-identical; failure set identical to master.

    Next honest ceilings (measured, this round's stop line): ~26ms = the 60 big fold-completion full re-lexes — the resume checkpoint cannot fold a { before the checkpoint offset, so each big group's closing line re-lexes the whole buffer (skip_brace body walk linear×depth); fix = opener-state LexerBoundaryState checkpoint at bare-{ emission — scanner.rs/mod.rs deep water, own round with full gates. ~12ms = linear small-line lexing (4753 single-line commits) — token-architecture round territory. Residual backslash scans 2.3ms (1.3%, below the honesty bar).

    Decomposition artifacts: rubash-wt-lextok/target/lextok/ + target/issue-suites/results/lextok/.

  4. added
    P1-high
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions