Merkle trees and build systems
Merkle trees and build systems
Posted May 31, 2020 19:53 UTC (Sun) by MrWim (subscriber, #47432)In reply to: Merkle trees and build systems by nim-nim
Parent article: Merkle trees and build systems
This seems like a strange comment to make on an article specifically describing the advantages of making such a transposition.
The only difference between storing source-code in git vs storing it as source tarballs is storage and performance characteristics. But: it's exactly those differences that make git so much more useful than source tarballs. You interact with it and think about it differently once certain operations are cheap.
At the risk of restating things already stated in the article:
- Deployment is now incremental and cheap - you only need to transfer the blobs that have changed, not the whole tarball. The effect is you don't need a separate deployment mechanism during dev vs prod.
- You can store many many different versions of your built images in a reasonable amount of space - so you just stop worrying about it what to keep and what the deletion policy should be
- Your intermediate build steps now share storage with your final rootfses, so you don't need to worry about reducing the number of build steps or intermediate artefacts.
- The cost of comparing two trees is now super cheap, so becomes a natural operation to do. Interested in how a particular change has affected your installed image? It's fine we run a diff on the whole tree for every PR. This is particularly useful for changes to the build system itself.
- Maybe you're performing some transformation on your tree that only depends on one subdirectory? That's fine: extracting a subdir is cheap and because it's a merkle tree you know if you need to rerun your build steps, because you can find the SHA of the subtree cheaply.
- Composing a new tree out of subtrees or partial trees is super cheap, so you do so wherever convenient.
You could implement all of the above with tarballs, but it would be so impractical that you wouldn't. With Merkle trees it's natural. Whether it's innovative or not is irrelevant.
