weeknotes: hashmaps are slow

2025-10-26

This was the final push for members’ week and the crit day presentation! Phew.

(I’m checking over my notes a few weeks later, and it’s mostly notes from feedback about the presentation, so this will be a quick update.)

Making leaf diffusion faster

For leaf diffusion to look interesting, I needed it to run in real-time, but it was at around 2fps. Profiling this time showed me that it was the hashmaps that were slowing me down! So the first thought is to make sure that I’m not using the slow default hasher (even though it’s a bit faster). But in this case, I had a very dense HashMap where nearly every key had a value in a certain range. So instead I switched them to a simple new data type backed by a vector with the same interface as HashMap and got a 10x improvement, whoa. Another thing I did was keep the temporary data structure around and just cleared it before working with it. First time that has made a difference!

Oh, I also learned about having to force a function not to be inlined so you can profile it.

Also, I had gotten this far with my representation of time only being in milliseconds instead of microseconds, so I updated that. I wonder if any of the stuttering I sometimes notice was from that, eek!