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

cmd/geth, ethdb/pebble: improve database statistic #29948

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func importChain(ctx *cli.Context) error {
fmt.Printf("Import done in %v.\n\n", time.Since(start))

// Output pre-compaction stats mostly to see the import trashing
showLeveldbStats(db)
showDBStats(db)

// Print the memory statistics used by the importing
mem := new(runtime.MemStats)
Expand All @@ -360,7 +360,7 @@ func importChain(ctx *cli.Context) error {
}
fmt.Printf("Compaction done in %v.\n\n", time.Since(start))

showLeveldbStats(db)
showDBStats(db)
return importErr
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func checkStateContent(ctx *cli.Context) error {
return nil
}

func showLeveldbStats(db ethdb.KeyValueStater) {
rjl493456442 marked this conversation as resolved.
Show resolved Hide resolved
func showDBStats(db ethdb.KeyValueStater) {
if stats, err := db.Stat("leveldb.stats"); err != nil {
log.Warn("Failed to read database stats", "error", err)
} else {
Expand All @@ -427,7 +427,7 @@ func dbStats(ctx *cli.Context) error {
db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close()

showLeveldbStats(db)
showDBStats(db)
return nil
}

Expand All @@ -439,15 +439,15 @@ func dbCompact(ctx *cli.Context) error {
defer db.Close()

log.Info("Stats before compaction")
showLeveldbStats(db)
showDBStats(db)

log.Info("Triggering compaction")
if err := db.Compact(nil, nil); err != nil {
log.Info("Compact err", "error", err)
return err
}
log.Info("Stats after compaction")
showLeveldbStats(db)
showDBStats(db)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion ethdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ 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.
// 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) {
Expand Down