google/cayley — pull request #128 by barakmich (2014-08-20 21:57:39+00:00)
Title: Add BoltDB backend

There's a flurry of discussion about what makes a good local persistent backend. LevelDB was a choice, and a good one, but there's a lot of options out there. I've been weighing a few of them and I'm coming around to [Bolt](http://github.com/boltdb/bolt) as a pretty good one.

For one, it improves our ACID story considerably. It has real read/write transactions and a nice API. That alone is a selling point for me. It writes relatively quickly (or at least, certainly not more slowly) than LevelDB and is well-supported. It does have some disk overhead on small stores (eg, 600Mb for the movies set against ~225Mb) but that starts to even out on larger ones. The corollary is that its memory usage would likewise be higher.

But then how does it do on queries?
```
$ benchx leveldbpr.txt boltpr.txt
benchmark old ns/op new ns/op delta mult
BenchmarkNamePredicate 3807236 1409078 -62.99% -2.70x
BenchmarkLargeSetsNoIntersection 925544265 187675217 -79.72% -4.93x
BenchmarkVeryLargeSetsSmallIntersection 1306140818 471821173 -63.88% -2.77x
BenchmarkHelplessContainsChecker 1437189511 367282585 -74.44% -3.91x
BenchmarkNetAndSpeed 80003659 25535952 -68.08% -3.13x
BenchmarkKeanuAndNet 37146352 16469829 -55.66% -2.26x
BenchmarkKeanuAndSpeed 60546303 31867784 -47.37% -1.90x
BenchmarkKeanuOther 465388076 175475491 -62.29% -2.65x
BenchmarkKeanuBullockOther 917129328 229777168 -74.95% -3.99x
```
(benchx is a simple awk script of mine for the last column)

In short, it's roughly 3x faster across the board.

I'm happy to keep testing, but it's at least time to share and get comments.

(Incidentally, this would fix #9 (number nine... number nine....))