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

ethdb: add pebble for experiment #21575

Closed
wants to merge 1 commit into from

Conversation

rjl493456442
Copy link
Member

No description provided.

ethdb/pebble/pebble.go Outdated Show resolved Hide resolved
ethdb/pebble/pebble.go Outdated Show resolved Hide resolved
ethdb/pebble/pebble.go Outdated Show resolved Hide resolved
ethdb/pebble/pebble.go Outdated Show resolved Hide resolved
ethdb/pebble/pebble.go Outdated Show resolved Hide resolved
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

Please rebase the PR and squash it so it's easier to apply on top of other prs for debugging and benchmarking

ethdb/pebble/pebble.go Outdated Show resolved Hide resolved
@rjl493456442 rjl493456442 force-pushed the exp-pebble branch 2 times, most recently from 65cace4 to 1d689c5 Compare September 21, 2020 11:56
@holiman
Copy link
Contributor

holiman commented Nov 22, 2020

I rebased this and ran it on bench03 against master on bench04, in fast-sync. They both finished sync in roughly the same time (this PR 30 minutes faster).
After both are in sync:

root@bench03:/datadrive/geth/geth/chaindata# du . -h
167G	./ancient
292G	.
root@bench04:/datadrive/geth/geth/chaindata# du . -h
167G	./ancient
289G	.

So the pebble is only 3GB larger, a mere 1% difference.

Some charts (this PR is yellow)
Screenshot_2020-11-22 Dual Geth - Grafana

Screenshot_2020-11-22 Dual Geth - Grafana(1)

This PR on the right-hand side (and in this chart, this PR seems to be slower)
Screenshot_2020-11-22 Dual Geth - Grafana(2)

@holiman
Copy link
Contributor

holiman commented Nov 22, 2020

For the last 12 hours, the pebble machine has been using ~1.5GB less memory, so the comparisons aren't quite fair. We should give it a bit more memory.
Screenshot_2020-11-22 Dual Geth - Grafana(3)

@karalabe
Copy link
Member

So the pebble is only 3GB larger, a mere 1% difference.

That's 3%. Don't count the chain which lives outside of the database. Curious why out previous benchmarks got 20%+. Could you start a full sync perhaps?

@holiman
Copy link
Contributor

holiman commented Nov 23, 2020

@holiman
Copy link
Contributor

holiman commented Nov 24, 2020

It's been running a little more than one day now, and is consistently ~2GB lower in memory consumption

Screenshot_2020-11-24 Dual Geth - Grafana

However, it's also about 1hours behind on the blocks.

Size-wise
Pebble:

22G	./ancient
85G	.

Leveldb:

23G	./ancient
72G	.

So it's quite a hefty difference: 63G versus 49G.

@holiman
Copy link
Contributor

holiman commented Nov 27, 2020

Another update. Pebble is yellow, leveldb is green.

They're both roughly in the same area of blocks
Screenshot_2020-11-27 Dual Geth - Grafana(4)

But leveldb is ~6h ahead:

Screenshot_2020-11-27 Dual Geth - Grafana(5)

Pebbles consistently uses ~2Gb less memory:
Screenshot_2020-11-27 Dual Geth - Grafana(3)

Pebbble has done a lot less disk reads:

Screenshot_2020-11-27 Dual Geth - Grafana

But roughly the same amount of writes:

Screenshot_2020-11-27 Dual Geth - Grafana(1)

Disk-usage-wise, pebble has used 294Gb, and leveldb 240Gb, that's an extra 22.5%:

ubuntu@bench03:~$ sudo du -h /datadrive/geth/geth/chaindata
78G	/datadrive/geth/geth/chaindata/ancient
372G	/datadrive/geth/geth/chaindata
ubuntu@bench04:~$ sudo du -h /datadrive/geth/geth/chaindata
83G	/datadrive/geth/geth/chaindata/ancient
323G	/datadrive/geth/geth/chaindata

All in all, the benchmark doesn't seem very fair, since pebble is using 2G less memory.

Comment on lines +196 to +200
func (db *Database) NewBatch() ethdb.Batch {
return &batch{
b: db.db.NewBatch(),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Pebble batches should be Closed after use -- they are pooled internally, and Close put it back into the pool. This requires changes to our batch API.

// Pebble has a single combined cache area and the write
// buffers are taken from this too. Assign all available
// memory allowance for cache.
Cache: pebble.NewCache(int64(cache * 1024 * 1024)),
Copy link
Contributor

Choose a reason for hiding this comment

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

From pebble docs

// The cache is created with a
// reference count of 1. Each DB it is associated with adds a reference, so the
// creator of the cache should usually release their reference after the DB is
// created.
//
//   c := pebble.NewCache(...)
//   defer c.Unref()
//   d, err := pebble.Open(pebble.Options{Cache: c})

@holiman
Copy link
Contributor

holiman commented Apr 9, 2021

On a new sync, where I gave pebble a bit more cache, and had it run on 04 vs leveldb on 03, pebble was slightly faster Maybe 6 hours ahead after a week.
IT did considerably less disk reads
Screenshot_2021-04-09 Dual Geth - Grafana(1)
Here's the full 8 days:
Screenshot_2021-04-09 Dual Geth - Grafana(2)

@fjl
Copy link
Contributor

fjl commented Nov 4, 2021

We should probably try this another time.

@holiman
Copy link
Contributor

holiman commented Nov 4, 2021

We should probably try this another time.

Heh, I was looking at this PR only yesterday, thinking the exact same thing.

Apart from just "using" pebble, we could also use their delete-range operations. Currently, we do range-deletion "manually", and don't have in in the database interface (we just iterate and delete). We do make use of it pretty much though, particularly during snap sync.

ethdb/pebble: disable sync-style db write

ethdb/pebble: update configs

ethdb/pebble: fixes and tests

ethdb/pebble: update configs
@holiman
Copy link
Contributor

holiman commented Nov 19, 2021

Rebased on master, updated to latest pebble

@holiman
Copy link
Contributor

holiman commented Nov 23, 2021

Running again, this PR on bench01, master on bench02, both doing snap sync.

@fjl
Copy link
Contributor

fjl commented Apr 8, 2022

New version: #24615

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.

4 participants