Skip to content

Commit

Permalink
sql: dont read dbstat by default (#5067)
Browse files Browse the repository at this point in the history
this is debug information and can be enabled to be collected.
moreover reading dbstat frequently can interfere with other workloads.
  • Loading branch information
dshulyak committed Sep 25, 2023
1 parent be829f5 commit 4e48b60
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

See [RELEASE](./RELEASE.md) for workflow instructions.


## UNRELEASED

### Features

* [#5067](https://github.com/spacemeshos/go-spacemesh/pull/5067) dbstat virtual table can be read periodically to collect table/index sizes.

In order to enable provide following configuration:
```json
"main": {
"db-size-metering-interval": "10m"
}
```

### Improvements

## v1.1.8

### Improvements
Expand Down
34 changes: 18 additions & 16 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ type BaseConfig struct {
OptFilterThreshold int `mapstructure:"optimistic-filtering-threshold"`
TickSize uint64 `mapstructure:"tick-size"`

DatabaseConnections int `mapstructure:"db-connections"`
DatabaseLatencyMetering bool `mapstructure:"db-latency-metering"`
DatabaseConnections int `mapstructure:"db-connections"`
DatabaseLatencyMetering bool `mapstructure:"db-latency-metering"`
DatabaseSizeMeteringInterval time.Duration `mapstructure:"db-size-metering-interval"`

NetworkHRP string `mapstructure:"network-hrp"`

Expand Down Expand Up @@ -174,20 +175,21 @@ func DefaultTestConfig() Config {
// DefaultBaseConfig returns a default configuration for spacemesh.
func defaultBaseConfig() BaseConfig {
return BaseConfig{
DataDirParent: defaultDataDir,
FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"),
CollectMetrics: false,
MetricsPort: 1010,
ProfilerName: "gp-spacemesh",
LayerDuration: 30 * time.Second,
LayersPerEpoch: 3,
PoETServers: []string{"127.0.0.1"},
TxsPerProposal: 100,
BlockGasLimit: math.MaxUint64,
OptFilterThreshold: 90,
TickSize: 100,
DatabaseConnections: 16,
NetworkHRP: "sm",
DataDirParent: defaultDataDir,
FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"),
CollectMetrics: false,
MetricsPort: 1010,
ProfilerName: "gp-spacemesh",
LayerDuration: 30 * time.Second,
LayersPerEpoch: 3,
PoETServers: []string{"127.0.0.1"},
TxsPerProposal: 100,
BlockGasLimit: math.MaxUint64,
OptFilterThreshold: 90,
TickSize: 100,
DatabaseConnections: 16,
DatabaseSizeMeteringInterval: 10 * time.Minute,
NetworkHRP: "sm",
}
}

Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ func (app *App) setupDBs(ctx context.Context, lg log.Log, dbPath string) error {
return fmt.Errorf("open sqlite db %w", err)
}
app.db = sqlDB
if app.Config.CollectMetrics {
app.dbMetrics = dbmetrics.NewDBMetricsCollector(ctx, sqlDB, app.addLogger(StateDbLogger, lg), 5*time.Minute)
if app.Config.CollectMetrics && app.Config.DatabaseSizeMeteringInterval != 0 {
app.dbMetrics = dbmetrics.NewDBMetricsCollector(ctx, sqlDB, app.addLogger(StateDbLogger, lg), app.Config.DatabaseSizeMeteringInterval)
}
app.cachedDB = datastore.NewCachedDB(sqlDB, app.addLogger(CachedDBLogger, lg), datastore.WithConfig(app.Config.Cache))
return nil
Expand Down

0 comments on commit 4e48b60

Please sign in to comment.