Skip to content

Commit

Permalink
[dbnode] Make caching after block retrieval a configuration option (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nbroyles authored Sep 17, 2020
1 parent 0ef7aba commit 3d2915f
Show file tree
Hide file tree
Showing 19 changed files with 446 additions and 171 deletions.
4 changes: 4 additions & 0 deletions src/cmd/services/m3dbnode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ type BlockRetrievePolicy struct {
// FetchConcurrency is the concurrency to fetch blocks from disk. For
// spinning disks it is highly recommended to set this value to 1.
FetchConcurrency int `yaml:"fetchConcurrency" validate:"min=0"`

// CacheBlocksOnRetrieve globally enables/disables callbacks used to cache blocks fetched
// from disk.
CacheBlocksOnRetrieve *bool `yaml:"cacheBlocksOnRetrieve"`
}

// CommitLogPolicy is the commit log policy.
Expand Down
19 changes: 11 additions & 8 deletions src/cmd/tools/dtest/docker/harness/resources/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
"github.com/m3db/m3/src/query/generated/proto/admin"
xerrors "github.com/m3db/m3/src/x/errors"
"github.com/m3db/m3/src/x/instrument"
dockertest "github.com/ory/dockertest"

protobuftypes "github.com/gogo/protobuf/types"
"github.com/ory/dockertest"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -150,13 +152,14 @@ func SetupSingleM3DBNode() (DockerResources, error) {
coldWriteNamespace = admin.NamespaceAddRequest{
Name: ColdWriteNsName,
Options: &namespace.NamespaceOptions{
BootstrapEnabled: true,
FlushEnabled: true,
WritesToCommitLog: true,
CleanupEnabled: true,
SnapshotEnabled: true,
RepairEnabled: true,
ColdWritesEnabled: true,
BootstrapEnabled: true,
FlushEnabled: true,
WritesToCommitLog: true,
CleanupEnabled: true,
SnapshotEnabled: true,
RepairEnabled: true,
ColdWritesEnabled: true,
CacheBlocksOnRetrieve: &protobuftypes.BoolValue{Value: true},
RetentionOptions: &namespace.RetentionOptions{
RetentionPeriodNanos: int64(4 * time.Hour),
BlockSizeNanos: int64(time.Hour),
Expand Down
179 changes: 118 additions & 61 deletions src/dbnode/generated/proto/namespace/namespace.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions src/dbnode/generated/proto/namespace/namespace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ message IndexOptions {
}

message NamespaceOptions {
bool bootstrapEnabled = 1;
bool flushEnabled = 2;
bool writesToCommitLog = 3;
bool cleanupEnabled = 4;
bool repairEnabled = 5;
RetentionOptions retentionOptions = 6;
bool snapshotEnabled = 7;
IndexOptions indexOptions = 8;
SchemaOptions schemaOptions = 9;
bool coldWritesEnabled = 10;
NamespaceRuntimeOptions runtimeOptions = 11;
bool bootstrapEnabled = 1;
bool flushEnabled = 2;
bool writesToCommitLog = 3;
bool cleanupEnabled = 4;
bool repairEnabled = 5;
RetentionOptions retentionOptions = 6;
bool snapshotEnabled = 7;
IndexOptions indexOptions = 8;
SchemaOptions schemaOptions = 9;
bool coldWritesEnabled = 10;
NamespaceRuntimeOptions runtimeOptions = 11;
google.protobuf.BoolValue cacheBlocksOnRetrieve = 12;
}

message Registry {
Expand Down
22 changes: 13 additions & 9 deletions src/dbnode/namespace/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ func (m *MapConfiguration) Map() (Map, error) {

// MetadataConfiguration is the configuration for a single namespace
type MetadataConfiguration struct {
ID string `yaml:"id" validate:"nonzero"`
BootstrapEnabled *bool `yaml:"bootstrapEnabled"`
FlushEnabled *bool `yaml:"flushEnabled"`
WritesToCommitLog *bool `yaml:"writesToCommitLog"`
CleanupEnabled *bool `yaml:"cleanupEnabled"`
RepairEnabled *bool `yaml:"repairEnabled"`
ColdWritesEnabled *bool `yaml:"coldWritesEnabled"`
Retention retention.Configuration `yaml:"retention" validate:"nonzero"`
Index IndexConfiguration `yaml:"index"`
ID string `yaml:"id" validate:"nonzero"`
BootstrapEnabled *bool `yaml:"bootstrapEnabled"`
FlushEnabled *bool `yaml:"flushEnabled"`
WritesToCommitLog *bool `yaml:"writesToCommitLog"`
CleanupEnabled *bool `yaml:"cleanupEnabled"`
RepairEnabled *bool `yaml:"repairEnabled"`
ColdWritesEnabled *bool `yaml:"coldWritesEnabled"`
CacheBlocksOnRetrieve *bool `yaml:"cacheBlocksOnRetrieve"`
Retention retention.Configuration `yaml:"retention" validate:"nonzero"`
Index IndexConfiguration `yaml:"index"`
}

// Metadata returns a Metadata corresponding to the receiver struct
Expand Down Expand Up @@ -84,6 +85,9 @@ func (mc *MetadataConfiguration) Metadata() (Metadata, error) {
if v := mc.ColdWritesEnabled; v != nil {
opts = opts.SetColdWritesEnabled(*v)
}
if v := mc.CacheBlocksOnRetrieve; v != nil {
opts = opts.SetCacheBlocksOnRetrieve(*v)
}
return NewMetadata(ident.StringID(mc.ID), opts)
}

Expand Down
Loading

0 comments on commit 3d2915f

Please sign in to comment.