Closed odeke-em closed 1 year ago
Good catch! To preallocate the whole thing, we need a couple of loops to calculated the size; I don't think len(t.R16) + len(t.R32)
is a good estimation on the number of runes.
expandRangeTable
should only be called once for a particular table and then cached forever, that's why I did not bother to preallocate. Does this slow down the tests in your case, or was it just something you have noticed in the profile when troubleshooting other issues?
Good to chat with you @flyingmutant and thanks for your work on this package! I noticed it in profiles, I work on security and performance for the Cosmos Network so I focus on ridding as much CPU and RAM usage in profiles; we use simapp (a simulation app) to run a whole bunch of tests and benchmarks and such profiles if they exist in profiles can become a distraction.
Noticed by profiling the cosmos-sdk project which uses this code that has a RAM profile of
but we can modify expandRangeTable to preallocate ret by
After
On re-profiling the same code, we now get this profile