Skip to content

Conversation

@AndreasArvidsson
Copy link
Member

@AndreasArvidsson AndreasArvidsson commented Jan 10, 2025

First, were checking the captures against the SCM files in production, which was an oversight - should only be happening in debugging.

Secondarily, the existing implementation multiple map and filters. This part of the code is very time sensitive and can run quite long for large files since we are iterating every capture in the entire file.

This implementation aims to reduce iteration steps

Fixes #2656

Checklist

  • [/] I have added tests
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson AndreasArvidsson requested a review from a team as a code owner January 10, 2025 00:43
@phillco
Copy link
Member

phillco commented Jan 10, 2025

We're going to test the performance of the test change and the captured to for loop rewrite separately so we can get a better sense for where the improvement is. The loop rewrite is still a nice code cleanliness change on its own, but we'd like to know how much more efficient it is to better calibrate JavaScript performance mentally.

@AndreasArvidsson
Copy link
Member Author

Now I have some data

529k lines json, 11 iterations, median value

  • main, checking captures: 4201ms
  • main, don't check captures: 3944ms
  • pr, checking captures: 3878ms
  • pr, don't check captures: 3754ms

@phillco
Copy link
Member

phillco commented Jan 11, 2025

Total performance improvement: 11.45%

  • Not checking captures: 8.3%
  • Loop rewriting: 3.2%

@phillco phillco added this pull request to the merge queue Jan 11, 2025
Merged via the queue into main with commit 85fd827 Jan 11, 2025
15 checks passed
@phillco phillco deleted the treeSitterMatches branch January 11, 2025 16:45
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.

Improve performance when using large files

3 participants