MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / streamRadixTreeMemoryUsage

Function streamRadixTreeMemoryUsage

src/object.cpp:878–885  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

876 * on the insertion speed and thus the ability of the radix tree
877 * to compress prefixes. */
878size_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

Callers 1

objectComputeSizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected