Skip to content

Conversation

@wenxuanjun
Copy link
Contributor

@wenxuanjun wenxuanjun commented Dec 28, 2025

This PR implements performance optimizations for the indexing process and fixes memory leaks throughout the LSP lifecycle.

Refactored build_stub_tree to use a lightweight TreeWalker with manual cursor management, avoiding unnecessary object creation.

Addressed memory leaks where Tree-sitter C-side resources were not being freed. I also ensures temporary parsers used during constant and enum value evaluation are correctly freed.

Resolves #131.

Benchmarks

Indexing a project (including vlib and vmodules) without stub cache:

Dev build:

  • Before: 10.75s, 72MB peak memory
  • After: 7.96s, 50MB peak memory

Prod build:

  • Before: 6.9s, 63MB peak memory
  • After: 5.6s, 48MB peak memory

Test suite (v test src/tests):

  • Before: 7102.553 ms
  • After: 3324.785 ms

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.
Thank you for working on it 🙇🏻 .
A lot.

@wenxuanjun wenxuanjun marked this pull request as draft December 28, 2025 18:41
@wenxuanjun wenxuanjun marked this pull request as ready for review December 28, 2025 19:42
@spytheman spytheman merged commit f9e6c82 into vlang:main Dec 29, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V-analyzer slowly leaks memory over time

2 participants