Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann authored and kirugan committed Oct 3, 2024
1 parent e5f6512 commit 156f0e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 5 additions & 8 deletions db/pebble/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ const (
// This is also pebble's default value.
minCacheSizeMB = 8

// metricsGatheringInterval specifies the interval to retrieve pebble database
// compaction, io and pause stats to report to the user.
metricsGatheringInterval = 3 * time.Second

// dbNamespace is the namespace for the database metrics
dbNamespace = "db"
)
Expand Down Expand Up @@ -66,7 +62,7 @@ type DB struct {

func New(path string, enableMetrics bool, options ...Option) (*DB, error) {
opts := &pebble.Options{
MaxConcurrentCompactions: func() int { return runtime.NumCPU() },
MaxConcurrentCompactions: runtime.NumCPU,
}

for _, option := range options {
Expand Down Expand Up @@ -241,7 +237,7 @@ func (d *DB) enableMetrics() db.DB {
return d
}

func (d *DB) onCompactionBegin(info pebble.CompactionInfo) {
func (d *DB) onCompactionBegin(info pebble.CompactionInfo) { //nolint:gocritic // Used by pebble's event listener
if d.activeComp == 0 {
d.compStartTime = time.Now()

Check warning on line 242 in db/pebble/db.go

View check run for this annotation

Codecov / codecov/patch

db/pebble/db.go#L240-L242

Added lines #L240 - L242 were not covered by tests
}
Expand All @@ -254,7 +250,7 @@ func (d *DB) onCompactionBegin(info pebble.CompactionInfo) {
d.activeComp++

Check warning on line 250 in db/pebble/db.go

View check run for this annotation

Codecov / codecov/patch

db/pebble/db.go#L250

Added line #L250 was not covered by tests
}

func (d *DB) onCompactionEnd(info pebble.CompactionInfo) {
func (d *DB) onCompactionEnd(info pebble.CompactionInfo) { //nolint:gocritic // Used by pebble's event listener
if d.activeComp == 1 {
d.compTime.Add(int64(time.Since(d.compStartTime)))
} else if d.activeComp == 0 {
Expand Down Expand Up @@ -306,7 +302,8 @@ func (d *DB) StartMetricsCollection(ctx context.Context, refresh time.Duration)
writeDelayCounts[i%2] = writeDelayCount
compTimes[i%2] = compTime

for _, levelMetrics := range metrics.Levels {
for j := range metrics.Levels {
levelMetrics := metrics.Levels[j]
nWrite += int64(levelMetrics.BytesCompacted)
nWrite += int64(levelMetrics.BytesFlushed)
compWrite += int64(levelMetrics.BytesCompacted)
Expand Down
13 changes: 8 additions & 5 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ import (
)

const (
upgraderDelay = 5 * time.Minute
metricsGatheringInterval = 3 * time.Second
githubAPIUrl = "https://api.github.com/repos/NethermindEth/juno/releases/latest"
latestReleaseURL = "https://github.com/NethermindEth/juno/releases/latest"
upgraderDelay = 5 * time.Minute

// metricsGatheringInterval specifies the interval to retrieve pebble database
// compaction, io and pause stats to report to the user.
dbMetricsGatheringInterval = 3 * time.Second
githubAPIUrl = "https://api.github.com/repos/NethermindEth/juno/releases/latest"
latestReleaseURL = "https://github.com/NethermindEth/juno/releases/latest"
)

// Config is the top-level juno configuration.
Expand Down Expand Up @@ -348,7 +351,7 @@ func (n *Node) Run(ctx context.Context) {

wg.Go(func() {
defer cancel()
n.db.StartMetricsCollection(ctx, metricsGatheringInterval)
n.db.StartMetricsCollection(ctx, dbMetricsGatheringInterval)
})
}

Expand Down

0 comments on commit 156f0e1

Please sign in to comment.