Skip to content

Conversation

@sidp
Copy link
Contributor

@sidp sidp commented Jul 17, 2025

This PR implements dynamic sizing of the buffer used by tree-sitter, to fix #74 . The default 32 KB buffer size is maintained, but any files over that size will be parsed with a dynamic buffer size matching the file size + 32 bytes of padding instead.

I suggest that a warning is logged for files where the size starts to noticeably affect performance. It's currently set to 2 MB but I'm of course open to suggestions to change it. Logging for every file is over 32 kb might get noisy in some codebases.

Here are some performance metrics captured on my Macbook Pro M1:

file size parse time
1 kb 10 ms
100 kb 145 ms
1 mb 1656 ms
2 mb 3849 ms
3 mb 6487 ms
4 mb 11278 ms
5 mb 13039 ms
10 mb 40163 ms

@erikyo erikyo merged commit 55533c6 into wp-blocks:1.6.2 Jul 17, 2025
3 checks passed
@erikyo
Copy link
Collaborator

erikyo commented Jul 17, 2025

@sidp, I have to thank you again! ☺️

Your contributions have been really valuable!

@sidp
Copy link
Contributor Author

sidp commented Jul 17, 2025

No problem at all! 🙌

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.

2 participants