rpds icon indicating copy to clipboard operation
rpds copied to clipboard

Memory Usage for Debugging

Open fredfortier opened this issue 4 years ago • 4 comments

What is a good way to get the current memory usage of a rpds structure? I'm looking for something like Servo's malloc_size_of. I can get the size of leaves but I'm missing the size of branches. Or is it trivial to calculate it? Any recommendation would be appreciated.

fredfortier avatar Jul 16 '21 15:07 fredfortier

Hi @fredfortier. There's no simple way to get those numbers. I can imagine a custom allocator that keeps track of which functions allocate memory.

If you want to go a bit more intrusive and modify rpds you can traverse the tree of the data structure you want to inspect and sum all sizes together.

Keep in mind that most persistent data structures keep a fair amount of extra data, so I expect the memory overhead to be significant for most data structures.

orium avatar Jul 19 '21 16:07 orium

Any simple formula I can use to compute an estimated size? I don't need precise measurements. If I can make some assumptions, like treat them all as uncolored binary search tree, while remaining in the ballpark, it might be good enough for me.

fredfortier avatar Jul 19 '21 18:07 fredfortier

Which particular data structure are you trying to get the memory usage of?

orium avatar Jul 19 '21 23:07 orium

These here: HashTrieMapSync, HashTrieSetSync, RedBlackTreeMapSync, RedBlackTreeSetSync, StackSync

fredfortier avatar Jul 20 '21 00:07 fredfortier