fabric icon indicating copy to clipboard operation
fabric copied to clipboard

add badger as alternative state database

Open fubss opened this issue 9 months ago • 1 comments

Type of change

  • New feature

Description

BadgerDB was added as alternative for GolevelDB state database. Choosing the better alternative for the GolevelDB was a goal of my research within the paper "A Journey Towards the Most Efficient State Database For Hyperledger Fabric":

This PR adds Badger because it showed better performance results in comparison with GolevelDB, Bbolt and RocksDB.

PR satisfies potential future items of the current Hyperledger Fabric Roadmap where the goal to replace the GolevelDB with faster database is mentioned.

Additional details

Detailed Hyperledger Fabric performance reports mentioned in the papers above are availiable here. They were made using Hyperledger Caliper tool. The tool was used to measure main performance metrics on HLF peer with default GolevelDB and integrated Badger, Bbolt and RocksDB. More measuring details are described in the aforementioned studies.

To demonstrate Badger's potential advantage over GolevelDB, go benchmarks were added to the packages leveldbhelper and badgerdbhelper respectively. The results measured locally show that Badger has better performance for "put" operations than GolevelDB. The output is:

GolevelDB

go test -benchmem -run=^$ -bench ^BenchmarkLevelDBHelper$ github.com/hyperledger/fabric/common/ledger/util/leveldbhelper
goos: darwin
goarch: arm64
pkg: github.com/hyperledger/fabric/common/ledger/util/leveldbhelper
BenchmarkLevelDBHelper/get-leveldb-little-data-10                5452860               189.3 ns/op           108 B/op          4 allocs/op
BenchmarkLevelDBHelper/put-leveldb-10                                673           2768479 ns/op             248 B/op          3 allocs/op
BenchmarkLevelDBHelper/put-leveldb-type-2-10                         415           2560133 ns/op             204 B/op          3 allocs/op
PASS
ok      github.com/hyperledger/fabric/common/ledger/util/leveldbhelper  7.145s

Badger

 go test -benchmem -run=^$ -bench ^BenchmarkBadgerDBHelper$ github.com/hyperledger/fabric/common/ledger/util/badgerdbhelper
goos: darwin
goarch: arm64
pkg: github.com/hyperledger/fabric/common/ledger/util/badgerdbhelper
BenchmarkBadgerDBHelper/get-badgerdb-little-data-10          1388515               727.7 ns/op           410 B/op          8 allocs/op
BenchmarkBadgerDBHelper/put-badgerdb-10                           207873              5808 ns/op            1408 B/op         37 allocs/op
BenchmarkBadgerDBHelper/put-badgerdb-type-2-10                171474              7206 ns/op            1477 B/op         37 allocs/op
PASS
ok      github.com/hyperledger/fabric/common/ledger/util/badgerdbhelper 13.984s

The changes were tested locally and with GitHub CI/CD.

fubss avatar May 14 '24 19:05 fubss

@fubss Thanks; I believe switching to a more performant k/v is a valuable contribution. However, such changes warrant the need to start with RFC first. Please follow the link and submit your proposal here.

C0rWin avatar May 15 '24 06:05 C0rWin