4 ms·
Mutable strings are a double edged sword from a performance perspective. It sucks to have a bunch of un-needed string allocations due to string literals that ar
by schneems 11y ago
Mutable strings are a double edged sword from a performance perspective. It sucks to have a bunch of un-needed string allocations due to string literals that are only used for one method. Sometimes though, mutating and re-using strings when possible can yield some pretty large improvements like https://github.com/mime-types/ruby-mime-types/pull/93 https://github.com/mime-types/ruby-mime-types/pull/93.
I would love to read a post written in simple(ish) terms about how V8 handles string allocation and what string performance optimizations helped the most. Would be really neat to see it compared to python/ruby/etc.
It's also worth noting that the majority of the speed here comes from getting rid of hash and array allocations. The bulk of the object count came from string savings but the bulk of the "memory" came from more complex objects.