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
| 876 | * on the insertion speed and thus the ability of the radix tree |
| 877 | * to compress prefixes. */ |
| 878 | size_t streamRadixTreeMemoryUsage(rax *rax) { |
| 879 | size_t size; |
| 880 | size = rax->numele * sizeof(streamID); |
| 881 | size += rax->numnodes * sizeof(raxNode); |
| 882 | /* Add a fixed overhead due to the aux data pointer, children, ... */ |
| 883 | size += rax->numnodes * sizeof(long)*30; |
| 884 | return size; |
| 885 | } |
| 886 | |
| 887 | /* Returns the size in bytes consumed by the key's value in RAM. |
| 888 | * Note that the returned value is just an approximation, especially in the |