mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
no need cli
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
11cf3a677b
commit
27d9dc796a
2 changed files with 11 additions and 15 deletions
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -90,13 +89,7 @@ Remove blockchain and state databases`,
|
||||||
Action: inspect,
|
Action: inspect,
|
||||||
Name: "inspect",
|
Name: "inspect",
|
||||||
ArgsUsage: "<prefix> <start>",
|
ArgsUsage: "<prefix> <start>",
|
||||||
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags, []cli.Flag{
|
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
&cli.IntFlag{
|
|
||||||
Name: "workers",
|
|
||||||
Usage: "Number of parallel workers for database inspection",
|
|
||||||
Value: runtime.NumCPU(),
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
Usage: "Inspect the storage size for each type of data in the database",
|
Usage: "Inspect the storage size for each type of data in the database",
|
||||||
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
|
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
|
||||||
}
|
}
|
||||||
|
|
@ -336,8 +329,7 @@ func inspect(ctx *cli.Context) error {
|
||||||
db := utils.MakeChainDatabase(ctx, stack, true)
|
db := utils.MakeChainDatabase(ctx, stack, true)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
workers := ctx.Int("workers")
|
return rawdb.InspectDatabase(db, prefix, start)
|
||||||
return rawdb.InspectDatabase(db, prefix, start, workers)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkStateContent(ctx *cli.Context) error {
|
func checkStateContent(ctx *cli.Context) error {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"maps"
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -395,7 +396,7 @@ func (s *stat) GetCount() counter {
|
||||||
|
|
||||||
// InspectDatabase traverses the entire database and checks the size
|
// InspectDatabase traverses the entire database and checks the size
|
||||||
// of all different categories of data.
|
// of all different categories of data.
|
||||||
func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte, workers int) error {
|
func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
|
||||||
var (
|
var (
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
count atomic.Int64
|
count atomic.Int64
|
||||||
|
|
@ -550,7 +551,10 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte, workers int)
|
||||||
return it.Error()
|
return it.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
var eg errgroup.Group
|
var (
|
||||||
|
eg errgroup.Group
|
||||||
|
workers = runtime.NumCPU()
|
||||||
|
)
|
||||||
eg.SetLimit(workers)
|
eg.SetLimit(workers)
|
||||||
|
|
||||||
log.Info("Starting parallel database inspection", "workers", workers)
|
log.Info("Starting parallel database inspection", "workers", workers)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue