DEV Community

Johannes Lichtenberger
Johannes Lichtenberger

Posted on

3 1

Rolling, secure hashes for nodes in a tree / How to reduce on-disk space consumption?

Hi all,

I've implemented the storage of rolling, secure hashes for a temporal document store called SirixDB.

During bulk inserts hashes are built while traversing the built tree in postorder. During updates, that is deletes, inserts or value updates hashes of ancestor nodes are adapted. We have unique node-IDs and hashes are built taking neighbour nodes into account (the 64 Bit node-IDs pointing to the sibling nodes).

For instance during an update the old hash is subtracted and a new hash basically added to parent node and that's bubbling up for all ancestors.

Now I wanted to reduce the collision possibility to a minimum and used Sha256 truncated to 128 Bits.

However, now every node optionally stores this hash, which is an additional 16 Bytes.

My idea would be to store all hashes of the nodes at the beginning of the variable sized page in a delta-encoding, for instance subtracting each consecutive hash from the former and storing some kind of variable size encoding.

Do you have any ideas how to best "compress" the hashes on-disk? Currently at most 512 nodes are stored in a page meaning 512*16 bytes only for the hashes.

Kind regards
Johannes

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay