10 minutes ago · 10 min read1944 words · Tech · hide

Until recently, sorted-map and sorted-set in Jolt were a straight port of Clojure's PersistentTreeMap, which is backed by a persistent red-black tree. Using a red-black tree has worked well for Clojure, and it provides a solid foundation for backing these data structures. However, red-black trees have a downside, which is that every entry gets its own small node, meaning that every step of a lookup follows a pointer to a different place in memory.So, naturally I got curious to see if a different data structure could be used for the same job which might have a lower overhead. Turns out that a red-black tree can indeed be swapped out for a B+tree here. I updated Jolt's sorted collections along with the java.util.TreeMap and TreeSet shims to use a persistent B+tree, which dropped peak memory by 40% while making most operations faster at every size, as we'll see later in the benchmarks.What was wrong with the red-black treeEach red-black node in Jolt was a five-slot Scheme vector holding…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town