Skip to content

make pebble the clear choice - #115

Closed
faddat wants to merge 25 commits into
cometbft:mainfrom
faddat:faddat/make-pebble-overwhelmingly-fast
Closed

faddat wants to merge 25 commits into
cometbft:mainfrom
faddat:faddat/make-pebble-overwhelmingly-fast

Conversation

@faddat

@faddat faddat commented Jan 7, 2024 •

Copy link
Copy Markdown
Contributor

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

faddat commented Jan 7, 2024 •

Copy link
Copy Markdown
Contributor Author

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.

@codecov

codecov Bot commented Jan 7, 2024 •

Copy link
Copy Markdown

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

faddat commented Jan 7, 2024

Copy link
Copy Markdown
Contributor Author

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

faddat commented Jan 7, 2024

Copy link
Copy Markdown
Contributor Author

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

faddat commented Jan 7, 2024

Copy link
Copy Markdown
Contributor Author

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

faddat commented Jan 9, 2024

Copy link
Copy Markdown
Contributor Author

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

faddat commented Jan 9, 2024

Copy link
Copy Markdown
Contributor Author

TO: Maintainer -

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

@faddat

faddat commented Jan 9, 2024

Copy link
Copy Markdown
Contributor Author

I'll pull benchmarks from here.

@faddat
faddat marked this pull request as draft January 9, 2024 20:56
@faddat

faddat commented Jan 14, 2024

Copy link
Copy Markdown
Contributor Author

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

faddat commented Jan 14, 2024 •

Copy link
Copy Markdown
Contributor Author

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

faddat commented Jan 14, 2024

Copy link
Copy Markdown
Contributor Author

sometimes pebble is a few million times faster.

Flakiness, anyone?

This was referenced Jan 15, 2024
@faddat

faddat commented Jan 16, 2024

Copy link
Copy Markdown
Contributor Author

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

@faddat

faddat commented Jan 16, 2024

Copy link
Copy Markdown
Contributor Author

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

itsdevbear pushed 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 <[email protected]>
@adizere

adizere commented Jan 23, 2024

Copy link
Copy Markdown
Contributor

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!

Comment thread badger_db.go
"github.com/dgraph-io/badger/v2"
)

func init() { registerDBCreator(BadgerDBBackend, badgerDBCreator, true) }

Copy link
Copy Markdown
Collaborator

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?

Comment thread Makefile
-race \
-coverprofile=coverage.txt \
-covermode=atomic \
-tags=memdb,goleveldb,cleveldb,boltdb,rocksdb,grocksdb_clean_link,badgerdb \

Copy link
Copy Markdown
Collaborator

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?

Comment thread memdb.go

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

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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.

Comment thread pebble.go
"github.com/cockroachdb/pebble/bloom"
)

// ForceSync

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

melekes commented Jan 24, 2024

Copy link
Copy Markdown
Collaborator

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