Skip to content

deps(treesitter): upgrade gotreesitter from v0.16.0 to v0.48.0 - #43

Merged
HarshK97 merged 5 commits into
mainfrom
deps/upgrade-gotreesitter-v0.48.0
Aug 2, 2026
Merged

deps(treesitter): upgrade gotreesitter from v0.16.0 to v0.48.0#43
HarshK97 merged 5 commits into
mainfrom
deps/upgrade-gotreesitter-v0.48.0

Conversation

@HarshK97

@HarshK97 HarshK97 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Problem

  1. gotreesitter v0.16.0 had unbounded GLR parser stack splits on ambiguous syntax like Python blocks, causing severe parsing slowdowns up to ~400ms.
  2. High allocation churn (13k to 19k allocations per diff) placed unnecessary memory pressure on the Go garbage collector.
  3. CI benchmark execution was delayed because it waited on slow cross-platform test matrix runners (macOS and Windows) before starting.

What Changed

  • Dependency Upgrade: Upgraded gotreesitter from v0.16.0 to v0.48.0.
  • GLR Parser & Memory Optimization: Introduced GLR state-stack merging, iteration depth safety caps, O(N) leaf node matching, and scratch buffer pooling.
  • Modular CI Jobs Architecture: Refactored .github/workflows/ci.yml into 4 dedicated, decoupled jobs:
    • lint: Fails fast in ~15s on syntax/formatting issues.
    • test-linux: Runs unit tests + code coverage on ubuntu-latest.
    • test-cross: Runs cross-platform unit tests on macos-latest & windows-latest in parallel.
    • benchmark: Depends on [lint, test-linux] (not test-cross), executing A/B benchmarks as soon as Linux unit tests pass with path filtering.
  • CI Benchmark Formatting: Added a formatting script to parse benchstat output into a clean GitHub Step Summary report with geometric means, highlighted performance deltas, and collapsible breakdown tables.

Version Evolution

  • v0.16.0: Base version. Suffered from unbounded GLR parser stack splits and heavy allocation churn.
  • v0.24.0 / v0.26.0: Fixed parser hangs by introducing bounded GLR stack depth limits and ABI v14 state safety caps.
  • v0.40.0: Added memory worker bounds and initial scratch buffer allocations.
  • v0.48.0: Added O(N) leaf node matching, buffer reuse, and 200+ pre-compiled pure Go grammars for native TUI syntax highlighting.

Benchmark & CI Reporting Impact

  • Python Parsing: Up to 17x faster on large Python files (py_fix_encode_files dropped from 392.57 ms to 23.31 ms).
  • Heap Allocations: Cut Go heap allocations significantly (-35% to -53% fewer allocations across Go fixtures).
  • Executive Summaries: PR CI runs render structured Markdown tables for benchmark comparisons and code coverage right in the GitHub summary tab when performance-critical paths are modified.
  • CGo Evaluation: Confirms keeping pure Go gotreesitter with CGO_ENABLED=0, giving us zero CGo build setups with only ~10% total pipeline difference against CGo tree-sitter.

@HarshK97
HarshK97 force-pushed the deps/upgrade-gotreesitter-v0.48.0 branch 2 times, most recently from b135053 to f999fef Compare August 2, 2026 05:41
@HarshK97
HarshK97 force-pushed the deps/upgrade-gotreesitter-v0.48.0 branch from 9437919 to 0a4b312 Compare August 2, 2026 05:47
@HarshK97
HarshK97 merged commit 284e005 into main Aug 2, 2026
8 checks passed
@HarshK97
HarshK97 deleted the deps/upgrade-gotreesitter-v0.48.0 branch August 2, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant