, 15 tweets, 3 min read Read on Twitter
Something that nobody tells and I've learned the hard way: don't use radix trees if you have to delete nodes.
Consul and Vault use an immutable radix tree and that's why people complain of the everlasting massive keys' deletions. It's the tree.
radix trees are good for fast in-memory searches and adding nodes but very bad for deleting them. You will fall back to the old good BTrees.
But now we have copy-on-write btrees, so you can cheaply O(1) clone a tree, do the inserts in the close and then swap the roots...
And the reads will be fast as usual.
And so it finishes my report after sleeping 6 hours in 48 hours optimizing massive btrees operations ;)
Some details, massive trees in memory, for example in one node. Radix consumed 72 GB but sky rocketed to 140 for eternal deletions (expires)
Very fast for reading, average of < 10 ms but useless because expirations killed completely the system. Had to go back to btress...
Initially the average was higher that 10 ms, sad. But the I started to optimize it, first I moved the keys tree to a map. Although...
BTrees' fans will telly you that trees are often faster than hashing tables (map in Go) and that normally is O(k), it's a lie! A big lie.
For massive trees you really notice the difference of the (ish) O(1) vs the O(log n) of a tree. The map for the unique keys improved a lot.
Next I created two versions of every tree (one per index plus the expiration's) with a COW clone and switch them at the end of transactions
This also allowed me to get rid the reader lock for reads operations, now they are lockless!
At the end, similar or better response times than radixes', deletions are unnoticeable and it consumes < 30GB w/o increasing in deletions.
And this is the story of perhaps the best engineering work I ever made. I couldn't even stop for eating or sleeping, like a drug.
OTOH estoy solo en casa (toda mi familia de viaje), me da pereza salir o cocinar porque pierdo tiempo. Creo que perdí 2 kg en 3 días.
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Ricardo Galli
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member and get exclusive features!

Premium member ($3.00/month or $30.00/year)

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!