Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Sep 30, 2024
1 parent 07136d3 commit 32f672e
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 @@ -21,10 +21,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 @@ -61,7 +57,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 @@ -236,7 +232,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 237 in db/pebble/db.go

View check run for this annotation

Codecov / codecov/patch

db/pebble/db.go#L235-L237

Added lines #L235 - L237 were not covered by tests
}
Expand All @@ -249,7 +245,7 @@ func (d *DB) onCompactionBegin(info pebble.CompactionInfo) {
d.activeComp++

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

View check run for this annotation

Codecov / codecov/patch

db/pebble/db.go#L245

Added line #L245 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 @@ -301,7 +297,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 32f672e

Please sign in to comment.