This is an helper function with the goal of estimating the memory * size of a radix tree that is used to store Stream IDs. * * Note: to guess the size of the radix tree is not trivial, so we * approximate it considering 16 bytes of data overhead for each * key (the ID), and then adding the number of bare nodes, plus some * overhead due by the data and child pointers. This secret recipe * wa
| 792 | * on the insertion speed and thus the ability of the radix tree |
| 793 | * to compress prefixes. */ |
| 794 | size_t streamRadixTreeMemoryUsage(rax *rax) { |
| 795 | size_t size; |
| 796 | size = rax->numele * sizeof(streamID); |
| 797 | size += rax->numnodes * sizeof(raxNode); |
| 798 | /* Add a fixed overhead due to the aux data pointer, children, ... */ |
| 799 | size += rax->numnodes * sizeof(long)*30; |
| 800 | return size; |
| 801 | } |
| 802 | |
| 803 | /* Returns the size in bytes consumed by the key's value in RAM. |
| 804 | * Note that the returned value is just an approximation, especially in the |