Tagging Motoko to hopefully get some additional eyes on this.
I’m also very curious about this large memory discrepancy between HashMap and TrieMap.
@claudio do you have any ideas regarding why the memory usage is so much higher for HashMap? And were there any benchmarks run on the modules in motoko-base beforehand that can be referenced?
Based on the table resizing code link @justmythoughts posted, the load factor for the current HashMap implementation is 1 (hash table waits until count >= size of the array to double. I could see memory usage being 4X or 10X if the load factor was 0.25 or 0.1 respectively, but it makes no sense that the memory usage is 28X that of TrieMap with a load factor of 1.
I wonder if it hash anything to do with this issue, and not necessarily that the HashMap is less space efficient