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

[Merged by Bors] - sql: dont read dbstat by default #5067

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Support for old certificate sync protocol is dropped. This update is incompatibl
### Features

* [#5031](https://github.com/spacemeshos/go-spacemesh/pull/5031) Nodes will also fetch from PoET 112 for round 4 if they were able to register to PoET 110.
* [#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

Expand Down
38 changes: 20 additions & 18 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ 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"`
DatabasePruneInterval time.Duration `mapstructure:"db-prune-interval"`
DatabaseConnections int `mapstructure:"db-connections"`
DatabaseLatencyMetering bool `mapstructure:"db-latency-metering"`
DatabaseSizeMeteringInterval time.Duration `mapstructure:"db-size-metering-interval"`
DatabasePruneInterval time.Duration `mapstructure:"db-prune-interval"`

NetworkHRP string `mapstructure:"network-hrp"`

Expand Down Expand Up @@ -174,21 +175,22 @@ 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,
DatabasePruneInterval: 30 * time.Minute,
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,
DatabasePruneInterval: 30 * time.Minute,
NetworkHRP: "sm",
}
}

Expand Down
11 changes: 6 additions & 5 deletions config/presets/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func testnet() config.Config {
defaultdir := filepath.Join(home, "spacemesh-testnet", "/")
return config.Config{
BaseConfig: config.BaseConfig{
DataDirParent: defaultdir,
FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"),
MetricsPort: 1010,
DatabaseConnections: 16,
NetworkHRP: "stest",
DataDirParent: defaultdir,
FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"),
MetricsPort: 1010,
DatabaseConnections: 16,
DatabaseSizeMeteringInterval: 10 * time.Minute,
NetworkHRP: "stest",

LayerDuration: 5 * time.Minute,
LayerAvgSize: 50,
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,8 @@ func (app *App) setupDBs(ctx context.Context, lg log.Log) 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