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

Add more pebble database metrics collection #2187

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions cmd/juno/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func dbInfo(cmd *cobra.Command, args []string) error {
return nil
}

database, err := pebble.New(dbPath)
database, err := pebble.New(dbPath, false)
if err != nil {
return fmt.Errorf("open DB: %w", err)
}
Expand Down Expand Up @@ -125,7 +125,7 @@ func dbSize(cmd *cobra.Command, args []string) error {
return nil
}

pebbleDB, err := pebble.New(dbPath)
pebbleDB, err := pebble.New(dbPath, false)
if err != nil {
return err
}
Expand All @@ -145,7 +145,7 @@ func dbSize(cmd *cobra.Command, args []string) error {

for _, b := range db.BucketValues() {
fmt.Fprintf(cmd.OutOrStdout(), "Calculating size of %s, remaining buckets: %d\n", b, len(db.BucketValues())-int(b)-1)
bucketItem, err := pebble.CalculatePrefixSize(cmd.Context(), pebbleDB.(*pebble.DB), []byte{byte(b)})
bucketItem, err := pebble.CalculatePrefixSize(cmd.Context(), pebbleDB, []byte{byte(b)})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/juno/dbcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func executeCmdInDB(t *testing.T, cmd *cobra.Command) {
require.NoError(t, err)

dbPath := t.TempDir()
testDB, err := pebble.New(dbPath)
testDB, err := pebble.New(dbPath, false)
require.NoError(t, err)

chain := blockchain.New(testDB, &utils.Mainnet)
Expand Down
4 changes: 4 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package db

import (
"context"
"errors"
"fmt"
"io"
"os"
"time"

"github.com/NethermindEth/juno/utils"
)
Expand Down Expand Up @@ -33,6 +35,8 @@ type DB interface {

// WithListener registers an EventListener
WithListener(listener EventListener) DB

StartMetricsCollection(ctx context.Context, interval time.Duration)
}

// Iterator is an iterator over a DB's key/value pairs.
Expand Down
Loading