Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make pebble the clear choice #115

Closed

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Jan 7, 2024

Closes: #90

  • add pebbledb
  • use latest pebble
  • added a ton of test rigor and fixed linting
  • if always false we don't need the param
  • let's go fast

@faddat faddat requested a review from a team as a code owner January 7, 2024 10:23
@faddat
Copy link
Contributor Author

faddat commented Jan 7, 2024

All I can say is:

  • informal never merged it
  • ICF never funded it
  • notional never optimized it: most interactions with informal are disincentivized
  • we believe and can sense / smell that Anton could be different.
  • we are gonna try again.
  • Jacob thinks Osmosis will benefit from optimizing it, so -- it is being optimized.

Copy link

codecov bot commented Jan 7, 2024

Codecov Report

Attention: 97 lines in your changes are missing coverage. Please review.

Comparison is base (b15320b) 77.53% compared to head (070a044) 73.98%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
- Coverage   77.53%   73.98%   -3.55%     
==========================================
  Files          22       13       -9     
  Lines        1785     1134     -651     
==========================================
- Hits         1384      839     -545     
+ Misses        342      250      -92     
+ Partials       59       45      -14     
Files Coverage Δ
goleveldb.go 59.84% <100.00%> (ø)
test_helpers.go 100.00% <100.00%> (ø)
util.go 36.66% <100.00%> (ø)
db.go 35.00% <50.00%> (ø)
memdb_iterator.go 90.42% <33.33%> (-2.99%) ⬇️
memdb.go 69.64% <16.66%> (-1.27%) ⬇️
pebble.go 71.93% <71.93%> (ø)

... and 10 files with indirect coverage changes

Files Coverage Δ
goleveldb.go 59.84% <100.00%> (ø)
test_helpers.go 100.00% <100.00%> (ø)
util.go 36.66% <100.00%> (ø)
db.go 35.00% <50.00%> (ø)
memdb_iterator.go 90.42% <33.33%> (-2.99%) ⬇️
memdb.go 69.64% <16.66%> (-1.27%) ⬇️
pebble.go 71.93% <71.93%> (ø)

... and 10 files with indirect coverage changes

@faddat
Copy link
Contributor Author

faddat commented Jan 7, 2024

faddat@Whites-MacBook-Pro cometbft-db % GOARCH=arm64 go test -bench=BenchmarkPebbleDBvsGoLevelDB
goos: darwin
goarch: arm64
pkg: github.com/cometbft/cometbft-db
BenchmarkPebbleDBvsGoLevelDB/PebbleDB-8 322890 3930 ns/op
BenchmarkPebbleDBvsGoLevelDB/GoLevelDB-8 315639 4425 ns/op
PASS
ok github.com/cometbft/cometbft-db 7.470s

@faddat
Copy link
Contributor Author

faddat commented Jan 7, 2024

faddat@Whites-MacBook-Pro cometbft-db % GOARCH=arm64 go test -bench=BenchmarkPebbleDBvsGoLevelDB
goos: darwin
goarch: arm64
pkg: github.com/cometbft/cometbft-db
BenchmarkPebbleDBvsGoLevelDB/PebbleDB-8 348592 3866 ns/op
BenchmarkPebbleDBvsGoLevelDB/GoLevelDB-8 307240 4261 ns/op
PASS
ok github.com/cometbft/cometbft-db 7.409s

@faddat
Copy link
Contributor Author

faddat commented Jan 7, 2024

However if tested against iavl, this would be even more superieor.

@faddat faddat closed this Jan 7, 2024
@faddat faddat reopened this Jan 9, 2024
@faddat
Copy link
Contributor Author

faddat commented Jan 9, 2024

Please use this mainly for the benchmarks as I think I made a kind of significant finding here with regard to high bandwidth situations.

@faddat
Copy link
Contributor Author

faddat commented Jan 9, 2024

TO: Maintainer -

please run the benchmarks I think they could explain some recent stuff.

@faddat
Copy link
Contributor Author

faddat commented Jan 9, 2024

I'll pull benchmarks from here.

@faddat
Copy link
Contributor Author

faddat commented Jan 14, 2024

to: maintiner (idk who this is) please run benchmarks on a solidly fast machine.

I fear if we don't it wont match the real world.

@faddat faddat marked this pull request as ready for review January 14, 2024 19:08
@faddat
Copy link
Contributor Author

faddat commented Jan 14, 2024

In general the benchmarks will exceed what a normal computer can do. my 64gb macbook pro handles it well. I could reduce the size of values, which I am somewhat guessing on, and increase the number of keys. The critical thing to note is that

go test -bench=.
goos: darwin
goarch: arm64
pkg: github.com/cometbft/cometbft-db
BenchmarkGoLevelDBRandomReadsWrites-12            374047              3878 ns/op
BenchmarkMemDBRangeScans1M-12                       1087           1122654 ns/op
BenchmarkMemDBRangeScans10M-12                      1060           1126530 ns/op
BenchmarkMemDBRandomReadsWrites-12               1000000              2080 ns/op
BenchmarkDB/Keys_10000_Values_512_pebbledb-12           1000000000               0.03704 ns/op
BenchmarkDB/Keys_10000_Values_512_goleveldb-12          1000000000               0.05867 ns/op
BenchmarkDB/Keys_10000_Values_1024_pebbledb-12          1000000000               0.03695 ns/op
BenchmarkDB/Keys_10000_Values_1024_goleveldb-12         1000000000               0.08461 ns/op
BenchmarkDB/Keys_10000_Values_2048_pebbledb-12          1000000000               0.03693 ns/op
BenchmarkDB/Keys_10000_Values_2048_goleveldb-12         1000000000               0.1145 ns/op
BenchmarkDB/Keys_10000_Values_4096_pebbledb-12          1000000000               0.04425 ns/op
BenchmarkDB/Keys_10000_Values_4096_goleveldb-12         1000000000               0.2443 ns/op
BenchmarkDB/Keys_25000_Values_512_pebbledb-12           1000000000               0.08316 ns/op
BenchmarkDB/Keys_25000_Values_512_goleveldb-12          1000000000               0.1817 ns/op
BenchmarkDB/Keys_25000_Values_1024_pebbledb-12          1000000000               0.07789 ns/op
BenchmarkDB/Keys_25000_Values_1024_goleveldb-12         1000000000               0.2394 ns/op
BenchmarkDB/Keys_25000_Values_2048_pebbledb-12          1000000000               0.07354 ns/op
BenchmarkDB/Keys_25000_Values_2048_goleveldb-12         1000000000               0.3182 ns/op
BenchmarkDB/Keys_25000_Values_4096_pebbledb-12          1000000000               0.07995 ns/op
BenchmarkDB/Keys_25000_Values_4096_goleveldb-12                1        1674754750 ns/op
BenchmarkDB/Keys_50000_Values_512_pebbledb-12           1000000000               0.1466 ns/op
BenchmarkDB/Keys_50000_Values_512_goleveldb-12          1000000000               0.3238 ns/op
BenchmarkDB/Keys_50000_Values_1024_pebbledb-12          1000000000               0.1558 ns/op
BenchmarkDB/Keys_50000_Values_1024_goleveldb-12         1000000000               0.4517 ns/op
BenchmarkDB/Keys_50000_Values_2048_pebbledb-12          1000000000               0.1485 ns/op
BenchmarkDB/Keys_50000_Values_2048_goleveldb-12         1000000000               0.7940 ns/op
BenchmarkDB/Keys_50000_Values_4096_pebbledb-12          1000000000               0.1651 ns/op
BenchmarkDB/Keys_50000_Values_4096_goleveldb-12                1        1899533750 ns/op
BenchmarkDB/Keys_75000_Values_512_pebbledb-12           1000000000               0.2108 ns/op
BenchmarkDB/Keys_75000_Values_512_goleveldb-12          1000000000               0.4588 ns/op
BenchmarkDB/Keys_75000_Values_1024_pebbledb-12          1000000000               0.2225 ns/op
BenchmarkDB/Keys_75000_Values_1024_goleveldb-12         1000000000               0.7332 ns/op
BenchmarkDB/Keys_75000_Values_2048_pebbledb-12          1000000000               0.2192 ns/op
BenchmarkDB/Keys_75000_Values_2048_goleveldb-12                1        1429007458 ns/op
BenchmarkDB/Keys_75000_Values_4096_pebbledb-12          1000000000               0.2486 ns/op
BenchmarkDB/Keys_75000_Values_4096_goleveldb-12                1        3416400792 ns/op
BenchmarkDB/Keys_100000_Values_512_pebbledb-12          1000000000               0.2646 ns/op
BenchmarkDB/Keys_100000_Values_512_goleveldb-12         1000000000               0.6500 ns/op
BenchmarkDB/Keys_100000_Values_1024_pebbledb-12         1000000000               0.3111 ns/op
BenchmarkDB/Keys_100000_Values_1024_goleveldb-12               1        1034177375 ns/op
BenchmarkDB/Keys_100000_Values_2048_pebbledb-12         

pebble is in general many times faster.

Ulike goleveldb, pebble is maintained.

@faddat
Copy link
Contributor Author

faddat commented Jan 14, 2024

sometimes pebble is a few million times faster.

Flakiness, anyone?

This was referenced Jan 15, 2024
@faddat
Copy link
Contributor Author

faddat commented Jan 16, 2024

the big worry here is that goleveldb does not act in a predictable manner.

@faddat
Copy link
Contributor Author

faddat commented Jan 16, 2024

preparing a branch of cometbft's main to see if we can eliminate time based flakiness with pebble.

itsdevbear added a commit to berachain/polaris that referenced this pull request Jan 17, 2024
In my view the berachain testnet experienced unreliability due to
upstream issues in Comet.

* cometbft/cometbft#1940

While I cannot be sure, I think that some of the results that I got in
recent benchmarks of goleveldb actually represent clear bugs that could
under certain circumstances be used to halt chains.

* cometbft/cometbft-db#115

So here's the thinking:

1) drop goleveldb for pebble by literally specifying pebble statically
in the code
2) reduce max_bytes to 1mb
3) increase the size of the validator set and distribute VP evenly
4) torture the network, including torturing RPCs

Co-authored-by: Devon Bear <itsdevbear@berachain.com>
@adizere
Copy link
Member

adizere commented Jan 23, 2024

I'm a fan. How is pebbleDB handling workload in Berachain?

Really wish you didn't do unnecessary changes here so we could review it easier. But aside from that, concept ACK and we'll review this ASAP, thanks for patience!

@@ -12,7 +12,7 @@ import (
"github.com/dgraph-io/badger/v2"
)

func init() { registerDBCreator(BadgerDBBackend, badgerDBCreator, true) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason for changing this interface?

@@ -54,7 +58,6 @@ test-all-with-coverage:
-race \
-coverprofile=coverage.txt \
-covermode=atomic \
-tags=memdb,goleveldb,cleveldb,boltdb,rocksdb,grocksdb_clean_link,badgerdb \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this line?

@@ -137,7 +137,7 @@ func (db *MemDB) DeleteSync(key []byte) error {
}

// Close implements DB.
func (db *MemDB) Close() error {
func (*MemDB) Close() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lint will complain that the signature is not following the same pattern for all functions. It's probably a style preference so not a strong opinion but it usually complains in case of mixed (db *MemDB) and (*MemDB).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nope, please think of an unused receiver as the declaration of an unused variable, and these lints will make perfect sense to you.

"github.com/cockroachdb/pebble/bloom"
)

// ForceSync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we established whether this version of Pebble needs these extra steps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs them, as long as SDK doesn't cleanly. close the DB after an upgrade -- at least I think that's what @baabeetaa found.

…erwhelmingly-fast

      - prefix(github.com/cosmos/ibc-go)
@melekes
Copy link
Contributor

melekes commented Jan 24, 2024

Closing in favor of #112. Let's focus on a single PR. After it's merged, we can do linting.

@melekes melekes closed this Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for pebbleDB
5 participants