Description
When doing some memory profiling, I noticed that Locals::push
ends up requiring a lot grows:
The location for the initial pushes appears to be here:
tree-house/highlighter/src/locals.rs
Lines 209 to 217 in 16e1189
With push
also calling the inner Vec::push
:
tree-house/highlighter/src/locals.rs
Lines 44 to 52 in 16e1189
locals
is instantiated via Locals::default
. Currently the default impl is using 4
as a starting point:
tree-house/highlighter/src/locals.rs
Lines 28 to 41 in 16e1189
I wonder if increasing the starting size a bit could end up removing the need for some of the grows? Maybe try 8
? Or 16
? I don't know enough about the full context of how this function works to know if this is a meaningful change or not, but thought I would share.
As far as other places for large allocation numbers (not amount allocated, just the amount of allocations), most other areas in the screenshot lead directly into the C tree-sitter implementation. Of the spots in the actual Rust code, found just a few so far.