v0.40.0
A byte-identical performance release, plus a security guard and an incremental-correctness fix. Every performance change is verified byte-for-byte identical to the C tree-sitter oracle across the 206-grammar parity suite.
Performance
On the forest-path grammars (C#, Bash, CMake) these compound to roughly a 30% wall-clock reduction with ~95% less allocation:
- Build-time PGO — ~7% wall-clock, broad across all 206 grammars.
- Forest-index allocation overhaul — the forest alternative index is pooled across parses and per-compare throwaway slices are gone; allocation bytes drop 86–96% and GC-cycle CPU 48–90%.
- GLR comparator copy elimination — the disambiguation comparator chain takes stack pointers instead of copying a 104-byte value per call (~12 fewer
runtime.duffcopyper compare); ~14% wall-clock. - Forest reducer pooling — the per-parse forest reducer is pooled; a further ~51% cut in C# parse allocation.
Security
- Query matcher work budget — the
-Allquantifier matchers now charge a per-execution work budget, bounding worst-case combinatorial blow-up on adversarial query/source pairs. Surfaced viaCursor.DidExceedMatchLimit, configurable withSetMatchWorkBudget(default 1,000,000).
Fixed
- Incremental reuse token-boundary bug — incremental parsing no longer reuses a stale subtree when an edit shifts a token boundary that abuts a reused node's right edge. Both the leaf and the non-leaf (wrapped-token) reuse paths now reject reuse on a boundary mismatch, preventing spurious
ERRORnodes on common edits such as deleting the whitespace between two identifiers (e.g. Clojure(a b)→(ab)). Verified byte-identical to a fresh parse across the C-oracle incremental parity harness.
Known issues (pre-existing, not regressions)
- Incremental-forest divergence on
javascript/jquery.js under the non-defaultGTS_FOREST_INCR=1mode. - A single-character mid-identifier incremental-delete divergence class on some grammars (JS/TS/TSX/Python), unrelated to the boundary fix; tracked as follow-up.
The v0.39.0 authenticated cross-suite receipt remains the published performance baseline; a re-measured v0.40.0 receipt is pending.
Full changelog: v0.39.0...v0.40.0