mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
implement db stat for pebble
This commit is contained in:
parent
9c3cc83a03
commit
99569fd2d4
2 changed files with 16 additions and 5 deletions
|
|
@ -408,12 +408,12 @@ func checkStateContent(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func showDBStats(db ethdb.KeyValueStater) {
|
||||
if stats, err := db.Stat("leveldb.stats"); err != nil {
|
||||
if stats, err := db.Stat("stats"); err != nil {
|
||||
log.Warn("Failed to read database stats", "error", err)
|
||||
} else {
|
||||
fmt.Println(stats)
|
||||
}
|
||||
if ioStats, err := db.Stat("leveldb.iostats"); err != nil {
|
||||
if ioStats, err := db.Stat("iostats"); err != nil {
|
||||
log.Warn("Failed to read database iostats", "error", err)
|
||||
} else {
|
||||
fmt.Println(ioStats)
|
||||
|
|
|
|||
|
|
@ -417,10 +417,21 @@ func upperBound(prefix []byte) (limit []byte) {
|
|||
|
||||
// Stat returns the internal metrics of Pebble in a text format. It's a developer
|
||||
// method to read everything there is to read, independent of Pebble version.
|
||||
//
|
||||
// The property is unused in Pebble as there's only one thing to retrieve.
|
||||
func (d *Database) Stat(property string) (string, error) {
|
||||
return d.db.Metrics().String(), nil
|
||||
metrics := d.db.Metrics()
|
||||
if property == "iostats" {
|
||||
total := metrics.Total()
|
||||
return fmt.Sprintf("Read(MB):%.5f Write(MB):%.5f",
|
||||
float64(total.BytesRead)/1048576.0, // 1024*1024
|
||||
float64(total.BytesFlushed+total.BytesCompacted)/1048576.0), nil
|
||||
}
|
||||
if property == "disk.size" {
|
||||
return fmt.Sprintf("%d", metrics.Total().Size), nil
|
||||
}
|
||||
if property == "stats" {
|
||||
return metrics.String(), nil
|
||||
}
|
||||
return "", fmt.Errorf("pebble stat property %s does not exists", property)
|
||||
}
|
||||
|
||||
// Compact flattens the underlying data store for the given key range. In essence,
|
||||
|
|
|
|||
Loading…
Reference in a new issue