4 ms·
Try adding following optimizations to your binary radix tree code: 1) Path compression: avoid having intermediate empty nodes, when possible. E.g. replace root
by faragon 8y ago
Try adding following optimizations to your binary radix tree code:
1) Path compression: avoid having intermediate empty nodes, when possible. E.g. replace root-left(void)-left(void)-left(void)-left(item) with root-[000]left(item). Because of the node reduction, you'll get better data cache usage.
2) Use a memory pool for the nodes: you'll save because of avoiding malloc() overhead, plus the possibility of using e.g. 32-bit indexes instead of pointers. Like in (1), this would help you reduce the memory usage, being able to put more nodes in the data cache.
3) Nth level lookup table, so you can jump e.g. instead of starting from the root node, you could go directly to the Nth level. For a minor cost in the insertion, for updating the LUT, you could get an important speed-up (2x-3x, more, or less, depending on your data and how you tune the LUT -fixed level LUT, adaptative-level LUT, etc.-).
- loeg 8y agoOr start here: https://github.com/armon/libart https://github.com/armon/libart