hashicorp/raft-mdb

Have you seen boltdb?

pkieltyka opened this issue · 7 comments

github.com/boltdb/bolt

it's a fantastic LMDB-inspired db written entirely in Go...

@pkieltyka Yeah, just recently came across it. I want to write a bolt backend at some point just to benchmark the two.

Hey @armon I was just wondering if you did any benchmarking between the two?

@pkieltyka I haven't had a chance yet!

Hi @armon @pkieltyka I just did it today, check it out here:
https://github.com/spynup/raft-mdb

go bench results comparing the two on my lowly Macbook Pro are in the submit comment.

Almost 100 lines less, in some ways slower, other ways faster.
Experimental: go test passes, but this has not seen any real usage yet.

thats awesome, nice work

...and just now I saw this: https://github.com/hashicorp/raft-boltdb :) Guess it was good coding practice. Striking how similar the bench numbers compare:

$ go test
PASS
ok spynup.com/raft-boltdb 0.021s
$ go test -bench=.
PASS
BenchmarkBoltStore_FirstIndex 1000000 1309 ns/op
BenchmarkBoltStore_LastIndex 1000000 1368 ns/op
BenchmarkBoltStore_GetLog 500000 4759 ns/op
BenchmarkBoltStore_StoreLog 10000 288859 ns/op
BenchmarkBoltStore_StoreLogs 10000 419542 ns/op
BenchmarkBoltStore_DeleteRange 5000 346507 ns/op
BenchmarkBoltStore_Set 10000 294887 ns/op
BenchmarkBoltStore_Get 1000000 2097 ns/op
BenchmarkBoltStore_SetUint64 10000 246920 ns/op
BenchmarkBoltStore_GetUint64 1000000 1604 ns/op
ok spynup.com/raft-boltdb 23.668s

In the interests of keeping the ecosystem uncluttered, I deleted my fork, which is essentially identical to hashicorp/raft-boltdb

Above were the bench results of hashicorp/raft-boltdb.
Here are the bench results of hashicorp/raft-mdb on the same machine for comparison.
$ go test
PASS
ok spynup.com/raft-mdb 0.063s
$ go test -bench=.
PASS
BenchmarkMDBStore_FirstIndex 500000 2811 ns/op
BenchmarkMDBStore_LastIndex 1000000 2732 ns/op
BenchmarkMDBStore_GetLog 500000 5719 ns/op
BenchmarkMDBStore_StoreLog 10000 216940 ns/op
BenchmarkMDBStore_StoreLogs 5000 252693 ns/op
BenchmarkMDBStore_DeleteRange 10000 246455 ns/op
BenchmarkMDBStore_Set 10000 220326 ns/op
BenchmarkMDBStore_Get 1000000 2359 ns/op
BenchmarkMDBStore_SetUint64 10000 184869 ns/op
BenchmarkMDBStore_GetUint64 1000000 2426 ns/op
ok spynup.com/raft-mdb 22.342s