From a32c9f90d0a3b5df1fdd0bf60230f9508518773f Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 11:17:48 -0500 Subject: [PATCH 01/54] wip --- src/cmd/services/m3dbnode/config/pooling.go | 388 ++++++++++++++++-- .../services/m3dbnode/config/pooling_test.go | 84 ++-- src/dbnode/sharding/shardset_test.go | 8 + 3 files changed, 396 insertions(+), 84 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 5a467bb3a2..03bf5bda0f 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -36,6 +36,8 @@ const ( defaultPostingsListPoolSize = 16 ) +var () + // PoolingPolicy specifies the pooling policy. type PoolingPolicy struct { // The initial alloc size for a block. @@ -45,52 +47,52 @@ type PoolingPolicy struct { Type PoolingType `yaml:"type"` // The Bytes pool buckets to use. - BytesPool BucketPoolPolicy `yaml:"bytesPool"` + BytesPool BytesPool `yaml:"bytesPool"` // The policy for the Closers pool. - ClosersPool PoolPolicy `yaml:"closersPool"` + ClosersPool ClosersPool `yaml:"closersPool"` // The policy for the Context pool. ContextPool ContextPoolPolicy `yaml:"contextPool"` // The policy for the DatabaseSeries pool. - SeriesPool PoolPolicy `yaml:"seriesPool"` + SeriesPool SeriesPool `yaml:"seriesPool"` // The policy for the DatabaseBlock pool. - BlockPool PoolPolicy `yaml:"blockPool"` + BlockPool BlockPool `yaml:"blockPool"` // The policy for the Encoder pool. - EncoderPool PoolPolicy `yaml:"encoderPool"` + EncoderPool EncoderPool `yaml:"encoderPool"` // The policy for the Iterator pool. - IteratorPool PoolPolicy `yaml:"iteratorPool"` + IteratorPool IteratorPool `yaml:"iteratorPool"` // The policy for the Segment Reader pool. - SegmentReaderPool PoolPolicy `yaml:"segmentReaderPool"` + SegmentReaderPool SegmentReaderPool `yaml:"segmentReaderPool"` // The policy for the Identifier pool. - IdentifierPool PoolPolicy `yaml:"identifierPool"` + IdentifierPool IdentifierPool `yaml:"identifierPool"` // The policy for the FetchBlockMetadataResult pool. - FetchBlockMetadataResultsPool CapacityPoolPolicy `yaml:"fetchBlockMetadataResultsPool"` + FetchBlockMetadataResultsPool FetchBlockMetadataResultsPool `yaml:"fetchBlockMetadataResultsPool"` // The policy for the FetchBlocksMetadataResults pool. - FetchBlocksMetadataResultsPool CapacityPoolPolicy `yaml:"fetchBlocksMetadataResultsPool"` + FetchBlocksMetadataResultsPool FetchBlocksMetadataResultsPool `yaml:"fetchBlocksMetadataResultsPool"` // The policy for the HostBlockMetadataSlice pool. - HostBlockMetadataSlicePool CapacityPoolPolicy `yaml:"hostBlockMetadataSlicePool"` + HostBlockMetadataSlicePool HostBlockMetadataSlicePool `yaml:"hostBlockMetadataSlicePool"` // The policy for the BlockMetadat pool. - BlockMetadataPool PoolPolicy `yaml:"blockMetadataPool"` + BlockMetadataPool BlockMetadataPool `yaml:"blockMetadataPool"` // The policy for the BlockMetadataSlice pool. - BlockMetadataSlicePool CapacityPoolPolicy `yaml:"blockMetadataSlicePool"` + BlockMetadataSlicePool BlockMetadataSlicePool `yaml:"blockMetadataSlicePool"` // The policy for the BlocksMetadata pool. - BlocksMetadataPool PoolPolicy `yaml:"blocksMetadataPool"` + BlocksMetadataPool BlocksMetadataPool `yaml:"blocksMetadataPool"` // The policy for the BlocksMetadataSlice pool. - BlocksMetadataSlicePool CapacityPoolPolicy `yaml:"blocksMetadataSlicePool"` + BlocksMetadataSlicePool BlocksMetadataSlicePool `yaml:"blocksMetadataSlicePool"` // The policy for the tags pool. TagsPool MaxCapacityPoolPolicy `yaml:"tagsPool"` @@ -114,28 +116,45 @@ type PoolingPolicy struct { PostingsListPool PoolPolicy `yaml:"postingsListPool"` } -// PostingsListPoolPolicyWithDefaults returns the postings list pool policy -// and will set a sensible default size if not specified in the YAML -// configuration. -func (c PoolingPolicy) PostingsListPoolPolicyWithDefaults() PoolPolicy { - if c.PostingsListPool.Size > 0 { - return c.PostingsListPool - } - policy := c.PostingsListPool - policy.Size = defaultPostingsListPoolSize - return policy +// // PostingsListPoolPolicyWithDefaults returns the postings list pool policy +// // and will set a sensible default size if not specified in the YAML +// // configuration. +// func (c PoolingPolicy) PostingsListPoolPolicyWithDefaults() PoolPolicy { +// if c.PostingsListPool.Size != nil { +// return c.PostingsListPool +// } +// policy := c.PostingsListPool +// policy.Size = defaultPostingsListPoolSize +// return policy +// } + +// OptionalPoolPolicy specifies an optional pool policy. +type OptionalPoolPolicy struct { + // The size of the pool. + Size *int `yaml:"size"` + + // The low watermark to start refilling the pool, if zero none. + RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` + + // The high watermark to stop refilling the pool, if zero none. + RefillHighWaterMark *float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` } // PoolPolicy specifies a single pool policy. type PoolPolicy struct { // The size of the pool. - Size int `yaml:"size"` + Size *int `yaml:"size"` // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` + RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + RefillHighWaterMark *float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + + // Default values to be returned if the above values are not set. + defaultSize int + defaultRefillLowWaterMark float64 + defaultRefillHighWaterMark float64 } // CapacityPoolPolicy specifies a single pool policy that has a @@ -152,6 +171,12 @@ type CapacityPoolPolicy struct { // The high watermark to stop refilling the pool, if zero none. RefillHighWaterMark float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + + // Default values to be returned if the above values are not set. + defaultSize int + defaultCapacity int + defaultRefillLowWaterMark float64 + defaultRefillHighWaterMark float64 } // MaxCapacityPoolPolicy specifies a single pool policy that has a @@ -177,18 +202,14 @@ type MaxCapacityPoolPolicy struct { type BucketPoolPolicy struct { // The pool buckets sizes to use Buckets []CapacityPoolPolicy `yaml:"buckets"` + + // Default values to be returned if the above values are not set. + defaultBuckets []CapacityPoolPolicy } // ContextPoolPolicy specifies the policy for the context pool. type ContextPoolPolicy struct { - // The size of the pool - Size int `yaml:"size"` - - // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` - - // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + PoolPolicy `yaml:",inline"` // The maximum allowable size for a slice of finalizers that the // pool will allow to be returned (finalizer slices that grow too @@ -211,8 +232,9 @@ type WriteBatchPoolPolicy struct { Pool PoolPolicy `yaml:"pool"` } -// PoolPolicy returns the PoolPolicy that is represented by the ContextPoolPolicy. -func (c ContextPoolPolicy) PoolPolicy() PoolPolicy { +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ Size: c.Size, RefillLowWaterMark: c.RefillLowWaterMark, @@ -220,12 +242,298 @@ func (c ContextPoolPolicy) PoolPolicy() PoolPolicy { } } -// MaxFinalizerCapacityWithDefault returns the maximum finalizer capacity and +// MaxFinalizerCapacityOrDefault returns the maximum finalizer capacity and // fallsback to the default value if its not set. -func (c ContextPoolPolicy) MaxFinalizerCapacityWithDefault() int { +func (c ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { if c.MaxFinalizerCapacity == 0 { return defaultMaxFinalizerCapacity } return c.MaxFinalizerCapacity } + +// SeriesPool is the pool policy for the series pool. +type SeriesPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *SeriesPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// BlockPool is the pool policy for the block pool. +type BlockPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *BlockPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// EncoderPool is the pool policy for the encoder pool. +type EncoderPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *EncoderPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// ClosersPool is the pool policy for the closers pool. +type ClosersPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 104857, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// ContextPool is the pool policy for the context pool. +type ContextPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// SegmentReaderPool is the pool policy for the segment reader pool. +type SegmentReaderPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *SegmentReaderPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 16384, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// IteratorPool is the pool policy for the iterator pool. +type IteratorPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *IteratorPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 2048, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// FetchBlockMetadataResultsPool is the pool policy for the fetch block metadata results pool. +type FetchBlockMetadataResultsPool struct { + CapacityPoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *FetchBlockMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { + return CapacityPoolPolicy{ + Size: 65536, + Capacity: 32, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + } +} + +// FetchBlocksMetadataResultsPool is the pool policy for the fetch blocks metadata results pool. +type FetchBlocksMetadataResultsPool struct { + CapacityPoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *FetchBlocksMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { + return CapacityPoolPolicy{ + defaultSize: 32, + defaultCapacity: 4096, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// HostBlockMetadataSlicePool is the pool policy for the host block metadata slice pool. +type HostBlockMetadataSlicePool struct { + CapacityPoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *HostBlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { + return CapacityPoolPolicy{ + defaultSize: 131072, + defaultCapacity: 3, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// BlockMetadataPool is the pool policy for the block metadata pool. +type BlockMetadataPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *BlockMetadataPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 65536, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// BlockMetadataSlicePool is the pool policy for the block metadata slice pool. +type BlockMetadataSlicePool struct { + CapacityPoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *BlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { + return CapacityPoolPolicy{ + defaultSize: 65536, + defaultCapacity: 32, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// BlocksMetadataPool is the pool policy for the blocks metadata pool. +type BlocksMetadataPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *BlocksMetadataPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 65536, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// BlocksMetadataSlicePool is the pool policy for the blocks metadata slice pool. +type BlocksMetadataSlicePool struct { + CapacityPoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *BlocksMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { + return CapacityPoolPolicy{ + defaultSize: 32, + defaultCapacity: 4096, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// IdentifierPool is the pool policy for the identifier pool. +type IdentifierPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *IdentifierPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} + +// BytesPool is the pool policy for the bytes pool. +type BytesPool struct { + BucketPoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { + return BucketPoolPolicy{ + defaultBuckets: []CapacityPoolPolicy{ + { + Capacity: 16, + Size: 524288, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 32, + Size: 262144, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 64, + Size: 131072, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 128, + Size: 65536, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 256, + Size: 65536, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 1440, + Size: 16384, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 4096, + Size: 8192, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + }, + } +} diff --git a/src/cmd/services/m3dbnode/config/pooling_test.go b/src/cmd/services/m3dbnode/config/pooling_test.go index 86d3b4d311..6ab1f7193e 100644 --- a/src/cmd/services/m3dbnode/config/pooling_test.go +++ b/src/cmd/services/m3dbnode/config/pooling_test.go @@ -19,54 +19,50 @@ // THE SOFTWARE. package config -import ( - "testing" +// func TestContextPoolPolicyPoolPolicy(t *testing.T) { +// size := 10 +// refillLowWaterMark := 0.5 +// refillHighWaterMark := 0.7 +// cpp := ContextPoolPolicy{ +// PoolPolicy: PoolPolicy{ +// defaultSize: size, +// defaultRefillLowWaterMark: refillLowWaterMark, +// defaultRefillHighWaterMark: refillHighWaterMark, +// }, +// } - "github.com/stretchr/testify/require" -) +// require.Equal(t, PoolPolicy{ +// Size: size, +// RefillLowWaterMark: refillLowWaterMark, +// RefillHighWaterMark: refillHighWaterMark, +// }, cpp.PoolPolicyOrDefault()) +// } -func TestContextPoolPolicyPoolPolicy(t *testing.T) { - size := 10 - refillLowWaterMark := 0.5 - refillHighWaterMark := 0.7 - cpp := ContextPoolPolicy{ - Size: size, - RefillLowWaterMark: refillLowWaterMark, - RefillHighWaterMark: refillHighWaterMark, - } +// func TestContextPoolMaxFinalizerCapacityOrDefault(t *testing.T) { +// cpp := ContextPoolPolicy{ +// MaxFinalizerCapacity: 0, +// } +// require.Equal(t, defaultMaxFinalizerCapacity, cpp.MaxFinalizerCapacityOrDefault()) - require.Equal(t, PoolPolicy{ - Size: size, - RefillLowWaterMark: refillLowWaterMark, - RefillHighWaterMark: refillHighWaterMark, - }, cpp.PoolPolicy()) -} +// cpp.MaxFinalizerCapacity = 10 +// require.Equal(t, 10, cpp.MaxFinalizerCapacityOrDefault()) +// } -func TestContextPoolMaxFinalizerCapacityWithDefault(t *testing.T) { - cpp := ContextPoolPolicy{ - MaxFinalizerCapacity: 0, - } - require.Equal(t, defaultMaxFinalizerCapacity, cpp.MaxFinalizerCapacityWithDefault()) +// func TestPostingsPoolPolicyDefaultSize(t *testing.T) { +// policy := PoolingPolicy{ +// PostingsListPool: PoolPolicy{}, +// } - cpp.MaxFinalizerCapacity = 10 - require.Equal(t, 10, cpp.MaxFinalizerCapacityWithDefault()) -} +// parsed := policy.PostingsListPoolPolicyWithDefaults() +// require.Equal(t, defaultPostingsListPoolSize, parsed.Size) +// } -func TestPostingsPoolPolicyDefaultSize(t *testing.T) { - policy := PoolingPolicy{ - PostingsListPool: PoolPolicy{}, - } +// func TestPostingsPoolPolicyWithSize(t *testing.T) { +// defaultPlus1 := defaultPostingsListPoolSize + 1 +// policy := PoolingPolicy{ +// PostingsListPool: PoolPolicy{Size: defaultPlus1}, +// } - parsed := policy.PostingsListPoolPolicyWithDefaults() - require.Equal(t, defaultPostingsListPoolSize, parsed.Size) -} - -func TestPostingsPoolPolicyWithSize(t *testing.T) { - defaultPlus1 := defaultPostingsListPoolSize + 1 - policy := PoolingPolicy{ - PostingsListPool: PoolPolicy{Size: defaultPlus1}, - } - - parsed := policy.PostingsListPoolPolicyWithDefaults() - require.Equal(t, defaultPlus1, parsed.Size) -} +// parsed := policy.PostingsListPoolPolicyWithDefaults() +// require.Equal(t, defaultPlus1, parsed.Size) +// } diff --git a/src/dbnode/sharding/shardset_test.go b/src/dbnode/sharding/shardset_test.go index b2ef069e81..fc3480f8d4 100644 --- a/src/dbnode/sharding/shardset_test.go +++ b/src/dbnode/sharding/shardset_test.go @@ -21,6 +21,7 @@ package sharding import ( + "fmt" "testing" "github.com/m3db/m3/src/cluster/shard" @@ -29,6 +30,13 @@ import ( "github.com/stretchr/testify/require" ) +func TestYoloShard(t *testing.T) { + str := ident.StringID("stats.dca1.counts.m3+venue_aborted_ios+app=rider,app_version=3.335.10000,city_name=new_jersey,dc=dca1,env=prod,is_helix=true,os=ios,pipe=us1,service=superflurry,type=counter") + hash := DefaultHashFn(8184) + fmt.Println(hash(str)) + panic("yolo") +} + func TestShardSet(t *testing.T) { ss, err := NewShardSet( NewShards([]uint32{1, 1}, shard.Available), From f221c68b2b763629880b835e446c404fd0fa6c90 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:16:18 -0500 Subject: [PATCH 02/54] pooling passing --- src/cmd/services/m3dbnode/config/pooling.go | 76 ++++++++++------- src/cmd/services/m3dbnode/main/common_test.go | 1 - src/cmd/services/m3dbnode/main/main_test.go | 1 - src/dbnode/server/server.go | 82 +++++++++++++------ 4 files changed, 105 insertions(+), 55 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 03bf5bda0f..8045afb6d9 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -113,31 +113,7 @@ type PoolingPolicy struct { WriteBatchPool WriteBatchPoolPolicy `yaml:"writeBatchPool"` // The policy for the PostingsListPool. - PostingsListPool PoolPolicy `yaml:"postingsListPool"` -} - -// // PostingsListPoolPolicyWithDefaults returns the postings list pool policy -// // and will set a sensible default size if not specified in the YAML -// // configuration. -// func (c PoolingPolicy) PostingsListPoolPolicyWithDefaults() PoolPolicy { -// if c.PostingsListPool.Size != nil { -// return c.PostingsListPool -// } -// policy := c.PostingsListPool -// policy.Size = defaultPostingsListPoolSize -// return policy -// } - -// OptionalPoolPolicy specifies an optional pool policy. -type OptionalPoolPolicy struct { - // The size of the pool. - Size *int `yaml:"size"` - - // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` - - // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark *float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + PostingsListPool PostingsListPool `yaml:"postingsListPool"` } // PoolPolicy specifies a single pool policy. @@ -157,6 +133,35 @@ type PoolPolicy struct { defaultRefillHighWaterMark float64 } +// SizeOrDefault returns the configured size if present, or a default value otherwise. +func (p *PoolPolicy) SizeOrDefault() int { + if p.Size != nil { + return *p.Size + } + + return p.defaultSize +} + +// RefillLowWaterMarkOrDefault returns the configured refill low water mark if present, +// or a default value otherwise. +func (p *PoolPolicy) RefillLowWaterMarkOrDefault() float64 { + if p.RefillLowWaterMark != nil { + return *p.RefillLowWaterMark + } + + return p.defaultRefillLowWaterMark +} + +// RefillHighWaterMarkOrDefault returns the configured refill high water mark if present, +// or a default value otherwise. +func (p *PoolPolicy) RefillHighWaterMarkOrDefault() float64 { + if p.RefillHighWaterMark != nil { + return *p.RefillHighWaterMark + } + + return p.defaultRefillHighWaterMark +} + // CapacityPoolPolicy specifies a single pool policy that has a // per element capacity. type CapacityPoolPolicy struct { @@ -236,9 +241,9 @@ type WriteBatchPoolPolicy struct { // one is not provided. func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ - Size: c.Size, - RefillLowWaterMark: c.RefillLowWaterMark, - RefillHighWaterMark: c.RefillHighWaterMark, + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, } } @@ -537,3 +542,18 @@ func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { }, } } + +// PostingsListPool is the pool policy for the postings list pool. +type PostingsListPool struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 16, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + } +} diff --git a/src/cmd/services/m3dbnode/main/common_test.go b/src/cmd/services/m3dbnode/main/common_test.go index 178080ef83..49b4cb8acd 100644 --- a/src/cmd/services/m3dbnode/main/common_test.go +++ b/src/cmd/services/m3dbnode/main/common_test.go @@ -1,4 +1,3 @@ -// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 10e68061a4..8127e25334 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -1,4 +1,3 @@ -// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 19468e5839..9c5dc7dfa2 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -463,7 +463,7 @@ func Run(runOpts RunOptions) { // Set repair options hostBlockMetadataSlicePool := repair.NewHostBlockMetadataSlicePool( - capacityPoolOptions(policy.HostBlockMetadataSlicePool, + capacityPoolOptions(policy.HostBlockMetadataSlicePool.PoolPolicyOrDefault(), scope.SubScope("host-block-metadata-slice-pool")), policy.HostBlockMetadataSlicePool.Capacity) @@ -978,20 +978,38 @@ func withEncodingAndPoolingOptions( bytesPool.Init() segmentReaderPool := xio.NewSegmentReaderPool( - poolOptions(policy.SegmentReaderPool, scope.SubScope("segment-reader-pool"))) + poolOptions( + policy.SegmentReaderPool.PoolPolicyOrDefault(), + scope.SubScope("segment-reader-pool"))) segmentReaderPool.Init() + encoderPool := encoding.NewEncoderPool( - poolOptions(policy.EncoderPool, scope.SubScope("encoder-pool"))) - closersPoolOpts := poolOptions(policy.ClosersPool, scope.SubScope("closers-pool")) - contextPoolOpts := poolOptions(policy.ContextPool.PoolPolicy(), scope.SubScope("context-pool")) + poolOptions( + policy.EncoderPool.PoolPolicyOrDefault(), + scope.SubScope("encoder-pool"))) + + closersPoolOpts := poolOptions( + policy.ClosersPool.PoolPolicyOrDefault(), + scope.SubScope("closers-pool")) + + contextPoolOpts := poolOptions( + policy.ContextPool.PoolPolicyOrDefault(), + scope.SubScope("context-pool")) + contextPool := context.NewPool(context.NewOptions(). SetContextPoolOptions(contextPoolOpts). SetFinalizerPoolOptions(closersPoolOpts). - SetMaxPooledFinalizerCapacity(policy.ContextPool.MaxFinalizerCapacityWithDefault())) + SetMaxPooledFinalizerCapacity(policy.ContextPool.MaxFinalizerCapacityOrDefault())) + iteratorPool := encoding.NewReaderIteratorPool( - poolOptions(policy.IteratorPool, scope.SubScope("iterator-pool"))) + poolOptions( + policy.IteratorPool.PoolPolicyOrDefault(), + scope.SubScope("iterator-pool"))) + multiIteratorPool := encoding.NewMultiReaderIteratorPool( - poolOptions(policy.IteratorPool, scope.SubScope("multi-iterator-pool"))) + poolOptions( + policy.IteratorPool.PoolPolicyOrDefault(), + scope.SubScope("multi-iterator-pool"))) var writeBatchPoolInitialBatchSize *int if policy.WriteBatchPool.InitialBatchSize != nil { @@ -1009,15 +1027,17 @@ func withEncodingAndPoolingOptions( } writeBatchPoolPolicy := policy.WriteBatchPool.Pool - if writeBatchPoolPolicy.Size == 0 { + writeBatchPoolSize := writeBatchPoolPolicy.SizeOrDefault() + if writeBatchPoolSize == 0 { // If no value set, calculate a reasonabble value based on the commit log // queue size. We base it off the commitlog queue size because we will // want to be able to buffer at least one full commitlog queues worth of // writes without allocating because these objects are very expensive to // allocate. commitlogQueueSize := opts.CommitLogOptions().BacklogQueueSize() + // TODO: This seems wrong expectedBatchSize := *writeBatchPoolInitialBatchSize - writeBatchPoolPolicy.Size = commitlogQueueSize / expectedBatchSize + writeBatchPoolSize = commitlogQueueSize / expectedBatchSize } writeBatchPool := ts.NewWriteBatchPool( poolOptions(writeBatchPoolPolicy, scope.SubScope("write-batch-pool")), @@ -1025,7 +1045,8 @@ func withEncodingAndPoolingOptions( writeBatchPoolMaxBatchSize) identifierPool := ident.NewPool(bytesPool, ident.PoolOptions{ - IDPoolOptions: poolOptions(policy.IdentifierPool, scope.SubScope("identifier-pool")), + IDPoolOptions: poolOptions( + policy.IdentifierPool.PoolPolicyOrDefault(), scope.SubScope("identifier-pool")), TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), TagsCapacity: policy.TagsPool.Capacity, TagsMaxCapacity: policy.TagsPool.MaxCapacity, @@ -1033,12 +1054,12 @@ func withEncodingAndPoolingOptions( }) fetchBlockMetadataResultsPool := block.NewFetchBlockMetadataResultsPool( - capacityPoolOptions(policy.FetchBlockMetadataResultsPool, + capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicyOrDefault(), scope.SubScope("fetch-block-metadata-results-pool")), policy.FetchBlockMetadataResultsPool.Capacity) fetchBlocksMetadataResultsPool := block.NewFetchBlocksMetadataResultsPool( - capacityPoolOptions(policy.FetchBlocksMetadataResultsPool, + capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicyOrDefault(), scope.SubScope("fetch-blocks-metadata-results-pool")), policy.FetchBlocksMetadataResultsPool.Capacity) @@ -1099,8 +1120,10 @@ func withEncodingAndPoolingOptions( wiredList := block.NewWiredList(wiredListOpts) blockOpts = blockOpts.SetWiredList(wiredList) } - blockPool := block.NewDatabaseBlockPool(poolOptions(policy.BlockPool, - scope.SubScope("block-pool"))) + blockPool := block.NewDatabaseBlockPool( + poolOptions( + policy.BlockPool.PoolPolicyOrDefault(), + scope.SubScope("block-pool"))) blockPool.Init(func() block.DatabaseBlock { return block.NewDatabaseBlock(time.Time{}, 0, ts.Segment{}, blockOpts) }) @@ -1112,7 +1135,9 @@ func withEncodingAndPoolingOptions( seriesOpts := storage.NewSeriesOptionsFromOptions(opts, retentionOpts). SetFetchBlockMetadataResultsPool(opts.FetchBlockMetadataResultsPool()) seriesPool := series.NewDatabaseSeriesPool( - poolOptions(policy.SeriesPool, scope.SubScope("series-pool"))) + poolOptions( + policy.SeriesPool.PoolPolicyOrDefault(), + scope.SubScope("series-pool"))) opts = opts. SetSeriesOptions(seriesOpts). @@ -1123,7 +1148,8 @@ func withEncodingAndPoolingOptions( resultsPool := index.NewResultsPool(poolOptions(policy.IndexResultsPool, scope.SubScope("index-results-pool"))) - postingsListOpts := poolOptions(policy.PostingsListPoolPolicyWithDefaults(), + postingsListOpts := poolOptions( + policy.PostingsListPool.PoolPolicyOrDefault(), scope.SubScope("postingslist-pool")) postingsList := postings.NewPool(postingsListOpts, roaring.NewPostingsList) indexOpts := opts.IndexOptions(). @@ -1151,14 +1177,20 @@ func poolOptions( policy config.PoolPolicy, scope tally.Scope, ) pool.ObjectPoolOptions { - opts := pool.NewObjectPoolOptions() - if policy.Size > 0 { - opts = opts.SetSize(policy.Size) - if policy.RefillLowWaterMark > 0 && - policy.RefillHighWaterMark > 0 && - policy.RefillHighWaterMark > policy.RefillLowWaterMark { - opts = opts.SetRefillLowWatermark(policy.RefillLowWaterMark) - opts = opts.SetRefillHighWatermark(policy.RefillHighWaterMark) + var ( + opts = pool.NewObjectPoolOptions() + size = policy.SizeOrDefault() + refillLowWaterMark = policy.RefillLowWaterMarkOrDefault() + refillHighWaterMark = policy.RefillHighWaterMarkOrDefault() + ) + + if size > 0 { + opts = opts.SetSize(size) + if refillLowWaterMark > 0 && + refillHighWaterMark > 0 && + refillHighWaterMark > refillLowWaterMark { + opts = opts.SetRefillLowWatermark(refillLowWaterMark) + opts = opts.SetRefillHighWatermark(refillHighWaterMark) } } if scope != nil { From 108904f8bae8f6448f1c9bd0bc0a47877feef383 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:19:48 -0500 Subject: [PATCH 03/54] delete test yolo shard --- src/dbnode/sharding/shardset_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/dbnode/sharding/shardset_test.go b/src/dbnode/sharding/shardset_test.go index fc3480f8d4..b2ef069e81 100644 --- a/src/dbnode/sharding/shardset_test.go +++ b/src/dbnode/sharding/shardset_test.go @@ -21,7 +21,6 @@ package sharding import ( - "fmt" "testing" "github.com/m3db/m3/src/cluster/shard" @@ -30,13 +29,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestYoloShard(t *testing.T) { - str := ident.StringID("stats.dca1.counts.m3+venue_aborted_ios+app=rider,app_version=3.335.10000,city_name=new_jersey,dc=dca1,env=prod,is_helix=true,os=ios,pipe=us1,service=superflurry,type=counter") - hash := DefaultHashFn(8184) - fmt.Println(hash(str)) - panic("yolo") -} - func TestShardSet(t *testing.T) { ss, err := NewShardSet( NewShards([]uint32{1, 1}, shard.Available), From 55a4eecb59e1d59e3749d888e7679364e57f01cb Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:21:16 -0500 Subject: [PATCH 04/54] rename method --- src/cmd/services/m3dbnode/config/pooling.go | 72 ++++++++++----------- src/dbnode/server/server.go | 26 ++++---- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 8045afb6d9..8e04e2a67c 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -237,9 +237,9 @@ type WriteBatchPoolPolicy struct { Pool PoolPolicy `yaml:"pool"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { +func (c ContextPoolPolicy) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -262,9 +262,9 @@ type SeriesPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *SeriesPool) PoolPolicyOrDefault() PoolPolicy { +func (p *SeriesPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -277,9 +277,9 @@ type BlockPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *BlockPool) PoolPolicyOrDefault() PoolPolicy { +func (p *BlockPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -292,9 +292,9 @@ type EncoderPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *EncoderPool) PoolPolicyOrDefault() PoolPolicy { +func (p *EncoderPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -307,9 +307,9 @@ type ClosersPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { +func (p *ClosersPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 104857, defaultRefillLowWaterMark: 0.7, @@ -322,9 +322,9 @@ type ContextPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { +func (p *ContextPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -337,9 +337,9 @@ type SegmentReaderPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *SegmentReaderPool) PoolPolicyOrDefault() PoolPolicy { +func (p *SegmentReaderPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 16384, defaultRefillLowWaterMark: 0.7, @@ -352,9 +352,9 @@ type IteratorPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *IteratorPool) PoolPolicyOrDefault() PoolPolicy { +func (p *IteratorPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 2048, defaultRefillLowWaterMark: 0.7, @@ -367,9 +367,9 @@ type FetchBlockMetadataResultsPool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *FetchBlockMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { +func (p *FetchBlockMetadataResultsPool) PoolPolicy() CapacityPoolPolicy { return CapacityPoolPolicy{ Size: 65536, Capacity: 32, @@ -383,9 +383,9 @@ type FetchBlocksMetadataResultsPool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *FetchBlocksMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { +func (p *FetchBlocksMetadataResultsPool) PoolPolicy() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 32, defaultCapacity: 4096, @@ -399,9 +399,9 @@ type HostBlockMetadataSlicePool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *HostBlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { +func (p *HostBlockMetadataSlicePool) PoolPolicy() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 131072, defaultCapacity: 3, @@ -415,9 +415,9 @@ type BlockMetadataPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *BlockMetadataPool) PoolPolicyOrDefault() PoolPolicy { +func (p *BlockMetadataPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 65536, defaultRefillLowWaterMark: 0.7, @@ -430,9 +430,9 @@ type BlockMetadataSlicePool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *BlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { +func (p *BlockMetadataSlicePool) PoolPolicy() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 65536, defaultCapacity: 32, @@ -446,9 +446,9 @@ type BlocksMetadataPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *BlocksMetadataPool) PoolPolicyOrDefault() PoolPolicy { +func (p *BlocksMetadataPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 65536, defaultRefillLowWaterMark: 0.7, @@ -461,9 +461,9 @@ type BlocksMetadataSlicePool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *BlocksMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { +func (p *BlocksMetadataSlicePool) PoolPolicy() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 32, defaultCapacity: 4096, @@ -477,9 +477,9 @@ type IdentifierPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *IdentifierPool) PoolPolicyOrDefault() PoolPolicy { +func (p *IdentifierPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -492,9 +492,9 @@ type BytesPool struct { BucketPoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { +func (p *BytesPool) PoolPolicy() BucketPoolPolicy { return BucketPoolPolicy{ defaultBuckets: []CapacityPoolPolicy{ { @@ -548,9 +548,9 @@ type PostingsListPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// PoolPolicy returns the provided pool policy, or a default value if // one is not provided. -func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { +func (p *PostingsListPool) PoolPolicy() PoolPolicy { return PoolPolicy{ defaultSize: 16, defaultRefillLowWaterMark: 0.7, diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 9c5dc7dfa2..5d27ea4867 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -463,7 +463,7 @@ func Run(runOpts RunOptions) { // Set repair options hostBlockMetadataSlicePool := repair.NewHostBlockMetadataSlicePool( - capacityPoolOptions(policy.HostBlockMetadataSlicePool.PoolPolicyOrDefault(), + capacityPoolOptions(policy.HostBlockMetadataSlicePool.PoolPolicy(), scope.SubScope("host-block-metadata-slice-pool")), policy.HostBlockMetadataSlicePool.Capacity) @@ -979,21 +979,21 @@ func withEncodingAndPoolingOptions( segmentReaderPool := xio.NewSegmentReaderPool( poolOptions( - policy.SegmentReaderPool.PoolPolicyOrDefault(), + policy.SegmentReaderPool.PoolPolicy(), scope.SubScope("segment-reader-pool"))) segmentReaderPool.Init() encoderPool := encoding.NewEncoderPool( poolOptions( - policy.EncoderPool.PoolPolicyOrDefault(), + policy.EncoderPool.PoolPolicy(), scope.SubScope("encoder-pool"))) closersPoolOpts := poolOptions( - policy.ClosersPool.PoolPolicyOrDefault(), + policy.ClosersPool.PoolPolicy(), scope.SubScope("closers-pool")) contextPoolOpts := poolOptions( - policy.ContextPool.PoolPolicyOrDefault(), + policy.ContextPool.PoolPolicy(), scope.SubScope("context-pool")) contextPool := context.NewPool(context.NewOptions(). @@ -1003,12 +1003,12 @@ func withEncodingAndPoolingOptions( iteratorPool := encoding.NewReaderIteratorPool( poolOptions( - policy.IteratorPool.PoolPolicyOrDefault(), + policy.IteratorPool.PoolPolicy(), scope.SubScope("iterator-pool"))) multiIteratorPool := encoding.NewMultiReaderIteratorPool( poolOptions( - policy.IteratorPool.PoolPolicyOrDefault(), + policy.IteratorPool.PoolPolicy(), scope.SubScope("multi-iterator-pool"))) var writeBatchPoolInitialBatchSize *int @@ -1046,7 +1046,7 @@ func withEncodingAndPoolingOptions( identifierPool := ident.NewPool(bytesPool, ident.PoolOptions{ IDPoolOptions: poolOptions( - policy.IdentifierPool.PoolPolicyOrDefault(), scope.SubScope("identifier-pool")), + policy.IdentifierPool.PoolPolicy(), scope.SubScope("identifier-pool")), TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), TagsCapacity: policy.TagsPool.Capacity, TagsMaxCapacity: policy.TagsPool.MaxCapacity, @@ -1054,12 +1054,12 @@ func withEncodingAndPoolingOptions( }) fetchBlockMetadataResultsPool := block.NewFetchBlockMetadataResultsPool( - capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicyOrDefault(), + capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicy(), scope.SubScope("fetch-block-metadata-results-pool")), policy.FetchBlockMetadataResultsPool.Capacity) fetchBlocksMetadataResultsPool := block.NewFetchBlocksMetadataResultsPool( - capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicyOrDefault(), + capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicy(), scope.SubScope("fetch-blocks-metadata-results-pool")), policy.FetchBlocksMetadataResultsPool.Capacity) @@ -1122,7 +1122,7 @@ func withEncodingAndPoolingOptions( } blockPool := block.NewDatabaseBlockPool( poolOptions( - policy.BlockPool.PoolPolicyOrDefault(), + policy.BlockPool.PoolPolicy(), scope.SubScope("block-pool"))) blockPool.Init(func() block.DatabaseBlock { return block.NewDatabaseBlock(time.Time{}, 0, ts.Segment{}, blockOpts) @@ -1136,7 +1136,7 @@ func withEncodingAndPoolingOptions( SetFetchBlockMetadataResultsPool(opts.FetchBlockMetadataResultsPool()) seriesPool := series.NewDatabaseSeriesPool( poolOptions( - policy.SeriesPool.PoolPolicyOrDefault(), + policy.SeriesPool.PoolPolicy(), scope.SubScope("series-pool"))) opts = opts. @@ -1149,7 +1149,7 @@ func withEncodingAndPoolingOptions( resultsPool := index.NewResultsPool(poolOptions(policy.IndexResultsPool, scope.SubScope("index-results-pool"))) postingsListOpts := poolOptions( - policy.PostingsListPool.PoolPolicyOrDefault(), + policy.PostingsListPool.PoolPolicy(), scope.SubScope("postingslist-pool")) postingsList := postings.NewPool(postingsListOpts, roaring.NewPostingsList) indexOpts := opts.IndexOptions(). From 6f186e5e0f758f0de000623723a5062fe99804eb Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:22:04 -0500 Subject: [PATCH 05/54] Revert "rename method" This reverts commit 61f2c669587373e658cea22f83a803ec4a62ba63. --- src/cmd/services/m3dbnode/config/pooling.go | 72 ++++++++++----------- src/dbnode/server/server.go | 26 ++++---- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 8e04e2a67c..8045afb6d9 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -237,9 +237,9 @@ type WriteBatchPoolPolicy struct { Pool PoolPolicy `yaml:"pool"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (c ContextPoolPolicy) PoolPolicy() PoolPolicy { +func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -262,9 +262,9 @@ type SeriesPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *SeriesPool) PoolPolicy() PoolPolicy { +func (p *SeriesPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -277,9 +277,9 @@ type BlockPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *BlockPool) PoolPolicy() PoolPolicy { +func (p *BlockPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -292,9 +292,9 @@ type EncoderPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *EncoderPool) PoolPolicy() PoolPolicy { +func (p *EncoderPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -307,9 +307,9 @@ type ClosersPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *ClosersPool) PoolPolicy() PoolPolicy { +func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 104857, defaultRefillLowWaterMark: 0.7, @@ -322,9 +322,9 @@ type ContextPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *ContextPool) PoolPolicy() PoolPolicy { +func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -337,9 +337,9 @@ type SegmentReaderPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *SegmentReaderPool) PoolPolicy() PoolPolicy { +func (p *SegmentReaderPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 16384, defaultRefillLowWaterMark: 0.7, @@ -352,9 +352,9 @@ type IteratorPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *IteratorPool) PoolPolicy() PoolPolicy { +func (p *IteratorPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 2048, defaultRefillLowWaterMark: 0.7, @@ -367,9 +367,9 @@ type FetchBlockMetadataResultsPool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *FetchBlockMetadataResultsPool) PoolPolicy() CapacityPoolPolicy { +func (p *FetchBlockMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { return CapacityPoolPolicy{ Size: 65536, Capacity: 32, @@ -383,9 +383,9 @@ type FetchBlocksMetadataResultsPool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *FetchBlocksMetadataResultsPool) PoolPolicy() CapacityPoolPolicy { +func (p *FetchBlocksMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 32, defaultCapacity: 4096, @@ -399,9 +399,9 @@ type HostBlockMetadataSlicePool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *HostBlockMetadataSlicePool) PoolPolicy() CapacityPoolPolicy { +func (p *HostBlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 131072, defaultCapacity: 3, @@ -415,9 +415,9 @@ type BlockMetadataPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *BlockMetadataPool) PoolPolicy() PoolPolicy { +func (p *BlockMetadataPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 65536, defaultRefillLowWaterMark: 0.7, @@ -430,9 +430,9 @@ type BlockMetadataSlicePool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *BlockMetadataSlicePool) PoolPolicy() CapacityPoolPolicy { +func (p *BlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 65536, defaultCapacity: 32, @@ -446,9 +446,9 @@ type BlocksMetadataPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *BlocksMetadataPool) PoolPolicy() PoolPolicy { +func (p *BlocksMetadataPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 65536, defaultRefillLowWaterMark: 0.7, @@ -461,9 +461,9 @@ type BlocksMetadataSlicePool struct { CapacityPoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *BlocksMetadataSlicePool) PoolPolicy() CapacityPoolPolicy { +func (p *BlocksMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { return CapacityPoolPolicy{ defaultSize: 32, defaultCapacity: 4096, @@ -477,9 +477,9 @@ type IdentifierPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *IdentifierPool) PoolPolicy() PoolPolicy { +func (p *IdentifierPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 262144, defaultRefillLowWaterMark: 0.7, @@ -492,9 +492,9 @@ type BytesPool struct { BucketPoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *BytesPool) PoolPolicy() BucketPoolPolicy { +func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { return BucketPoolPolicy{ defaultBuckets: []CapacityPoolPolicy{ { @@ -548,9 +548,9 @@ type PostingsListPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicy returns the provided pool policy, or a default value if +// PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *PostingsListPool) PoolPolicy() PoolPolicy { +func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { return PoolPolicy{ defaultSize: 16, defaultRefillLowWaterMark: 0.7, diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 5d27ea4867..9c5dc7dfa2 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -463,7 +463,7 @@ func Run(runOpts RunOptions) { // Set repair options hostBlockMetadataSlicePool := repair.NewHostBlockMetadataSlicePool( - capacityPoolOptions(policy.HostBlockMetadataSlicePool.PoolPolicy(), + capacityPoolOptions(policy.HostBlockMetadataSlicePool.PoolPolicyOrDefault(), scope.SubScope("host-block-metadata-slice-pool")), policy.HostBlockMetadataSlicePool.Capacity) @@ -979,21 +979,21 @@ func withEncodingAndPoolingOptions( segmentReaderPool := xio.NewSegmentReaderPool( poolOptions( - policy.SegmentReaderPool.PoolPolicy(), + policy.SegmentReaderPool.PoolPolicyOrDefault(), scope.SubScope("segment-reader-pool"))) segmentReaderPool.Init() encoderPool := encoding.NewEncoderPool( poolOptions( - policy.EncoderPool.PoolPolicy(), + policy.EncoderPool.PoolPolicyOrDefault(), scope.SubScope("encoder-pool"))) closersPoolOpts := poolOptions( - policy.ClosersPool.PoolPolicy(), + policy.ClosersPool.PoolPolicyOrDefault(), scope.SubScope("closers-pool")) contextPoolOpts := poolOptions( - policy.ContextPool.PoolPolicy(), + policy.ContextPool.PoolPolicyOrDefault(), scope.SubScope("context-pool")) contextPool := context.NewPool(context.NewOptions(). @@ -1003,12 +1003,12 @@ func withEncodingAndPoolingOptions( iteratorPool := encoding.NewReaderIteratorPool( poolOptions( - policy.IteratorPool.PoolPolicy(), + policy.IteratorPool.PoolPolicyOrDefault(), scope.SubScope("iterator-pool"))) multiIteratorPool := encoding.NewMultiReaderIteratorPool( poolOptions( - policy.IteratorPool.PoolPolicy(), + policy.IteratorPool.PoolPolicyOrDefault(), scope.SubScope("multi-iterator-pool"))) var writeBatchPoolInitialBatchSize *int @@ -1046,7 +1046,7 @@ func withEncodingAndPoolingOptions( identifierPool := ident.NewPool(bytesPool, ident.PoolOptions{ IDPoolOptions: poolOptions( - policy.IdentifierPool.PoolPolicy(), scope.SubScope("identifier-pool")), + policy.IdentifierPool.PoolPolicyOrDefault(), scope.SubScope("identifier-pool")), TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), TagsCapacity: policy.TagsPool.Capacity, TagsMaxCapacity: policy.TagsPool.MaxCapacity, @@ -1054,12 +1054,12 @@ func withEncodingAndPoolingOptions( }) fetchBlockMetadataResultsPool := block.NewFetchBlockMetadataResultsPool( - capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicy(), + capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicyOrDefault(), scope.SubScope("fetch-block-metadata-results-pool")), policy.FetchBlockMetadataResultsPool.Capacity) fetchBlocksMetadataResultsPool := block.NewFetchBlocksMetadataResultsPool( - capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicy(), + capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicyOrDefault(), scope.SubScope("fetch-blocks-metadata-results-pool")), policy.FetchBlocksMetadataResultsPool.Capacity) @@ -1122,7 +1122,7 @@ func withEncodingAndPoolingOptions( } blockPool := block.NewDatabaseBlockPool( poolOptions( - policy.BlockPool.PoolPolicy(), + policy.BlockPool.PoolPolicyOrDefault(), scope.SubScope("block-pool"))) blockPool.Init(func() block.DatabaseBlock { return block.NewDatabaseBlock(time.Time{}, 0, ts.Segment{}, blockOpts) @@ -1136,7 +1136,7 @@ func withEncodingAndPoolingOptions( SetFetchBlockMetadataResultsPool(opts.FetchBlockMetadataResultsPool()) seriesPool := series.NewDatabaseSeriesPool( poolOptions( - policy.SeriesPool.PoolPolicy(), + policy.SeriesPool.PoolPolicyOrDefault(), scope.SubScope("series-pool"))) opts = opts. @@ -1149,7 +1149,7 @@ func withEncodingAndPoolingOptions( resultsPool := index.NewResultsPool(poolOptions(policy.IndexResultsPool, scope.SubScope("index-results-pool"))) postingsListOpts := poolOptions( - policy.PostingsListPool.PoolPolicy(), + policy.PostingsListPool.PoolPolicyOrDefault(), scope.SubScope("postingslist-pool")) postingsList := postings.NewPool(postingsListOpts, roaring.NewPostingsList) indexOpts := opts.IndexOptions(). From 41b8fb028a5601e7a0f20caef4b24b00df309844 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:26:36 -0500 Subject: [PATCH 06/54] Add default pool policy --- src/cmd/services/m3dbnode/config/pooling.go | 45 ++++++++++++++------- src/dbnode/server/server.go | 26 ++++++++---- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 8045afb6d9..6873262ce4 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -98,16 +98,16 @@ type PoolingPolicy struct { TagsPool MaxCapacityPoolPolicy `yaml:"tagsPool"` // The policy for the tags iterator pool. - TagsIteratorPool PoolPolicy `yaml:"tagIteratorPool"` + TagsIteratorPool DefaultPoolPolicy `yaml:"tagIteratorPool"` // The policy for the index.ResultsPool. - IndexResultsPool PoolPolicy `yaml:"indexResultsPool"` + IndexResultsPool DefaultPoolPolicy `yaml:"indexResultsPool"` // The policy for the TagEncoderPool. - TagEncoderPool PoolPolicy `yaml:"tagEncoderPool"` + TagEncoderPool DefaultPoolPolicy `yaml:"tagEncoderPool"` // The policy for the TagDecoderPool. - TagDecoderPool PoolPolicy `yaml:"tagDecoderPool"` + TagDecoderPool DefaultPoolPolicy `yaml:"tagDecoderPool"` // The policy for the WriteBatchPool. WriteBatchPool WriteBatchPoolPolicy `yaml:"writeBatchPool"` @@ -212,17 +212,6 @@ type BucketPoolPolicy struct { defaultBuckets []CapacityPoolPolicy } -// ContextPoolPolicy specifies the policy for the context pool. -type ContextPoolPolicy struct { - PoolPolicy `yaml:",inline"` - - // The maximum allowable size for a slice of finalizers that the - // pool will allow to be returned (finalizer slices that grow too - // large during use will be discarded instead of returning to the - // pool where they would consume more memory.) - MaxFinalizerCapacity int `yaml:"maxFinalizerCapacity" validate:"min=0"` -} - // WriteBatchPoolPolicy specifies the pooling policy for the WriteBatch pool. type WriteBatchPoolPolicy struct { // InitialBatchSize controls the initial batch size for each WriteBatch when @@ -237,6 +226,17 @@ type WriteBatchPoolPolicy struct { Pool PoolPolicy `yaml:"pool"` } +// ContextPoolPolicy specifies the policy for the context pool. +type ContextPoolPolicy struct { + PoolPolicy `yaml:",inline"` + + // The maximum allowable size for a slice of finalizers that the + // pool will allow to be returned (finalizer slices that grow too + // large during use will be discarded instead of returning to the + // pool where they would consume more memory.) + MaxFinalizerCapacity int `yaml:"maxFinalizerCapacity" validate:"min=0"` +} + // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { @@ -257,6 +257,21 @@ func (c ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { return c.MaxFinalizerCapacity } +// DefaultPoolPolicy is the default pool policy. +type DefaultPoolPolicy struct { + PoolPolicy `yaml:",inline"` +} + +// PoolPolicyOrDefault returns the provided pool policy, or a default value if +// one is not provided. +func (p *DefaultPoolPolicy) PoolPolicyOrDefault() PoolPolicy { + return PoolPolicy{ + defaultSize: 4096, + defaultRefillLowWaterMark: 0.0, + defaultRefillHighWaterMark: 0.0, + } +} + // SeriesPool is the pool policy for the series pool. type SeriesPool struct { PoolPolicy `yaml:",inline"` diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 9c5dc7dfa2..f3e6604d6d 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -292,11 +292,15 @@ func Run(runOpts RunOptions) { policy := cfg.PoolingPolicy tagEncoderPool := serialize.NewTagEncoderPool( serialize.NewTagEncoderOptions(), - poolOptions(policy.TagEncoderPool, scope.SubScope("tag-encoder-pool"))) + poolOptions( + policy.TagEncoderPool.PoolPolicyOrDefault(), + scope.SubScope("tag-encoder-pool"))) tagEncoderPool.Init() tagDecoderPool := serialize.NewTagDecoderPool( serialize.NewTagDecoderOptions(), - poolOptions(policy.TagDecoderPool, scope.SubScope("tag-decoder-pool"))) + poolOptions( + policy.TagDecoderPool.PoolPolicyOrDefault(), + scope.SubScope("tag-decoder-pool"))) tagDecoderPool.Init() fsopts := fs.NewOptions(). @@ -1047,10 +1051,12 @@ func withEncodingAndPoolingOptions( identifierPool := ident.NewPool(bytesPool, ident.PoolOptions{ IDPoolOptions: poolOptions( policy.IdentifierPool.PoolPolicyOrDefault(), scope.SubScope("identifier-pool")), - TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), - TagsCapacity: policy.TagsPool.Capacity, - TagsMaxCapacity: policy.TagsPool.MaxCapacity, - TagsIteratorPoolOptions: poolOptions(policy.TagsIteratorPool, scope.SubScope("tags-iterator-pool")), + TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), + TagsCapacity: policy.TagsPool.Capacity, + TagsMaxCapacity: policy.TagsPool.MaxCapacity, + TagsIteratorPoolOptions: poolOptions( + policy.TagsIteratorPool.PoolPolicyOrDefault(), + scope.SubScope("tags-iterator-pool")), }) fetchBlockMetadataResultsPool := block.NewFetchBlockMetadataResultsPool( @@ -1146,12 +1152,16 @@ func withEncodingAndPoolingOptions( SetBytesPool(bytesPool). SetIdentifierPool(identifierPool)) - resultsPool := index.NewResultsPool(poolOptions(policy.IndexResultsPool, - scope.SubScope("index-results-pool"))) + resultsPool := index.NewResultsPool( + poolOptions( + policy.IndexResultsPool.PoolPolicyOrDefault(), + scope.SubScope("index-results-pool"))) + postingsListOpts := poolOptions( policy.PostingsListPool.PoolPolicyOrDefault(), scope.SubScope("postingslist-pool")) postingsList := postings.NewPool(postingsListOpts, roaring.NewPostingsList) + indexOpts := opts.IndexOptions(). SetInstrumentOptions(iopts). SetMemSegmentOptions( From 84483fe311896ebc2f82b6ef2718b5e67e0ff6b2 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:36:57 -0500 Subject: [PATCH 07/54] fix broken test --- src/cmd/services/m3dbnode/config/pooling.go | 4 ++-- src/cmd/services/m3dbnode/main/common_test.go | 1 + src/cmd/services/m3dbnode/main/main_test.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 6873262ce4..0856bd84be 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -122,10 +122,10 @@ type PoolPolicy struct { Size *int `yaml:"size"` // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` + RefillLowWaterMark *float64 `yaml:"lowWatermark"` // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark *float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + RefillHighWaterMark *float64 `yaml:"highWatermark"` // Default values to be returned if the above values are not set. defaultSize int diff --git a/src/cmd/services/m3dbnode/main/common_test.go b/src/cmd/services/m3dbnode/main/common_test.go index 49b4cb8acd..178080ef83 100644 --- a/src/cmd/services/m3dbnode/main/common_test.go +++ b/src/cmd/services/m3dbnode/main/common_test.go @@ -1,3 +1,4 @@ +// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 8127e25334..10e68061a4 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -1,3 +1,4 @@ +// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // From 26f150cfda3f657ecd758395a579f8a40a396357 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:39:41 -0500 Subject: [PATCH 08/54] valid refills --- src/cmd/services/m3dbnode/config/pooling.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 0856bd84be..26bf1f5d09 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -145,7 +145,7 @@ func (p *PoolPolicy) SizeOrDefault() int { // RefillLowWaterMarkOrDefault returns the configured refill low water mark if present, // or a default value otherwise. func (p *PoolPolicy) RefillLowWaterMarkOrDefault() float64 { - if p.RefillLowWaterMark != nil { + if p.RefillLowWaterMark != nil && *p.RefillLowWaterMark > 0 && *p.RefillLowWaterMark < 1 { return *p.RefillLowWaterMark } @@ -155,7 +155,7 @@ func (p *PoolPolicy) RefillLowWaterMarkOrDefault() float64 { // RefillHighWaterMarkOrDefault returns the configured refill high water mark if present, // or a default value otherwise. func (p *PoolPolicy) RefillHighWaterMarkOrDefault() float64 { - if p.RefillHighWaterMark != nil { + if p.RefillHighWaterMark != nil && *p.RefillHighWaterMark > 0 && *p.RefillHighWaterMark < 1 { return *p.RefillHighWaterMark } From c54c3f4b87336f3e463d04cbb38ad435af12e11d Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:40:40 -0500 Subject: [PATCH 09/54] delete unused var block --- src/cmd/services/m3dbnode/config/pooling.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 26bf1f5d09..ead31deb7e 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -36,8 +36,6 @@ const ( defaultPostingsListPoolSize = 16 ) -var () - // PoolingPolicy specifies the pooling policy. type PoolingPolicy struct { // The initial alloc size for a block. From de21c8884fc1cb65e0a286c0447e49f64e9a9d3b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 12:56:42 -0500 Subject: [PATCH 10/54] fix bug in parsing values and fix tests --- src/cmd/services/m3dbnode/config/pooling.go | 278 +++++++++--------- .../services/m3dbnode/config/pooling_test.go | 87 +++--- 2 files changed, 186 insertions(+), 179 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index ead31deb7e..9eb3f8400e 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -238,11 +238,11 @@ type ContextPoolPolicy struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := c.PoolPolicy + policy.defaultSize = 262144 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // MaxFinalizerCapacityOrDefault returns the maximum finalizer capacity and @@ -263,11 +263,11 @@ type DefaultPoolPolicy struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *DefaultPoolPolicy) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 4096, - defaultRefillLowWaterMark: 0.0, - defaultRefillHighWaterMark: 0.0, - } + policy := p.PoolPolicy + policy.defaultSize = 4096 + policy.defaultRefillLowWaterMark = 0.0 + policy.defaultRefillHighWaterMark = 0.0 + return policy } // SeriesPool is the pool policy for the series pool. @@ -278,11 +278,11 @@ type SeriesPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *SeriesPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 262144 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // BlockPool is the pool policy for the block pool. @@ -293,11 +293,11 @@ type BlockPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *BlockPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 262144 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // EncoderPool is the pool policy for the encoder pool. @@ -308,11 +308,11 @@ type EncoderPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *EncoderPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 262144 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // ClosersPool is the pool policy for the closers pool. @@ -323,11 +323,11 @@ type ClosersPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 104857, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 104857 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // ContextPool is the pool policy for the context pool. @@ -338,11 +338,11 @@ type ContextPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 262144 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // SegmentReaderPool is the pool policy for the segment reader pool. @@ -353,11 +353,11 @@ type SegmentReaderPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *SegmentReaderPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 16384, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 16384 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // IteratorPool is the pool policy for the iterator pool. @@ -368,11 +368,11 @@ type IteratorPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *IteratorPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 2048, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 2048 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // FetchBlockMetadataResultsPool is the pool policy for the fetch block metadata results pool. @@ -383,12 +383,12 @@ type FetchBlockMetadataResultsPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *FetchBlockMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { - return CapacityPoolPolicy{ - Size: 65536, - Capacity: 32, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - } + policy := p.CapacityPoolPolicy + policy.defaultSize = 65536 + policy.defaultCapacity = 32 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // FetchBlocksMetadataResultsPool is the pool policy for the fetch blocks metadata results pool. @@ -399,12 +399,12 @@ type FetchBlocksMetadataResultsPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *FetchBlocksMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { - return CapacityPoolPolicy{ - defaultSize: 32, - defaultCapacity: 4096, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.CapacityPoolPolicy + policy.defaultSize = 32 + policy.defaultCapacity = 4096 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // HostBlockMetadataSlicePool is the pool policy for the host block metadata slice pool. @@ -415,12 +415,12 @@ type HostBlockMetadataSlicePool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *HostBlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { - return CapacityPoolPolicy{ - defaultSize: 131072, - defaultCapacity: 3, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.CapacityPoolPolicy + policy.defaultSize = 131072 + policy.defaultCapacity = 3 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // BlockMetadataPool is the pool policy for the block metadata pool. @@ -431,11 +431,11 @@ type BlockMetadataPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *BlockMetadataPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 65536, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 65536 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // BlockMetadataSlicePool is the pool policy for the block metadata slice pool. @@ -446,12 +446,12 @@ type BlockMetadataSlicePool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *BlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { - return CapacityPoolPolicy{ - defaultSize: 65536, - defaultCapacity: 32, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.CapacityPoolPolicy + policy.defaultSize = 65536 + policy.defaultCapacity = 32 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // BlocksMetadataPool is the pool policy for the blocks metadata pool. @@ -462,11 +462,11 @@ type BlocksMetadataPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *BlocksMetadataPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 65536, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 65536 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // BlocksMetadataSlicePool is the pool policy for the blocks metadata slice pool. @@ -477,12 +477,12 @@ type BlocksMetadataSlicePool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *BlocksMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { - return CapacityPoolPolicy{ - defaultSize: 32, - defaultCapacity: 4096, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.CapacityPoolPolicy + policy.defaultSize = 32 + policy.defaultCapacity = 4096 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // IdentifierPool is the pool policy for the identifier pool. @@ -493,11 +493,11 @@ type IdentifierPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *IdentifierPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 262144 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } // BytesPool is the pool policy for the bytes pool. @@ -508,52 +508,52 @@ type BytesPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { - return BucketPoolPolicy{ - defaultBuckets: []CapacityPoolPolicy{ - { - Capacity: 16, - Size: 524288, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 32, - Size: 262144, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 64, - Size: 131072, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 128, - Size: 65536, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 256, - Size: 65536, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 1440, - Size: 16384, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 4096, - Size: 8192, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, + policy := p.BucketPoolPolicy + policy.defaultBuckets = []CapacityPoolPolicy{ + { + Capacity: 16, + Size: 524288, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 32, + Size: 262144, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 64, + Size: 131072, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 128, + Size: 65536, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 256, + Size: 65536, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 1440, + Size: 16384, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 4096, + Size: 8192, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, }, } + return policy } // PostingsListPool is the pool policy for the postings list pool. @@ -564,9 +564,9 @@ type PostingsListPool struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { - return PoolPolicy{ - defaultSize: 16, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - } + policy := p.PoolPolicy + policy.defaultSize = 16 + policy.defaultRefillLowWaterMark = 0.7 + policy.defaultRefillHighWaterMark = 1.0 + return policy } diff --git a/src/cmd/services/m3dbnode/config/pooling_test.go b/src/cmd/services/m3dbnode/config/pooling_test.go index 6ab1f7193e..f8478fa937 100644 --- a/src/cmd/services/m3dbnode/config/pooling_test.go +++ b/src/cmd/services/m3dbnode/config/pooling_test.go @@ -19,50 +19,57 @@ // THE SOFTWARE. package config -// func TestContextPoolPolicyPoolPolicy(t *testing.T) { -// size := 10 -// refillLowWaterMark := 0.5 -// refillHighWaterMark := 0.7 -// cpp := ContextPoolPolicy{ -// PoolPolicy: PoolPolicy{ -// defaultSize: size, -// defaultRefillLowWaterMark: refillLowWaterMark, -// defaultRefillHighWaterMark: refillHighWaterMark, -// }, -// } +import ( + "testing" -// require.Equal(t, PoolPolicy{ -// Size: size, -// RefillLowWaterMark: refillLowWaterMark, -// RefillHighWaterMark: refillHighWaterMark, -// }, cpp.PoolPolicyOrDefault()) -// } + "github.com/stretchr/testify/require" +) -// func TestContextPoolMaxFinalizerCapacityOrDefault(t *testing.T) { -// cpp := ContextPoolPolicy{ -// MaxFinalizerCapacity: 0, -// } -// require.Equal(t, defaultMaxFinalizerCapacity, cpp.MaxFinalizerCapacityOrDefault()) +func TestContextPoolPolicyPoolPolicy(t *testing.T) { + size := 10 + refillLowWaterMark := 0.5 + refillHighWaterMark := 0.7 + cpp := ContextPoolPolicy{ + PoolPolicy: PoolPolicy{ + Size: &size, + RefillLowWaterMark: &refillLowWaterMark, + RefillHighWaterMark: &refillHighWaterMark, + }, + } -// cpp.MaxFinalizerCapacity = 10 -// require.Equal(t, 10, cpp.MaxFinalizerCapacityOrDefault()) -// } + policy := cpp.PoolPolicyOrDefault() + require.Equal(t, size, policy.SizeOrDefault()) + require.Equal(t, refillLowWaterMark, policy.RefillLowWaterMarkOrDefault()) + require.Equal(t, refillHighWaterMark, policy.RefillHighWaterMarkOrDefault()) +} -// func TestPostingsPoolPolicyDefaultSize(t *testing.T) { -// policy := PoolingPolicy{ -// PostingsListPool: PoolPolicy{}, -// } +func TestContextPoolMaxFinalizerCapacityOrDefault(t *testing.T) { + cpp := ContextPoolPolicy{ + MaxFinalizerCapacity: 0, + } + require.Equal(t, defaultMaxFinalizerCapacity, cpp.MaxFinalizerCapacityOrDefault()) -// parsed := policy.PostingsListPoolPolicyWithDefaults() -// require.Equal(t, defaultPostingsListPoolSize, parsed.Size) -// } + cpp.MaxFinalizerCapacity = 10 + require.Equal(t, 10, cpp.MaxFinalizerCapacityOrDefault()) +} -// func TestPostingsPoolPolicyWithSize(t *testing.T) { -// defaultPlus1 := defaultPostingsListPoolSize + 1 -// policy := PoolingPolicy{ -// PostingsListPool: PoolPolicy{Size: defaultPlus1}, -// } +func TestPostingsPoolPolicyDefaultSize(t *testing.T) { + policy := PoolingPolicy{ + PostingsListPool: PostingsListPool{}, + } -// parsed := policy.PostingsListPoolPolicyWithDefaults() -// require.Equal(t, defaultPlus1, parsed.Size) -// } + parsed := policy.PostingsListPool.PoolPolicyOrDefault() + require.Equal(t, defaultPostingsListPoolSize, parsed.SizeOrDefault()) +} + +func TestPostingsPoolPolicyWithSize(t *testing.T) { + defaultPlus1 := defaultPostingsListPoolSize + 1 + policy := PoolingPolicy{ + PostingsListPool: PostingsListPool{ + PoolPolicy{Size: &defaultPlus1}, + }, + } + + parsed := policy.PostingsListPool.PoolPolicyOrDefault() + require.Equal(t, defaultPlus1, parsed.SizeOrDefault()) +} From d1a29ed191cad4ce1f85051e662de5f16cf28505 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 13:22:16 -0500 Subject: [PATCH 11/54] fix broken config and test --- src/dbnode/server/server.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index f3e6604d6d..320c4fffe1 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -1030,9 +1030,11 @@ func withEncodingAndPoolingOptions( writeBatchPoolMaxBatchSize = policy.WriteBatchPool.MaxBatchSize } - writeBatchPoolPolicy := policy.WriteBatchPool.Pool - writeBatchPoolSize := writeBatchPoolPolicy.SizeOrDefault() - if writeBatchPoolSize == 0 { + writeBatchPoolPolicy := poolOptions( + policy.WriteBatchPool.Pool, + scope.SubScope("write-batch-pool"), + ) + if writeBatchPoolPolicy.Size() == 0 { // If no value set, calculate a reasonabble value based on the commit log // queue size. We base it off the commitlog queue size because we will // want to be able to buffer at least one full commitlog queues worth of @@ -1041,10 +1043,10 @@ func withEncodingAndPoolingOptions( commitlogQueueSize := opts.CommitLogOptions().BacklogQueueSize() // TODO: This seems wrong expectedBatchSize := *writeBatchPoolInitialBatchSize - writeBatchPoolSize = commitlogQueueSize / expectedBatchSize + writeBatchPoolPolicy = writeBatchPoolPolicy.SetSize(commitlogQueueSize / expectedBatchSize) } writeBatchPool := ts.NewWriteBatchPool( - poolOptions(writeBatchPoolPolicy, scope.SubScope("write-batch-pool")), + writeBatchPoolPolicy, writeBatchPoolInitialBatchSize, writeBatchPoolMaxBatchSize) From 6725b03d5858cc003b617b2a4eab6bb94f7e0040 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 13:44:38 -0500 Subject: [PATCH 12/54] default values for filesystem; --- src/cmd/services/m3dbnode/config/config.go | 2 +- src/cmd/services/m3dbnode/config/fs.go | 147 +++++++++++++++--- src/cmd/services/m3dbnode/main/common_test.go | 1 - src/cmd/services/m3dbnode/main/main_test.go | 1 - src/dbnode/server/server.go | 20 +-- 5 files changed, 135 insertions(+), 36 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config.go b/src/cmd/services/m3dbnode/config/config.go index 9cd3db2ed0..fb5bd31cf2 100644 --- a/src/cmd/services/m3dbnode/config/config.go +++ b/src/cmd/services/m3dbnode/config/config.go @@ -256,7 +256,7 @@ func NewEtcdEmbedConfig(cfg DBConfiguration) (*embed.Config, error) { dir := kvCfg.RootDir if dir == "" { - dir = path.Join(cfg.Filesystem.FilePathPrefix, defaultEtcdDirSuffix) + dir = path.Join(cfg.Filesystem.FilePathPrefixOrDefault(), defaultEtcdDirSuffix) } newKVCfg.Dir = dir diff --git a/src/cmd/services/m3dbnode/config/fs.go b/src/cmd/services/m3dbnode/config/fs.go index 8d74601efe..c145eabcdd 100644 --- a/src/cmd/services/m3dbnode/config/fs.go +++ b/src/cmd/services/m3dbnode/config/fs.go @@ -30,6 +30,16 @@ const ( DefaultNewFileMode = os.FileMode(0666) // DefaultNewDirectoryMode is the default new directory mode. DefaultNewDirectoryMode = os.FileMode(0755) + + defaultFilePathPrefix = "/var/lib/m3db" + defaultWriteBufferSize = 65536 + defaultDataReadBufferSize = 65536 + defaultInfoReadBufferSize = 128 + defaultSeekReadBufferSize = 4096 + defaultThroughputLimitMbps = 100.0 + defaultThroughputCheckEvery = 128 + defaultForceIndexSummariesMmapMemory = false + defaultForceBloomFilterMmapMemory = false ) // DefaultMmapConfiguration is the default mmap configuration. @@ -45,25 +55,25 @@ func DefaultMmapConfiguration() MmapConfiguration { // FilesystemConfiguration is the filesystem configuration. type FilesystemConfiguration struct { // File path prefix for reading/writing TSDB files - FilePathPrefix string `yaml:"filePathPrefix" validate:"nonzero"` + FilePathPrefix *string `yaml:"filePathPrefix" validate:"nonzero"` // Write buffer size - WriteBufferSize int `yaml:"writeBufferSize" validate:"min=1"` + WriteBufferSize *int `yaml:"writeBufferSize" validate:"min=1"` // Data read buffer size - DataReadBufferSize int `yaml:"dataReadBufferSize" validate:"min=1"` + DataReadBufferSize *int `yaml:"dataReadBufferSize" validate:"min=1"` // Info metadata file read buffer size - InfoReadBufferSize int `yaml:"infoReadBufferSize" validate:"min=1"` + InfoReadBufferSize *int `yaml:"infoReadBufferSize" validate:"min=1"` // Seek data read buffer size - SeekReadBufferSize int `yaml:"seekReadBufferSize" validate:"min=1"` + SeekReadBufferSize *int `yaml:"seekReadBufferSize" validate:"min=1"` // Disk flush throughput limit in Mb/s - ThroughputLimitMbps float64 `yaml:"throughputLimitMbps" validate:"min=0.0"` + ThroughputLimitMbps *float64 `yaml:"throughputLimitMbps" validate:"min=0.0"` // Disk flush throughput check interval - ThroughputCheckEvery int `yaml:"throughputCheckEvery" validate:"nonzero"` + ThroughputCheckEvery *int `yaml:"throughputCheckEvery" validate:"nonzero"` // NewFileMode is the new file permissions mode to use when // creating files - specify as three digits, e.g. 666. @@ -78,11 +88,110 @@ type FilesystemConfiguration struct { // ForceIndexSummariesMmapMemory forces the mmap that stores the index lookup bytes // to be an anonymous region in memory as opposed to a file-based mmap. - ForceIndexSummariesMmapMemory bool `yaml:"force_index_summaries_mmap_memory"` + ForceIndexSummariesMmapMemory *bool `yaml:"force_index_summaries_mmap_memory"` // ForceBloomFilterMmapMemory forces the mmap that stores the index lookup bytes // to be an anonymous region in memory as opposed to a file-based mmap. - ForceBloomFilterMmapMemory bool `yaml:"force_bloom_filter_mmap_memory"` + ForceBloomFilterMmapMemory *bool `yaml:"force_bloom_filter_mmap_memory"` +} + +// FilePathPrefixOrDefault returns the configured file path prefix if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) FilePathPrefixOrDefault() string { + if f.FilePathPrefix != nil { + return *f.FilePathPrefix + } + + return defaultFilePathPrefix +} + +// WriteBufferSizeOrDefault returns the configured write buffer size if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) WriteBufferSizeOrDefault() int { + if f.WriteBufferSize != nil { + return *f.WriteBufferSize + } + + return defaultWriteBufferSize +} + +// DataReadBufferSizeOrDefault returns the configured data read buffer size if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) DataReadBufferSizeOrDefault() int { + if f.DataReadBufferSize != nil { + return *f.DataReadBufferSize + } + + return defaultDataReadBufferSize +} + +// InfoReadBufferSizeOrDefault returns the configured info read buffer size if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) InfoReadBufferSizeOrDefault() int { + if f.InfoReadBufferSize != nil { + return *f.InfoReadBufferSize + } + + return defaultInfoReadBufferSize +} + +// SeekReadBufferSizeOrDefault returns the configured seek read buffer size if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) SeekReadBufferSizeOrDefault() int { + if f.SeekReadBufferSize != nil { + return *f.SeekReadBufferSize + } + + return defaultSeekReadBufferSize +} + +// ThroughputLimitMbpsOrDefault returns the configured throughput limit mbps if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) ThroughputLimitMbpsOrDefault() float64 { + if f.ThroughputLimitMbps != nil { + return *f.ThroughputLimitMbps + } + + return defaultThroughputLimitMbps +} + +// ThroughputCheckEveryOrDefault returns the configured throughput check every value if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) ThroughputCheckEveryOrDefault() int { + if f.ThroughputCheckEvery != nil { + return *f.ThroughputCheckEvery + } + + return defaultThroughputCheckEvery +} + +// MmapConfigurationOrDefault returns the configured mmap configuration if configured, or a +// default value otherwise. +func (f FilesystemConfiguration) MmapConfigurationOrDefault() MmapConfiguration { + if f.Mmap == nil { + return DefaultMmapConfiguration() + } + return *f.Mmap +} + +// ForceIndexSummariesMmapMemoryOrDefault returns the configured value for forcing the summaries +// mmaps into anonymous region in memory if configured, or a default value otherwise. +func (f FilesystemConfiguration) ForceIndexSummariesMmapMemoryOrDefault() bool { + if f.ForceIndexSummariesMmapMemory != nil { + return *f.ForceIndexSummariesMmapMemory + } + + return defaultForceIndexSummariesMmapMemory +} + +// ForceBloomFilterMmapMemoryOrDefault returns the configured value for forcing the bloom +// filter mmaps into anonymous region in memory if configured, or a default value otherwise. +func (f FilesystemConfiguration) ForceBloomFilterMmapMemoryOrDefault() bool { + if f.ForceBloomFilterMmapMemory != nil { + return *f.ForceBloomFilterMmapMemory + } + + return defaultForceBloomFilterMmapMemory } // MmapConfiguration is the mmap configuration. @@ -102,12 +211,12 @@ type MmapHugeTLBConfiguration struct { } // ParseNewFileMode parses the specified new file mode. -func (p FilesystemConfiguration) ParseNewFileMode() (os.FileMode, error) { - if p.NewFileMode == nil { +func (f FilesystemConfiguration) ParseNewFileMode() (os.FileMode, error) { + if f.NewFileMode == nil { return DefaultNewFileMode, nil } - str := *p.NewFileMode + str := *f.NewFileMode if len(str) != 3 { return 0, fmt.Errorf("file mode must be 3 chars long") } @@ -126,12 +235,12 @@ func (p FilesystemConfiguration) ParseNewFileMode() (os.FileMode, error) { } // ParseNewDirectoryMode parses the specified new directory mode. -func (p FilesystemConfiguration) ParseNewDirectoryMode() (os.FileMode, error) { - if p.NewDirectoryMode == nil { +func (f FilesystemConfiguration) ParseNewDirectoryMode() (os.FileMode, error) { + if f.NewDirectoryMode == nil { return DefaultNewDirectoryMode, nil } - str := *p.NewDirectoryMode + str := *f.NewDirectoryMode if len(str) != 3 { return 0, fmt.Errorf("file mode must be 3 chars long") } @@ -148,11 +257,3 @@ func (p FilesystemConfiguration) ParseNewDirectoryMode() (os.FileMode, error) { } return os.ModeDir | os.FileMode(v), nil } - -// MmapConfiguration returns the effective mmap configuration. -func (p FilesystemConfiguration) MmapConfiguration() MmapConfiguration { - if p.Mmap == nil { - return DefaultMmapConfiguration() - } - return *p.Mmap -} diff --git a/src/cmd/services/m3dbnode/main/common_test.go b/src/cmd/services/m3dbnode/main/common_test.go index 178080ef83..49b4cb8acd 100644 --- a/src/cmd/services/m3dbnode/main/common_test.go +++ b/src/cmd/services/m3dbnode/main/common_test.go @@ -1,4 +1,3 @@ -// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 10e68061a4..8127e25334 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -1,4 +1,3 @@ -// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 320c4fffe1..2c2dbb6aa4 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -233,8 +233,8 @@ func Run(runOpts RunOptions) { runtimeOpts := m3dbruntime.NewOptions(). SetPersistRateLimitOptions(ratelimit.NewOptions(). SetLimitEnabled(true). - SetLimitMbps(cfg.Filesystem.ThroughputLimitMbps). - SetLimitCheckEvery(cfg.Filesystem.ThroughputCheckEvery)). + SetLimitMbps(cfg.Filesystem.ThroughputLimitMbpsOrDefault()). + SetLimitCheckEvery(cfg.Filesystem.ThroughputCheckEveryOrDefault())). SetWriteNewSeriesAsync(cfg.WriteNewSeriesAsync). SetWriteNewSeriesBackoffDuration(cfg.WriteNewSeriesBackoffDuration) if lruCfg := cfg.Cache.SeriesConfiguration().LRU; lruCfg != nil { @@ -275,7 +275,7 @@ func Run(runOpts RunOptions) { logger.Fatalf("could not parse new directory mode: %v", err) } - mmapCfg := cfg.Filesystem.MmapConfiguration() + mmapCfg := cfg.Filesystem.MmapConfigurationOrDefault() shouldUseHugeTLB := mmapCfg.HugeTLB.Enabled if shouldUseHugeTLB { // Make sure the host supports HugeTLB before proceeding with it to prevent @@ -307,20 +307,20 @@ func Run(runOpts RunOptions) { SetClockOptions(opts.ClockOptions()). SetInstrumentOptions(opts.InstrumentOptions(). SetMetricsScope(scope.SubScope("database.fs"))). - SetFilePathPrefix(cfg.Filesystem.FilePathPrefix). + SetFilePathPrefix(cfg.Filesystem.FilePathPrefixOrDefault()). SetNewFileMode(newFileMode). SetNewDirectoryMode(newDirectoryMode). - SetWriterBufferSize(cfg.Filesystem.WriteBufferSize). - SetDataReaderBufferSize(cfg.Filesystem.DataReadBufferSize). - SetInfoReaderBufferSize(cfg.Filesystem.InfoReadBufferSize). - SetSeekReaderBufferSize(cfg.Filesystem.SeekReadBufferSize). + SetWriterBufferSize(cfg.Filesystem.WriteBufferSizeOrDefault()). + SetDataReaderBufferSize(cfg.Filesystem.DataReadBufferSizeOrDefault()). + SetInfoReaderBufferSize(cfg.Filesystem.InfoReadBufferSizeOrDefault()). + SetSeekReaderBufferSize(cfg.Filesystem.SeekReadBufferSizeOrDefault()). SetMmapEnableHugeTLB(shouldUseHugeTLB). SetMmapHugeTLBThreshold(mmapCfg.HugeTLB.Threshold). SetRuntimeOptionsManager(runtimeOptsMgr). SetTagEncoderPool(tagEncoderPool). SetTagDecoderPool(tagDecoderPool). - SetForceIndexSummariesMmapMemory(cfg.Filesystem.ForceIndexSummariesMmapMemory). - SetForceBloomFilterMmapMemory(cfg.Filesystem.ForceBloomFilterMmapMemory) + SetForceIndexSummariesMmapMemory(cfg.Filesystem.ForceIndexSummariesMmapMemoryOrDefault()). + SetForceBloomFilterMmapMemory(cfg.Filesystem.ForceBloomFilterMmapMemoryOrDefault()) var commitLogQueueSize int specified := cfg.CommitLog.Queue.Size From 59ba7f925fa89a5217cd39819074cfb5d1deb047 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 13:52:08 -0500 Subject: [PATCH 13/54] Fix more config stuff --- src/cmd/services/m3dbnode/config/pooling.go | 24 +++++++++++++++++++-- src/dbnode/server/server.go | 4 ++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 9eb3f8400e..799fcbc936 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -39,10 +39,10 @@ const ( // PoolingPolicy specifies the pooling policy. type PoolingPolicy struct { // The initial alloc size for a block. - BlockAllocSize int `yaml:"blockAllocSize"` + BlockAllocSize *int `yaml:"blockAllocSize"` // The general pool type (currently only supported: simple). - Type PoolingType `yaml:"type"` + Type *PoolingType `yaml:"type"` // The Bytes pool buckets to use. BytesPool BytesPool `yaml:"bytesPool"` @@ -114,6 +114,26 @@ type PoolingPolicy struct { PostingsListPool PostingsListPool `yaml:"postingsListPool"` } +// BlockAllocSizeOrDefault returns the configured block alloc size if provided, +// or a default value otherwise. +func (p *PoolingPolicy) BlockAllocSizeOrDefault() int { + if p.BlockAllocSize != nil { + return *p.BlockAllocSize + } + + return 16 +} + +// TypeOrDefault returns the configured pooling type if provided, or a default +// value otherwise. +func (p *PoolingPolicy) TypeOrDefault() PoolingType { + if p.Type != nil { + return *p.Type + } + + return SimplePooling +} + // PoolPolicy specifies a single pool policy. type PoolPolicy struct { // The size of the pool. diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 2c2dbb6aa4..db9016c322 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -966,7 +966,7 @@ func withEncodingAndPoolingOptions( } var bytesPool pool.CheckedBytesPool - switch policy.Type { + switch policy.TypeOrDefault() { case config.SimplePooling: bytesPool = pool.NewCheckedBytesPool( buckets, @@ -1105,7 +1105,7 @@ func withEncodingAndPoolingOptions( SetWriteBatchPool(writeBatchPool) blockOpts := opts.DatabaseBlockOptions(). - SetDatabaseBlockAllocSize(policy.BlockAllocSize). + SetDatabaseBlockAllocSize(policy.BlockAllocSizeOrDefault()). SetContextPool(contextPool). SetEncoderPool(encoderPool). SetSegmentReaderPool(segmentReaderPool). From b85a430018723ddd4eaa2269cfe35f067783b194 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 13:59:27 -0500 Subject: [PATCH 14/54] remove now-default values from config yamls --- kube/m3dbnode-configmap.yaml | 112 ----------------- scripts/development/m3_stack/m3dbnode.yml | 113 ------------------ .../config/m3dbnode-cluster-template.yml | 113 ------------------ src/dbnode/config/m3dbnode-local-etcd.yml | 113 ------------------ src/dbnode/config/m3dbnode-local.yml | 113 ------------------ .../main/m3dbnode-local-config.yaml | 113 ------------------ src/query/benchmark/configs/m3db_config.yaml | 113 ------------------ .../m3dbnode-server1-config.yaml | 113 ------------------ .../m3dbnode-server2-config.yaml | 113 ------------------ .../m3dbnode-server3-config.yaml | 113 ------------------ 10 files changed, 1129 deletions(-) diff --git a/kube/m3dbnode-configmap.yaml b/kube/m3dbnode-configmap.yaml index 41102ef448..68c2d8ba46 100644 --- a/kube/m3dbnode-configmap.yaml +++ b/kube/m3dbnode-configmap.yaml @@ -88,119 +88,7 @@ data: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - - pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: service: env: default_env diff --git a/scripts/development/m3_stack/m3dbnode.yml b/scripts/development/m3_stack/m3dbnode.yml index e36ca8e783..54e1836ed0 100644 --- a/scripts/development/m3_stack/m3dbnode.yml +++ b/scripts/development/m3_stack/m3dbnode.yml @@ -67,119 +67,6 @@ db: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - - repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - - pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: service: diff --git a/src/dbnode/config/m3dbnode-cluster-template.yml b/src/dbnode/config/m3dbnode-cluster-template.yml index 5f193ff508..836721b72d 100644 --- a/src/dbnode/config/m3dbnode-cluster-template.yml +++ b/src/dbnode/config/m3dbnode-cluster-template.yml @@ -109,116 +109,3 @@ db: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - - repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - - pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 diff --git a/src/dbnode/config/m3dbnode-local-etcd.yml b/src/dbnode/config/m3dbnode-local-etcd.yml index d525a247c8..0faa07d220 100644 --- a/src/dbnode/config/m3dbnode-local-etcd.yml +++ b/src/dbnode/config/m3dbnode-local-etcd.yml @@ -91,119 +91,6 @@ db: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - - repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - - pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: service: diff --git a/src/dbnode/config/m3dbnode-local.yml b/src/dbnode/config/m3dbnode-local.yml index b09c54e73d..aaee5ccf6b 100644 --- a/src/dbnode/config/m3dbnode-local.yml +++ b/src/dbnode/config/m3dbnode-local.yml @@ -88,119 +88,6 @@ db: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - - repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - - pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: static: diff --git a/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml b/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml index c161b7ada5..76b353b600 100644 --- a/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml +++ b/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml @@ -65,119 +65,6 @@ commitlog: fs: filePathPrefix: /var/lib/m3db1 - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - -repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - -pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: static: diff --git a/src/query/benchmark/configs/m3db_config.yaml b/src/query/benchmark/configs/m3db_config.yaml index 45c28e86c8..1c48f78b5e 100644 --- a/src/query/benchmark/configs/m3db_config.yaml +++ b/src/query/benchmark/configs/m3db_config.yaml @@ -64,119 +64,6 @@ commitlog: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - -repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - -pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: static: diff --git a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml index 8056f15006..515e1f9afd 100644 --- a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml +++ b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml @@ -63,119 +63,6 @@ commitlog: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - -repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - -pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: static: diff --git a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml index e2710995e5..2908dba25e 100644 --- a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml +++ b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml @@ -63,119 +63,6 @@ commitlog: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - -repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - -pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: static: diff --git a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml index 5aafa571c4..2fd87e42b1 100644 --- a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml +++ b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml @@ -63,119 +63,6 @@ commitlog: fs: filePathPrefix: /var/lib/m3db - writeBufferSize: 65536 - dataReadBufferSize: 65536 - infoReadBufferSize: 128 - seekReadBufferSize: 4096 - throughputLimitMbps: 100.0 - throughputCheckEvery: 128 - -repair: - enabled: false - interval: 2h - offset: 30m - jitter: 1h - throttle: 2m - checkInterval: 1m - -pooling: - blockAllocSize: 16 - type: simple - seriesPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - blockPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - encoderPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - closersPool: - size: 104857 - lowWatermark: 0.7 - highWatermark: 1.0 - contextPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - segmentReaderPool: - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - iteratorPool: - size: 2048 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlockMetadataResultsPool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - fetchBlocksMetadataResultsPool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - hostBlockMetadataSlicePool: - size: 131072 - capacity: 3 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blockMetadataSlicePool: - size: 65536 - capacity: 32 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataPool: - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - blocksMetadataSlicePool: - size: 32 - capacity: 4096 - lowWatermark: 0.7 - highWatermark: 1.0 - identifierPool: - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - bytesPool: - buckets: - - capacity: 16 - size: 524288 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 32 - size: 262144 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 64 - size: 131072 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 128 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 256 - size: 65536 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 1440 - size: 16384 - lowWatermark: 0.7 - highWatermark: 1.0 - - capacity: 4096 - size: 8192 - lowWatermark: 0.7 - highWatermark: 1.0 config: static: From 1b55e901ba8bd5f9d01877dbf0b87d82c032fde1 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 14:26:37 -0500 Subject: [PATCH 15/54] fix validaiton --- src/cmd/services/m3dbnode/config/fs.go | 26 +++++++++---------- src/cmd/services/m3dbnode/main/common_test.go | 1 + src/cmd/services/m3dbnode/main/main_test.go | 1 + 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/fs.go b/src/cmd/services/m3dbnode/config/fs.go index c145eabcdd..d6aebb5598 100644 --- a/src/cmd/services/m3dbnode/config/fs.go +++ b/src/cmd/services/m3dbnode/config/fs.go @@ -55,25 +55,25 @@ func DefaultMmapConfiguration() MmapConfiguration { // FilesystemConfiguration is the filesystem configuration. type FilesystemConfiguration struct { // File path prefix for reading/writing TSDB files - FilePathPrefix *string `yaml:"filePathPrefix" validate:"nonzero"` + FilePathPrefix *string `yaml:"filePathPrefix"` // Write buffer size - WriteBufferSize *int `yaml:"writeBufferSize" validate:"min=1"` + WriteBufferSize *int `yaml:"writeBufferSize"` // Data read buffer size - DataReadBufferSize *int `yaml:"dataReadBufferSize" validate:"min=1"` + DataReadBufferSize *int `yaml:"dataReadBufferSize"` // Info metadata file read buffer size - InfoReadBufferSize *int `yaml:"infoReadBufferSize" validate:"min=1"` + InfoReadBufferSize *int `yaml:"infoReadBufferSize"` // Seek data read buffer size - SeekReadBufferSize *int `yaml:"seekReadBufferSize" validate:"min=1"` + SeekReadBufferSize *int `yaml:"seekReadBufferSize"` // Disk flush throughput limit in Mb/s - ThroughputLimitMbps *float64 `yaml:"throughputLimitMbps" validate:"min=0.0"` + ThroughputLimitMbps *float64 `yaml:"throughputLimitMbps"` // Disk flush throughput check interval - ThroughputCheckEvery *int `yaml:"throughputCheckEvery" validate:"nonzero"` + ThroughputCheckEvery *int `yaml:"throughputCheckEvery"` // NewFileMode is the new file permissions mode to use when // creating files - specify as three digits, e.g. 666. @@ -108,7 +108,7 @@ func (f FilesystemConfiguration) FilePathPrefixOrDefault() string { // WriteBufferSizeOrDefault returns the configured write buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) WriteBufferSizeOrDefault() int { - if f.WriteBufferSize != nil { + if f.WriteBufferSize != nil && *f.WriteBufferSize > 1 { return *f.WriteBufferSize } @@ -118,7 +118,7 @@ func (f FilesystemConfiguration) WriteBufferSizeOrDefault() int { // DataReadBufferSizeOrDefault returns the configured data read buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) DataReadBufferSizeOrDefault() int { - if f.DataReadBufferSize != nil { + if f.DataReadBufferSize != nil && *f.DataReadBufferSize > 1 { return *f.DataReadBufferSize } @@ -128,7 +128,7 @@ func (f FilesystemConfiguration) DataReadBufferSizeOrDefault() int { // InfoReadBufferSizeOrDefault returns the configured info read buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) InfoReadBufferSizeOrDefault() int { - if f.InfoReadBufferSize != nil { + if f.InfoReadBufferSize != nil && *f.InfoReadBufferSize > 1 { return *f.InfoReadBufferSize } @@ -138,7 +138,7 @@ func (f FilesystemConfiguration) InfoReadBufferSizeOrDefault() int { // SeekReadBufferSizeOrDefault returns the configured seek read buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) SeekReadBufferSizeOrDefault() int { - if f.SeekReadBufferSize != nil { + if f.SeekReadBufferSize != nil && *f.SeekReadBufferSize > 1 { return *f.SeekReadBufferSize } @@ -148,7 +148,7 @@ func (f FilesystemConfiguration) SeekReadBufferSizeOrDefault() int { // ThroughputLimitMbpsOrDefault returns the configured throughput limit mbps if configured, or a // default value otherwise. func (f FilesystemConfiguration) ThroughputLimitMbpsOrDefault() float64 { - if f.ThroughputLimitMbps != nil { + if f.ThroughputLimitMbps != nil && *f.ThroughputLimitMbps > 0 { return *f.ThroughputLimitMbps } @@ -158,7 +158,7 @@ func (f FilesystemConfiguration) ThroughputLimitMbpsOrDefault() float64 { // ThroughputCheckEveryOrDefault returns the configured throughput check every value if configured, or a // default value otherwise. func (f FilesystemConfiguration) ThroughputCheckEveryOrDefault() int { - if f.ThroughputCheckEvery != nil { + if f.ThroughputCheckEvery != nil && *f.ThroughputCheckEvery > 0 { return *f.ThroughputCheckEvery } diff --git a/src/cmd/services/m3dbnode/main/common_test.go b/src/cmd/services/m3dbnode/main/common_test.go index 49b4cb8acd..178080ef83 100644 --- a/src/cmd/services/m3dbnode/main/common_test.go +++ b/src/cmd/services/m3dbnode/main/common_test.go @@ -1,3 +1,4 @@ +// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 8127e25334..10e68061a4 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -1,3 +1,4 @@ +// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // From 828878dd3bc27f7d2284cc9175ecd3b74f721ab8 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:00:13 -0500 Subject: [PATCH 16/54] make repair config optional for now --- src/cmd/services/m3dbnode/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/config/config.go b/src/cmd/services/m3dbnode/config/config.go index fb5bd31cf2..d0a84c36fc 100644 --- a/src/cmd/services/m3dbnode/config/config.go +++ b/src/cmd/services/m3dbnode/config/config.go @@ -118,7 +118,7 @@ type DBConfiguration struct { CommitLog CommitLogPolicy `yaml:"commitlog"` // The repair policy for repairing in-memory data. - Repair RepairPolicy `yaml:"repair"` + Repair *RepairPolicy `yaml:"repair"` // The pooling policy. PoolingPolicy PoolingPolicy `yaml:"pooling"` From dd49fe2ebb94e0c3418b5ea53732ceab826f9ed0 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:04:27 -0500 Subject: [PATCH 17/54] dont run repair code in server.go --- src/dbnode/server/server.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index db9016c322..11d2815049 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -59,7 +59,6 @@ import ( "github.com/m3db/m3/src/dbnode/storage/cluster" "github.com/m3db/m3/src/dbnode/storage/index" "github.com/m3db/m3/src/dbnode/storage/namespace" - "github.com/m3db/m3/src/dbnode/storage/repair" "github.com/m3db/m3/src/dbnode/storage/series" "github.com/m3db/m3/src/dbnode/topology" "github.com/m3db/m3/src/dbnode/ts" @@ -465,22 +464,9 @@ func Run(runOpts RunOptions) { kvWatchClientConsistencyLevels(envCfg.KVStore, logger, clientAdminOpts, runtimeOptsMgr) - // Set repair options - hostBlockMetadataSlicePool := repair.NewHostBlockMetadataSlicePool( - capacityPoolOptions(policy.HostBlockMetadataSlicePool.PoolPolicyOrDefault(), - scope.SubScope("host-block-metadata-slice-pool")), - policy.HostBlockMetadataSlicePool.Capacity) - opts = opts. - SetRepairEnabled(cfg.Repair.Enabled). - SetRepairOptions(opts.RepairOptions(). - SetAdminClient(m3dbClient). - SetRepairInterval(cfg.Repair.Interval). - SetRepairTimeOffset(cfg.Repair.Offset). - SetRepairTimeJitter(cfg.Repair.Jitter). - SetRepairThrottle(cfg.Repair.Throttle). - SetRepairCheckInterval(cfg.Repair.CheckInterval). - SetHostBlockMetadataSlicePool(hostBlockMetadataSlicePool)) + // Feature currently not working. + SetRepairEnabled(false) // Set tchannelthrift options ttopts := tchannelthrift.NewOptions(). From e844550afc4e41b923f558d459e96989a4ab9907 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:21:59 -0500 Subject: [PATCH 18/54] update pooling --- src/cmd/services/m3dbnode/config/pooling.go | 261 +++++++++++--------- 1 file changed, 149 insertions(+), 112 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 799fcbc936..096b8c68fc 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -30,12 +30,102 @@ const ( const ( defaultMaxFinalizerCapacity = 4 + + defaultPoolSize = 4096 + defaultRefillLowWaterMark = 0.0 + defaultRefillHighWaterMark = 0.0 + + commonRefillLowWaterMark = 0.7 + commonRefillHighWaterMark = 0.7 + + defaultContextPoolSize = 262144 + + defaultSeriesPoolSize = 262144 + + defaultBlockPoolSize = 262144 + + defaultEncoderPoolSize = 262144 + + defaultClosersPoolSize = 104857 + + defaultSegmentReaderPoolSize = 16384 + + defaultIteratorPoolSize = 2048 + + defaultFetchBlockMetadataResultsPoolSize = 65536 + defaultFetchBlockMetadataResultsPoolCapacity = 32 + + defaultFetchBlocksMetadataResultsPoolSize = 32 + defaultFetchBlocksMetadataResultsPoolCapacity = 4096 + + defaultHostBlockMetadataSlicePoolSize = 131072 + defaultHostBlockMetadataSlicePoolCapacity = 3 + + defaultBlockMetadataPoolSize = 65536 + + defaultBlockMetadataSlicePoolSize = 65536 + defaultBlockMetadataSlicePoolCapacity = 32 + + defaultBlocksMetadataPool = 65536 + + defaultBlocksMetadataSlicePoolSize = 32 + defaultBlocksMetadataSlicePoolCapacity = 4096 + + defaultIdentifierPoolSize = 262144 + // defaultPostingsListPoolSize has a small default pool size since postings // lists can frequently reach the size of 4mb each in practice even when // reset. defaultPostingsListPoolSize = 16 ) +var ( + defaultBytesPoolBuckets = []CapacityPoolPolicy{ + { + Capacity: 16, + Size: 524288, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 32, + Size: 262144, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 64, + Size: 131072, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 128, + Size: 65536, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 256, + Size: 65536, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 1440, + Size: 16384, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + { + Capacity: 4096, + Size: 8192, + RefillLowWaterMark: 0.7, + RefillHighWaterMark: 1.0, + }, + } +) + // PoolingPolicy specifies the pooling policy. type PoolingPolicy struct { // The initial alloc size for a block. @@ -257,11 +347,11 @@ type ContextPoolPolicy struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (c ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { - policy := c.PoolPolicy - policy.defaultSize = 262144 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 +func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { + policy := p.PoolPolicy + policy.defaultSize = defaultContextPoolSize + policy.defaultRefillLowWaterMark = commonRefillLowWaterMark + policy.defaultRefillHighWaterMark = commonRefillHighWaterMark return policy } @@ -284,9 +374,9 @@ type DefaultPoolPolicy struct { // one is not provided. func (p *DefaultPoolPolicy) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 4096 - policy.defaultRefillLowWaterMark = 0.0 - policy.defaultRefillHighWaterMark = 0.0 + policy.defaultSize = defaultPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -299,9 +389,9 @@ type SeriesPool struct { // one is not provided. func (p *SeriesPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 262144 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultSeriesPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -314,9 +404,9 @@ type BlockPool struct { // one is not provided. func (p *BlockPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 262144 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultBlockPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -329,9 +419,9 @@ type EncoderPool struct { // one is not provided. func (p *EncoderPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 262144 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultEncoderPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -344,9 +434,9 @@ type ClosersPool struct { // one is not provided. func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 104857 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultClosersPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -355,16 +445,6 @@ type ContextPool struct { PoolPolicy `yaml:",inline"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = 262144 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 - return policy -} - // SegmentReaderPool is the pool policy for the segment reader pool. type SegmentReaderPool struct { PoolPolicy `yaml:",inline"` @@ -374,9 +454,9 @@ type SegmentReaderPool struct { // one is not provided. func (p *SegmentReaderPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 16384 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultSegmentReaderPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -389,9 +469,9 @@ type IteratorPool struct { // one is not provided. func (p *IteratorPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 2048 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultIteratorPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -404,10 +484,10 @@ type FetchBlockMetadataResultsPool struct { // one is not provided. func (p *FetchBlockMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { policy := p.CapacityPoolPolicy - policy.defaultSize = 65536 - policy.defaultCapacity = 32 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultFetchBlockMetadataResultsPoolSize + policy.defaultCapacity = defaultFetchBlockMetadataResultsPoolCapacity + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -420,10 +500,10 @@ type FetchBlocksMetadataResultsPool struct { // one is not provided. func (p *FetchBlocksMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { policy := p.CapacityPoolPolicy - policy.defaultSize = 32 - policy.defaultCapacity = 4096 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultFetchBlocksMetadataResultsPoolSize + policy.defaultCapacity = defaultFetchBlocksMetadataResultsPoolCapacity + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -436,10 +516,10 @@ type HostBlockMetadataSlicePool struct { // one is not provided. func (p *HostBlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { policy := p.CapacityPoolPolicy - policy.defaultSize = 131072 - policy.defaultCapacity = 3 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultHostBlockMetadataSlicePoolSize + policy.defaultCapacity = defaultHostBlockMetadataSlicePoolCapacity + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -452,9 +532,9 @@ type BlockMetadataPool struct { // one is not provided. func (p *BlockMetadataPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 65536 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultBlockMetadataPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -467,10 +547,10 @@ type BlockMetadataSlicePool struct { // one is not provided. func (p *BlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { policy := p.CapacityPoolPolicy - policy.defaultSize = 65536 - policy.defaultCapacity = 32 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultBlockMetadataSlicePoolSize + policy.defaultCapacity = defaultBlockMetadataSlicePoolCapacity + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -483,9 +563,9 @@ type BlocksMetadataPool struct { // one is not provided. func (p *BlocksMetadataPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 65536 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultBlocksMetadataPool + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -498,10 +578,10 @@ type BlocksMetadataSlicePool struct { // one is not provided. func (p *BlocksMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { policy := p.CapacityPoolPolicy - policy.defaultSize = 32 - policy.defaultCapacity = 4096 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultBlocksMetadataSlicePoolSize + policy.defaultCapacity = defaultBlocksMetadataSlicePoolCapacity + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -514,9 +594,9 @@ type IdentifierPool struct { // one is not provided. func (p *IdentifierPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 262144 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultIdentifierPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } @@ -529,50 +609,7 @@ type BytesPool struct { // one is not provided. func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { policy := p.BucketPoolPolicy - policy.defaultBuckets = []CapacityPoolPolicy{ - { - Capacity: 16, - Size: 524288, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 32, - Size: 262144, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 64, - Size: 131072, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 128, - Size: 65536, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 256, - Size: 65536, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 1440, - Size: 16384, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - { - Capacity: 4096, - Size: 8192, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, - }, - } + policy.defaultBuckets = defaultBytesPoolBuckets return policy } @@ -585,8 +622,8 @@ type PostingsListPool struct { // one is not provided. func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy - policy.defaultSize = 16 - policy.defaultRefillLowWaterMark = 0.7 - policy.defaultRefillHighWaterMark = 1.0 + policy.defaultSize = defaultPostingsListPoolSize + policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark + policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } From c1c1d2a1656bde17496f47fc8a78a4e2533a9e8b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:24:03 -0500 Subject: [PATCH 19/54] restructure constants --- src/cmd/services/m3dbnode/config/pooling.go | 35 ++++++++------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 096b8c68fc..5a441b43dd 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -38,19 +38,21 @@ const ( commonRefillLowWaterMark = 0.7 commonRefillHighWaterMark = 0.7 - defaultContextPoolSize = 262144 - - defaultSeriesPoolSize = 262144 - - defaultBlockPoolSize = 262144 - - defaultEncoderPoolSize = 262144 - - defaultClosersPoolSize = 104857 - + defaultContextPoolSize = 262144 + defaultSeriesPoolSize = 262144 + defaultBlockPoolSize = 262144 + defaultEncoderPoolSize = 262144 + defaultClosersPoolSize = 104857 defaultSegmentReaderPoolSize = 16384 + defaultIteratorPoolSize = 2048 + defaultBlockMetadataPoolSize = 65536 + defaultBlocksMetadataPool = 65536 + defaultIdentifierPoolSize = 262144 - defaultIteratorPoolSize = 2048 + // defaultPostingsListPoolSize has a small default pool size since postings + // lists can frequently reach the size of 4mb each in practice even when + // reset. + defaultPostingsListPoolSize = 16 defaultFetchBlockMetadataResultsPoolSize = 65536 defaultFetchBlockMetadataResultsPoolCapacity = 32 @@ -61,22 +63,11 @@ const ( defaultHostBlockMetadataSlicePoolSize = 131072 defaultHostBlockMetadataSlicePoolCapacity = 3 - defaultBlockMetadataPoolSize = 65536 - defaultBlockMetadataSlicePoolSize = 65536 defaultBlockMetadataSlicePoolCapacity = 32 - defaultBlocksMetadataPool = 65536 - defaultBlocksMetadataSlicePoolSize = 32 defaultBlocksMetadataSlicePoolCapacity = 4096 - - defaultIdentifierPoolSize = 262144 - - // defaultPostingsListPoolSize has a small default pool size since postings - // lists can frequently reach the size of 4mb each in practice even when - // reset. - defaultPostingsListPoolSize = 16 ) var ( From 31050b583e06e0b0d1d2ed636c58060e020398e4 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:26:21 -0500 Subject: [PATCH 20/54] remove TODO --- src/dbnode/server/server.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 11d2815049..760b7d25f3 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -1027,7 +1027,6 @@ func withEncodingAndPoolingOptions( // writes without allocating because these objects are very expensive to // allocate. commitlogQueueSize := opts.CommitLogOptions().BacklogQueueSize() - // TODO: This seems wrong expectedBatchSize := *writeBatchPoolInitialBatchSize writeBatchPoolPolicy = writeBatchPoolPolicy.SetSize(commitlogQueueSize / expectedBatchSize) } From b2f6ea227685ea1f3a7ec3d1771f9734186c8083 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:28:16 -0500 Subject: [PATCH 21/54] fix broken config --- src/cmd/services/m3dbnode/config/pooling.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 5a441b43dd..08f80c956f 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -338,7 +338,7 @@ type ContextPoolPolicy struct { // PoolPolicyOrDefault returns the provided pool policy, or a default value if // one is not provided. -func (p *ContextPool) PoolPolicyOrDefault() PoolPolicy { +func (p *ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { policy := p.PoolPolicy policy.defaultSize = defaultContextPoolSize policy.defaultRefillLowWaterMark = commonRefillLowWaterMark @@ -431,11 +431,6 @@ func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { return policy } -// ContextPool is the pool policy for the context pool. -type ContextPool struct { - PoolPolicy `yaml:",inline"` -} - // SegmentReaderPool is the pool policy for the segment reader pool. type SegmentReaderPool struct { PoolPolicy `yaml:",inline"` From 3d486f01f727e8837cd319d087ddfd98c57772fd Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:30:02 -0500 Subject: [PATCH 22/54] fix typo --- src/dbnode/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 760b7d25f3..7cdc349761 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -1021,7 +1021,7 @@ func withEncodingAndPoolingOptions( scope.SubScope("write-batch-pool"), ) if writeBatchPoolPolicy.Size() == 0 { - // If no value set, calculate a reasonabble value based on the commit log + // If no value set, calculate a reasonable value based on the commit log // queue size. We base it off the commitlog queue size because we will // want to be able to buffer at least one full commitlog queues worth of // writes without allocating because these objects are very expensive to From 40ffc3f55297d4bd8e53a3572b8b478aa598f7d0 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 16:57:28 -0500 Subject: [PATCH 23/54] set correct defaults for m3db client --- src/dbnode/client/config.go | 65 ++++++++++++++++++++----------- src/dbnode/client/options.go | 20 +++++++--- src/query/api/v1/httpd/handler.go | 5 ++- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/dbnode/client/config.go b/src/dbnode/client/config.go index 303589c108..17962a94f8 100644 --- a/src/dbnode/client/config.go +++ b/src/dbnode/client/config.go @@ -43,42 +43,42 @@ var ( // Configuration is a configuration that can be used to construct a client. type Configuration struct { // The environment (static or dynamic) configuration. - EnvironmentConfig environment.Configuration `yaml:"config"` + EnvironmentConfig *environment.Configuration `yaml:"config"` // WriteConsistencyLevel specifies the write consistency level. - WriteConsistencyLevel topology.ConsistencyLevel `yaml:"writeConsistencyLevel"` + WriteConsistencyLevel *topology.ConsistencyLevel `yaml:"writeConsistencyLevel"` // ReadConsistencyLevel specifies the read consistency level. - ReadConsistencyLevel topology.ReadConsistencyLevel `yaml:"readConsistencyLevel"` + ReadConsistencyLevel *topology.ReadConsistencyLevel `yaml:"readConsistencyLevel"` // ConnectConsistencyLevel specifies the cluster connect consistency level. - ConnectConsistencyLevel topology.ConnectConsistencyLevel `yaml:"connectConsistencyLevel"` + ConnectConsistencyLevel *topology.ConnectConsistencyLevel `yaml:"connectConsistencyLevel"` // WriteTimeout is the write request timeout. - WriteTimeout time.Duration `yaml:"writeTimeout" validate:"min=0"` + WriteTimeout *time.Duration `yaml:"writeTimeout" validate:"min=0"` // FetchTimeout is the fetch request timeout. - FetchTimeout time.Duration `yaml:"fetchTimeout" validate:"min=0"` + FetchTimeout *time.Duration `yaml:"fetchTimeout" validate:"min=0"` // ConnectTimeout is the cluster connect timeout. - ConnectTimeout time.Duration `yaml:"connectTimeout" validate:"min=0"` + ConnectTimeout *time.Duration `yaml:"connectTimeout" validate:"min=0"` // WriteRetry is the write retry config. - WriteRetry retry.Configuration `yaml:"writeRetry"` + WriteRetry *retry.Configuration `yaml:"writeRetry"` // FetchRetry is the fetch retry config. - FetchRetry retry.Configuration `yaml:"fetchRetry"` + FetchRetry *retry.Configuration `yaml:"fetchRetry"` // BackgroundHealthCheckFailLimit is the amount of times a background check // must fail before a connection is taken out of consideration. - BackgroundHealthCheckFailLimit int `yaml:"backgroundHealthCheckFailLimit" validate:"min=1,max=10"` + BackgroundHealthCheckFailLimit *int `yaml:"backgroundHealthCheckFailLimit" validate:"min=1,max=10"` // BackgroundHealthCheckFailThrottleFactor is the factor of the host connect // time to use when sleeping between a failed health check and the next check. - BackgroundHealthCheckFailThrottleFactor float64 `yaml:"backgroundHealthCheckFailThrottleFactor" validate:"min=0,max=10"` + BackgroundHealthCheckFailThrottleFactor *float64 `yaml:"backgroundHealthCheckFailThrottleFactor" validate:"min=0,max=10"` // HashingConfiguration is the configuration for hashing of IDs to shards. - HashingConfiguration HashingConfiguration `yaml:"hashing"` + HashingConfiguration *HashingConfiguration `yaml:"hashing"` } // HashingConfiguration is the configuration for hashing @@ -177,19 +177,40 @@ func (c Configuration) NewAdminClient( v := NewAdminOptions(). SetTopologyInitializer(envCfg.TopologyInitializer). - SetWriteConsistencyLevel(c.WriteConsistencyLevel). - SetReadConsistencyLevel(c.ReadConsistencyLevel). - SetClusterConnectConsistencyLevel(c.ConnectConsistencyLevel). - SetBackgroundHealthCheckFailLimit(c.BackgroundHealthCheckFailLimit). - SetBackgroundHealthCheckFailThrottleFactor(c.BackgroundHealthCheckFailThrottleFactor). - SetWriteRequestTimeout(c.WriteTimeout). - SetFetchRequestTimeout(c.FetchTimeout). - SetClusterConnectTimeout(c.ConnectTimeout). - SetWriteRetrier(c.WriteRetry.NewRetrier(writeRequestScope)). - SetFetchRetrier(c.FetchRetry.NewRetrier(fetchRequestScope)). SetChannelOptions(xtchannel.NewDefaultChannelOptions()). SetInstrumentOptions(iopts) + if c.WriteConsistencyLevel != nil { + v = v.SetWriteConsistencyLevel(*c.WriteConsistencyLevel) + } + if c.ReadConsistencyLevel != nil { + v = v.SetReadConsistencyLevel(*c.ReadConsistencyLevel) + } + if c.ConnectConsistencyLevel != nil { + v.SetClusterConnectConsistencyLevel(*c.ConnectConsistencyLevel) + } + if c.BackgroundHealthCheckFailLimit != nil { + v = v.SetBackgroundHealthCheckFailLimit(*c.BackgroundHealthCheckFailLimit) + } + if c.BackgroundHealthCheckFailThrottleFactor != nil { + v = v.SetBackgroundHealthCheckFailThrottleFactor(*c.BackgroundHealthCheckFailThrottleFactor) + } + if c.WriteTimeout != nil { + v = v.SetWriteRequestTimeout(*c.WriteTimeout) + } + if c.FetchTimeout != nil { + v = v.SetFetchRequestTimeout(*c.FetchTimeout) + } + if c.ConnectTimeout != nil { + v = v.SetClusterConnectTimeout(*c.ConnectTimeout) + } + if c.WriteRetry != nil { + v = v.SetWriteRetrier(c.WriteRetry.NewRetrier(writeRequestScope)) + } + if c.FetchRetry != nil { + v = v.SetFetchRetrier(c.FetchRetry.NewRetrier(fetchRequestScope)) + } + encodingOpts := params.EncodingOptions if encodingOpts == nil { encodingOpts = encoding.NewOptions() diff --git a/src/dbnode/client/options.go b/src/dbnode/client/options.go index cbfdac0cc8..3a8cdadf40 100644 --- a/src/dbnode/client/options.go +++ b/src/dbnode/client/options.go @@ -65,13 +65,13 @@ const ( defaultHostConnectTimeout = 5 * time.Second // defaultClusterConnectTimeout is the default cluster connect timeout - defaultClusterConnectTimeout = 30 * time.Second + defaultClusterConnectTimeout = 20 * time.Second // defaultClusterConnectConsistencyLevel is the default cluster connect consistency level defaultClusterConnectConsistencyLevel = topology.ConnectConsistencyLevelAny // defaultWriteRequestTimeout is the default write request timeout - defaultWriteRequestTimeout = 5 * time.Second + defaultWriteRequestTimeout = 10 * time.Second // defaultFetchRequestTimeout is the default fetch request timeout defaultFetchRequestTimeout = 15 * time.Second @@ -120,7 +120,7 @@ const ( // defaultBackgroundHealthCheckFailLimit is the default background health failure // limit before connection is deemed unhealth - defaultBackgroundHealthCheckFailLimit = 3 + defaultBackgroundHealthCheckFailLimit = 4 // defaultBackgroundHealthCheckFailThrottleFactor is the default throttle factor to // apply when calculating how long to wait between a failed health check and a @@ -164,10 +164,20 @@ var ( defaultSeriesIteratorArrayPoolBuckets = []pool.Bucket{} // defaulWriteRetrier is the default write retrier for write attempts - defaultWriteRetrier = xretry.NewRetrier(xretry.NewOptions().SetMaxRetries(0)) + defaultWriteRetrier = xretry.NewRetrier( + xretry.NewOptions(). + SetInitialBackoff(500 * time.Millisecond). + SetBackoffFactor(3). + SetMaxRetries(2). + SetJitter(true)) // defaultFetchRetrier is the default fetch retrier for fetch attempts - defaultFetchRetrier = xretry.NewRetrier(xretry.NewOptions().SetMaxRetries(0)) + defaultFetchRetrier = xretry.NewRetrier( + xretry.NewOptions(). + SetInitialBackoff(500 * time.Millisecond). + SetBackoffFactor(2). + SetMaxRetries(3). + SetJitter(true)) // defaultStreamBlocksRetrier is the default retrier for streaming blocks defaultStreamBlocksRetrier = xretry.NewRetrier( diff --git a/src/query/api/v1/httpd/handler.go b/src/query/api/v1/httpd/handler.go index 27cff8e245..cebd5d75be 100644 --- a/src/query/api/v1/httpd/handler.go +++ b/src/query/api/v1/httpd/handler.go @@ -114,11 +114,12 @@ func NewHandler( if embeddedDbCfg == nil { timeoutOpts.FetchTimeout = defaultTimeout } else { - if embeddedDbCfg.Client.FetchTimeout < 0 { + if embeddedDbCfg.Client.FetchTimeout != nil || + *embeddedDbCfg.Client.FetchTimeout <= 0 { return nil, errors.New("m3db client fetch timeout should be > 0") } - timeoutOpts.FetchTimeout = embeddedDbCfg.Client.FetchTimeout + timeoutOpts.FetchTimeout = *embeddedDbCfg.Client.FetchTimeout } h := &Handler{ From f09c896475e1bd4ec013071e9396267c764cd66c Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:02:34 -0500 Subject: [PATCH 24/54] remove client config from example YAMLs --- kube/m3dbnode-configmap.yaml | 15 --------------- scripts/development/m3_stack/m3dbnode.yml | 15 --------------- src/dbnode/config/m3dbnode-cluster-template.yml | 15 --------------- src/dbnode/config/m3dbnode-local-etcd.yml | 15 --------------- src/dbnode/config/m3dbnode-local.yml | 15 --------------- .../benchmarker/main/m3dbnode-local-config.yaml | 15 --------------- src/query/benchmark/configs/m3db_config.yaml | 16 ---------------- .../m3dbnode-server1-config.yaml | 16 ---------------- .../m3dbnode-server2-config.yaml | 16 ---------------- .../m3dbnode-server3-config.yaml | 16 ---------------- 10 files changed, 154 deletions(-) diff --git a/kube/m3dbnode-configmap.yaml b/kube/m3dbnode-configmap.yaml index 68c2d8ba46..d7a6bae810 100644 --- a/kube/m3dbnode-configmap.yaml +++ b/kube/m3dbnode-configmap.yaml @@ -47,21 +47,6 @@ data: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/scripts/development/m3_stack/m3dbnode.yml b/scripts/development/m3_stack/m3dbnode.yml index 54e1836ed0..a4fc0a3bf2 100644 --- a/scripts/development/m3_stack/m3dbnode.yml +++ b/scripts/development/m3_stack/m3dbnode.yml @@ -22,21 +22,6 @@ db: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/dbnode/config/m3dbnode-cluster-template.yml b/src/dbnode/config/m3dbnode-cluster-template.yml index 836721b72d..0771ab56a4 100644 --- a/src/dbnode/config/m3dbnode-cluster-template.yml +++ b/src/dbnode/config/m3dbnode-cluster-template.yml @@ -64,21 +64,6 @@ db: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/dbnode/config/m3dbnode-local-etcd.yml b/src/dbnode/config/m3dbnode-local-etcd.yml index 0faa07d220..a8fb1249be 100644 --- a/src/dbnode/config/m3dbnode-local-etcd.yml +++ b/src/dbnode/config/m3dbnode-local-etcd.yml @@ -46,21 +46,6 @@ db: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/dbnode/config/m3dbnode-local.yml b/src/dbnode/config/m3dbnode-local.yml index aaee5ccf6b..75797f3066 100644 --- a/src/dbnode/config/m3dbnode-local.yml +++ b/src/dbnode/config/m3dbnode-local.yml @@ -43,21 +43,6 @@ db: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml b/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml index 76b353b600..376d3253a9 100644 --- a/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml +++ b/src/query/benchmark/benchmarker/main/m3dbnode-local-config.yaml @@ -24,21 +24,6 @@ client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority # clusterConnectConsistencyLevel: any - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/query/benchmark/configs/m3db_config.yaml b/src/query/benchmark/configs/m3db_config.yaml index 1c48f78b5e..c37a0f8e79 100644 --- a/src/query/benchmark/configs/m3db_config.yaml +++ b/src/query/benchmark/configs/m3db_config.yaml @@ -22,22 +22,6 @@ hostID: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - clusterConnectConsistencyLevel: any - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml index 515e1f9afd..4ff8319577 100644 --- a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml +++ b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server1-config.yaml @@ -21,22 +21,6 @@ hostID: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - clusterConnectConsistencyLevel: any - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml index 2908dba25e..26400ef6e6 100644 --- a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml +++ b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server2-config.yaml @@ -21,22 +21,6 @@ hostID: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - clusterConnectConsistencyLevel: any - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 diff --git a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml index 2fd87e42b1..5b51b307d9 100644 --- a/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml +++ b/src/query/benchmark/configs/multi_node_setup/m3dbnode-server3-config.yaml @@ -21,22 +21,6 @@ hostID: client: writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - clusterConnectConsistencyLevel: any - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 gcPercentage: 100 From a7137f847825e4e441dd153a821772b76a92336e Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:15:38 -0500 Subject: [PATCH 25/54] delete more client config from YAMLs --- scripts/development/m3_stack/m3coordinator.yml | 17 ----------------- .../carbon/m3coordinator.yml | 15 --------------- .../prometheus/m3coordinator.yml | 15 --------------- .../main/m3coordinator-local-config.yml | 17 ----------------- .../config/m3coordinator-cluster-template.yml | 15 --------------- src/query/config/m3coordinator-local-etcd.yml | 16 ---------------- 6 files changed, 95 deletions(-) diff --git a/scripts/development/m3_stack/m3coordinator.yml b/scripts/development/m3_stack/m3coordinator.yml index 6941e0c7df..cf47d98a1d 100644 --- a/scripts/development/m3_stack/m3coordinator.yml +++ b/scripts/development/m3_stack/m3coordinator.yml @@ -32,23 +32,6 @@ clusters: - zone: embedded endpoints: - m3db_seed:2379 - writeConsistencyLevel: majority - readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 ingest: ingester: diff --git a/scripts/docker-integration-tests/carbon/m3coordinator.yml b/scripts/docker-integration-tests/carbon/m3coordinator.yml index 4767acd3c3..f3d109ac2b 100644 --- a/scripts/docker-integration-tests/carbon/m3coordinator.yml +++ b/scripts/docker-integration-tests/carbon/m3coordinator.yml @@ -34,21 +34,6 @@ clusters: - dbnode01:2379 writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 carbon: ingester: diff --git a/scripts/docker-integration-tests/prometheus/m3coordinator.yml b/scripts/docker-integration-tests/prometheus/m3coordinator.yml index 23fe8d4e87..435bd48380 100644 --- a/scripts/docker-integration-tests/prometheus/m3coordinator.yml +++ b/scripts/docker-integration-tests/prometheus/m3coordinator.yml @@ -34,18 +34,3 @@ clusters: - dbnode01:2379 writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 diff --git a/src/query/benchmark/benchmarker/main/m3coordinator-local-config.yml b/src/query/benchmark/benchmarker/main/m3coordinator-local-config.yml index f09fc0c5fa..d43f378104 100644 --- a/src/query/benchmark/benchmarker/main/m3coordinator-local-config.yml +++ b/src/query/benchmark/benchmarker/main/m3coordinator-local-config.yml @@ -19,20 +19,3 @@ client: blockSize: 4h writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - connectConsistencyLevel: any - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 - diff --git a/src/query/config/m3coordinator-cluster-template.yml b/src/query/config/m3coordinator-cluster-template.yml index 94da40643f..59f462b366 100644 --- a/src/query/config/m3coordinator-cluster-template.yml +++ b/src/query/config/m3coordinator-cluster-template.yml @@ -35,18 +35,3 @@ clusters: ## ... etc, list only M3DB seed nodes # writeConsistencyLevel: majority # readConsistencyLevel: unstrict_majority -# writeTimeout: 10s -# fetchTimeout: 15s -# connectTimeout: 20s -# writeRetry: -# initialBackoff: 500ms -# backoffFactor: 3 -# maxRetries: 2 -# jitter: true -# fetchRetry: -# initialBackoff: 500ms -# backoffFactor: 2 -# maxRetries: 3 -# jitter: true -# backgroundHealthCheckFailLimit: 4 -# backgroundHealthCheckFailThrottleFactor: 0.5 diff --git a/src/query/config/m3coordinator-local-etcd.yml b/src/query/config/m3coordinator-local-etcd.yml index 4b65c4a423..5e1d04cc49 100644 --- a/src/query/config/m3coordinator-local-etcd.yml +++ b/src/query/config/m3coordinator-local-etcd.yml @@ -34,19 +34,3 @@ clusters: endpoint: http://127.0.0.1:2380 writeConsistencyLevel: majority readConsistencyLevel: unstrict_majority - writeTimeout: 10s - fetchTimeout: 15s - connectTimeout: 20s - writeRetry: - initialBackoff: 500ms - backoffFactor: 3 - maxRetries: 2 - jitter: true - fetchRetry: - initialBackoff: 500ms - backoffFactor: 2 - maxRetries: 3 - jitter: true - backgroundHealthCheckFailLimit: 4 - backgroundHealthCheckFailThrottleFactor: 0.5 - From e9d3be4c07fa663df06dd05cdc0a61b76a18a99e Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:18:08 -0500 Subject: [PATCH 26/54] chain function calls --- src/dbnode/server/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 7cdc349761..22616cb627 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -1186,8 +1186,9 @@ func poolOptions( if refillLowWaterMark > 0 && refillHighWaterMark > 0 && refillHighWaterMark > refillLowWaterMark { - opts = opts.SetRefillLowWatermark(refillLowWaterMark) - opts = opts.SetRefillHighWatermark(refillHighWaterMark) + opts = opts. + SetRefillLowWatermark(refillLowWaterMark). + SetRefillHighWatermark(refillHighWaterMark) } } if scope != nil { From 95e1790c80e682ea0668acb4f859805de4526e9b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:27:25 -0500 Subject: [PATCH 27/54] fix broken test --- src/dbnode/client/config_test.go | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/dbnode/client/config_test.go b/src/dbnode/client/config_test.go index 6c83081cc8..5245a36075 100644 --- a/src/dbnode/client/config_test.go +++ b/src/dbnode/client/config_test.go @@ -72,29 +72,40 @@ hashing: err = xconfig.LoadFile(&cfg, fd.Name(), xconfig.Options{}) require.NoError(t, err) - boolTrue := true + var ( + levelMajority = topology.ConsistencyLevelMajority + readUnstrictMajority = topology.ReadConsistencyLevelUnstrictMajority + connectAny = topology.ConnectConsistencyLevelAny + second10 = 10 * time.Second + second15 = 15 * time.Second + second20 = 20 * time.Second + num4 = 4 + numHalf = 0.5 + boolTrue = true + ) + expected := Configuration{ - WriteConsistencyLevel: topology.ConsistencyLevelMajority, - ReadConsistencyLevel: topology.ReadConsistencyLevelUnstrictMajority, - ConnectConsistencyLevel: topology.ConnectConsistencyLevelAny, - WriteTimeout: 10 * time.Second, - FetchTimeout: 15 * time.Second, - ConnectTimeout: 20 * time.Second, - WriteRetry: retry.Configuration{ + WriteConsistencyLevel: &levelMajority, + ReadConsistencyLevel: &readUnstrictMajority, + ConnectConsistencyLevel: &connectAny, + WriteTimeout: &second10, + FetchTimeout: &second15, + ConnectTimeout: &second20, + WriteRetry: &retry.Configuration{ InitialBackoff: 500 * time.Millisecond, BackoffFactor: 3, MaxRetries: 2, Jitter: &boolTrue, }, - FetchRetry: retry.Configuration{ + FetchRetry: &retry.Configuration{ InitialBackoff: 500 * time.Millisecond, BackoffFactor: 2, MaxRetries: 3, Jitter: &boolTrue, }, - BackgroundHealthCheckFailLimit: 4, - BackgroundHealthCheckFailThrottleFactor: 0.5, - HashingConfiguration: HashingConfiguration{ + BackgroundHealthCheckFailLimit: &num4, + BackgroundHealthCheckFailThrottleFactor: &numHalf, + HashingConfiguration: &HashingConfiguration{ Seed: 42, }, } From f0b8f4807a7903032fe8c71bdbce2e957ddab40d Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:27:29 -0500 Subject: [PATCH 28/54] fix lint issue --- src/cmd/services/m3dbnode/config/pooling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 08f80c956f..b807fbadfd 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -348,7 +348,7 @@ func (p *ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { // MaxFinalizerCapacityOrDefault returns the maximum finalizer capacity and // fallsback to the default value if its not set. -func (c ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { +func (p ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { if c.MaxFinalizerCapacity == 0 { return defaultMaxFinalizerCapacity } From 3e2bc91a55639206b864017ce354f15945540f72 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:29:20 -0500 Subject: [PATCH 29/54] fix compilation --- src/cmd/services/m3dbnode/config/pooling.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index b807fbadfd..d623cce072 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -349,11 +349,11 @@ func (p *ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { // MaxFinalizerCapacityOrDefault returns the maximum finalizer capacity and // fallsback to the default value if its not set. func (p ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { - if c.MaxFinalizerCapacity == 0 { + if p.MaxFinalizerCapacity == 0 { return defaultMaxFinalizerCapacity } - return c.MaxFinalizerCapacity + return p.MaxFinalizerCapacity } // DefaultPoolPolicy is the default pool policy. From 4d34b8ee89a86eb5e34a66f5bb61d0283f20f89f Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 12 Feb 2019 17:35:12 -0500 Subject: [PATCH 30/54] set no retries for client tests --- src/dbnode/client/session_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dbnode/client/session_test.go b/src/dbnode/client/session_test.go index d0370116a5..31c717569f 100644 --- a/src/dbnode/client/session_test.go +++ b/src/dbnode/client/session_test.go @@ -34,6 +34,7 @@ import ( "github.com/m3db/m3/src/x/serialize" "github.com/m3db/m3x/ident" "github.com/m3db/m3x/pool" + xretry "github.com/m3db/m3x/retry" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" @@ -107,6 +108,10 @@ func sessionTestHostAndShards( func applySessionTestOptions(opts Options) Options { shardSet := sessionTestShardSet() return opts. + // Some of the test mocks expect things to only happen once, so disable retries + // for the unit tests. + SetWriteRetrier(xretry.NewRetrier(xretry.NewOptions().SetMaxRetries(0))). + SetFetchRetrier(xretry.NewRetrier(xretry.NewOptions().SetMaxRetries(0))). SetSeriesIteratorPoolSize(0). SetSeriesIteratorArrayPoolBuckets([]pool.Bucket{}). SetWriteOpPoolSize(0). From efdbb901ad357c08bf256e675a93be745ad2548b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 09:30:33 -0500 Subject: [PATCH 31/54] Validate configs --- src/cmd/services/m3dbnode/config/config.go | 20 ++++++++++ src/cmd/services/m3dbnode/config/fs.go | 42 +++++++++++++++++++++ src/cmd/services/m3dbnode/config/pooling.go | 13 ++++--- src/cmd/services/m3dbnode/main/main.go | 5 +++ 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config.go b/src/cmd/services/m3dbnode/config/config.go index d0a84c36fc..4397918c2c 100644 --- a/src/cmd/services/m3dbnode/config/config.go +++ b/src/cmd/services/m3dbnode/config/config.go @@ -58,6 +58,16 @@ type Configuration struct { Coordinator *coordinatorcfg.Configuration `yaml:"coordinator"` } +// Validate validates the Configuration. We use this method to validate +// fields where the validator package falls short. +func (c Configuration) Validate() error { + if err := c.DB.Validate(); err != nil { + return err + } + + return nil +} + // DBConfiguration is the configuration for a DB node. type DBConfiguration struct { // Index configuration. @@ -133,6 +143,16 @@ type DBConfiguration struct { WriteNewSeriesAsync bool `yaml:"writeNewSeriesAsync"` } +// Validate validates the Configuration. We use this method to validate +// fields where the validator package falls short. +func (c DBConfiguration) Validate() error { + if err := c.Filesystem.Validate(); err != nil { + return err + } + + return nil +} + // IndexConfiguration contains index-specific configuration. type IndexConfiguration struct { // MaxQueryIDsConcurrency controls the maximum number of outstanding QueryID diff --git a/src/cmd/services/m3dbnode/config/fs.go b/src/cmd/services/m3dbnode/config/fs.go index d6aebb5598..9616b9865d 100644 --- a/src/cmd/services/m3dbnode/config/fs.go +++ b/src/cmd/services/m3dbnode/config/fs.go @@ -95,6 +95,48 @@ type FilesystemConfiguration struct { ForceBloomFilterMmapMemory *bool `yaml:"force_bloom_filter_mmap_memory"` } +// Validate validates the Filesystem configuration. We use this method to validate +// fields where the validator package falls short. +func (f FilesystemConfiguration) Validate() error { + if f.WriteBufferSize != nil && *f.WriteBufferSize < 1 { + return fmt.Errorf( + "fs writeBufferSize is set to: %d, but must be at least 1", + *f.WriteBufferSize) + } + + if f.DataReadBufferSize != nil && *f.DataReadBufferSize < 1 { + return fmt.Errorf( + "fs dataReadBufferSize is set to: %d, but must be at least 1", + *f.DataReadBufferSize) + } + + if f.InfoReadBufferSize != nil && *f.InfoReadBufferSize < 1 { + return fmt.Errorf( + "fs infoReadBufferSize is set to: %d, but must be at least 1", + *f.InfoReadBufferSize) + } + + if f.SeekReadBufferSize != nil && *f.SeekReadBufferSize < 1 { + return fmt.Errorf( + "fs seekReadBufferSize is set to: %d, but must be at least 1", + *f.SeekReadBufferSize) + } + + if f.ThroughputLimitMbps != nil && !(*f.ThroughputLimitMbps > 0) { + return fmt.Errorf( + "fs throughputLimitMbps is set to: %f, but must be larger than 0", + *f.ThroughputLimitMbps) + } + + if f.ThroughputCheckEvery != nil && !(*f.ThroughputCheckEvery > 0) { + return fmt.Errorf( + "fs throughputCheckEvery is set to: %d, but must be larger than 0", + *f.ThroughputCheckEvery) + } + + return nil +} + // FilePathPrefixOrDefault returns the configured file path prefix if configured, or a // default value otherwise. func (f FilesystemConfiguration) FilePathPrefixOrDefault() string { diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index d623cce072..6df0f8b95e 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -30,6 +30,7 @@ const ( const ( defaultMaxFinalizerCapacity = 4 + defaultBlockAllocSize = 16 defaultPoolSize = 4096 defaultRefillLowWaterMark = 0.0 @@ -202,7 +203,7 @@ func (p *PoolingPolicy) BlockAllocSizeOrDefault() int { return *p.BlockAllocSize } - return 16 + return defaultBlockAllocSize } // TypeOrDefault returns the configured pooling type if provided, or a default @@ -218,13 +219,13 @@ func (p *PoolingPolicy) TypeOrDefault() PoolingType { // PoolPolicy specifies a single pool policy. type PoolPolicy struct { // The size of the pool. - Size *int `yaml:"size"` + Size *int `yaml:"size" validate:"min=0.0,max=1.0"` // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark *float64 `yaml:"lowWatermark"` + RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark *float64 `yaml:"highWatermark"` + RefillHighWaterMark *float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` // Default values to be returned if the above values are not set. defaultSize int @@ -244,7 +245,7 @@ func (p *PoolPolicy) SizeOrDefault() int { // RefillLowWaterMarkOrDefault returns the configured refill low water mark if present, // or a default value otherwise. func (p *PoolPolicy) RefillLowWaterMarkOrDefault() float64 { - if p.RefillLowWaterMark != nil && *p.RefillLowWaterMark > 0 && *p.RefillLowWaterMark < 1 { + if p.RefillLowWaterMark != nil { return *p.RefillLowWaterMark } @@ -254,7 +255,7 @@ func (p *PoolPolicy) RefillLowWaterMarkOrDefault() float64 { // RefillHighWaterMarkOrDefault returns the configured refill high water mark if present, // or a default value otherwise. func (p *PoolPolicy) RefillHighWaterMarkOrDefault() float64 { - if p.RefillHighWaterMark != nil && *p.RefillHighWaterMark > 0 && *p.RefillHighWaterMark < 1 { + if p.RefillHighWaterMark != nil { return *p.RefillHighWaterMark } diff --git a/src/cmd/services/m3dbnode/main/main.go b/src/cmd/services/m3dbnode/main/main.go index 7962680f24..2d4dc10b23 100644 --- a/src/cmd/services/m3dbnode/main/main.go +++ b/src/cmd/services/m3dbnode/main/main.go @@ -52,6 +52,11 @@ func main() { os.Exit(1) } + if err := cfg.Validate(); err != nil { + fmt.Fprintf(os.Stderr, "configuration validation failed %v\n", err) + os.Exit(1) + } + var ( dbClientCh chan client.Client clusterClientCh chan clusterclient.Client From 86a09a648d0cc7f99a76840ef61459e8d86c8d89 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 09:38:52 -0500 Subject: [PATCH 32/54] fix broken tests --- src/query/api/v1/httpd/handler_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/query/api/v1/httpd/handler_test.go b/src/query/api/v1/httpd/handler_test.go index 24865ded47..a9d2c1ed6e 100644 --- a/src/query/api/v1/httpd/handler_test.go +++ b/src/query/api/v1/httpd/handler_test.go @@ -71,7 +71,8 @@ func TestHandlerFetchTimeoutError(t *testing.T) { storage, _ := m3.NewStorageAndSession(t, ctrl) downsamplerAndWriter := ingest.NewDownsamplerAndWriter(storage, nil, testWorkerPool) - dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: -1 * time.Second}} + neg1Sec := -1 * time.Second + dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: &neg1Sec}} _, err := NewHandler(downsamplerAndWriter, makeTagOptions(), executor.NewEngine(storage, tally.NewTestScope("test", nil), time.Minute), nil, nil, config.Configuration{LookbackDuration: &defaultLookbackDuration}, dbconfig, tally.NewTestScope("", nil)) require.Error(t, err) @@ -84,7 +85,8 @@ func TestHandlerFetchTimeout(t *testing.T) { storage, _ := m3.NewStorageAndSession(t, ctrl) downsamplerAndWriter := ingest.NewDownsamplerAndWriter(storage, nil, testWorkerPool) - dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: 4 * time.Minute}} + fourMin := 4 * time.Minute + dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: &fourMin}} h, err := NewHandler(downsamplerAndWriter, makeTagOptions(), executor.NewEngine(storage, tally.NewTestScope("test", nil), time.Minute), nil, nil, config.Configuration{LookbackDuration: &defaultLookbackDuration}, dbconfig, tally.NewTestScope("", nil)) require.NoError(t, err) From 5afac43beedb32fa5894838ea9b9746b9c5edcbb Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 09:42:54 -0500 Subject: [PATCH 33/54] fix tests --- src/query/api/v1/httpd/handler.go | 5 ++--- src/query/api/v1/httpd/handler_test.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/query/api/v1/httpd/handler.go b/src/query/api/v1/httpd/handler.go index cebd5d75be..03c85c8fa2 100644 --- a/src/query/api/v1/httpd/handler.go +++ b/src/query/api/v1/httpd/handler.go @@ -111,11 +111,10 @@ func NewHandler( } var timeoutOpts = &prometheus.TimeoutOpts{} - if embeddedDbCfg == nil { + if embeddedDbCfg == nil || embeddedDbCfg.Client.FetchTimeout == nil { timeoutOpts.FetchTimeout = defaultTimeout } else { - if embeddedDbCfg.Client.FetchTimeout != nil || - *embeddedDbCfg.Client.FetchTimeout <= 0 { + if *embeddedDbCfg.Client.FetchTimeout <= 0 { return nil, errors.New("m3db client fetch timeout should be > 0") } diff --git a/src/query/api/v1/httpd/handler_test.go b/src/query/api/v1/httpd/handler_test.go index a9d2c1ed6e..7897dac6b6 100644 --- a/src/query/api/v1/httpd/handler_test.go +++ b/src/query/api/v1/httpd/handler_test.go @@ -71,8 +71,8 @@ func TestHandlerFetchTimeoutError(t *testing.T) { storage, _ := m3.NewStorageAndSession(t, ctrl) downsamplerAndWriter := ingest.NewDownsamplerAndWriter(storage, nil, testWorkerPool) - neg1Sec := -1 * time.Second - dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: &neg1Sec}} + negValue := -1 * time.Second + dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: &negValue}} _, err := NewHandler(downsamplerAndWriter, makeTagOptions(), executor.NewEngine(storage, tally.NewTestScope("test", nil), time.Minute), nil, nil, config.Configuration{LookbackDuration: &defaultLookbackDuration}, dbconfig, tally.NewTestScope("", nil)) require.Error(t, err) From f9fab8443de4b63117b4ea910da8dbc04ce83904 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 10:20:27 -0500 Subject: [PATCH 34/54] wip --- src/cmd/services/m3dbnode/config/config_test.go | 3 +++ src/cmd/services/m3dbnode/config/pooling.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/config/config_test.go b/src/cmd/services/m3dbnode/config/config_test.go index c1126f08c2..c853d1f399 100644 --- a/src/cmd/services/m3dbnode/config/config_test.go +++ b/src/cmd/services/m3dbnode/config/config_test.go @@ -21,6 +21,7 @@ package config import ( + "fmt" "io/ioutil" "os" "testing" @@ -610,6 +611,8 @@ coordinator: null ` actual := string(data) + fmt.Println("exp: ", expected) + fmt.Println("act: ", actual) if expected != actual { diff := xtest.Diff(expected, actual) require.FailNow(t, "reverse config did not match:\n"+diff) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 6df0f8b95e..65592133f3 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -219,7 +219,7 @@ func (p *PoolingPolicy) TypeOrDefault() PoolingType { // PoolPolicy specifies a single pool policy. type PoolPolicy struct { // The size of the pool. - Size *int `yaml:"size" validate:"min=0.0,max=1.0"` + Size *int `yaml:"size" validate:"min=0"` // The low watermark to start refilling the pool, if zero none. RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` From b4fe06ba60e6d9d221447166c6db9c04cb72162b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 11:53:28 -0500 Subject: [PATCH 35/54] fix broken test --- src/cmd/services/m3dbnode/config/config_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config_test.go b/src/cmd/services/m3dbnode/config/config_test.go index c853d1f399..a32342a2c4 100644 --- a/src/cmd/services/m3dbnode/config/config_test.go +++ b/src/cmd/services/m3dbnode/config/config_test.go @@ -21,7 +21,6 @@ package config import ( - "fmt" "io/ioutil" "os" "testing" @@ -344,10 +343,7 @@ func TestConfiguration(t *testing.T) { envVarName: null file: null client: - config: - service: null - static: null - seedNodes: null + config: null writeConsistencyLevel: 2 readConsistencyLevel: 2 connectConsistencyLevel: 0 @@ -611,8 +607,6 @@ coordinator: null ` actual := string(data) - fmt.Println("exp: ", expected) - fmt.Println("act: ", actual) if expected != actual { diff := xtest.Diff(expected, actual) require.FailNow(t, "reverse config did not match:\n"+diff) From 9bad14f7b7cf7feb6c021c542366a6cdb3266e41 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 11:55:31 -0500 Subject: [PATCH 36/54] remove bounds checks --- src/cmd/services/m3dbnode/config/fs.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/fs.go b/src/cmd/services/m3dbnode/config/fs.go index 9616b9865d..31eeaf050c 100644 --- a/src/cmd/services/m3dbnode/config/fs.go +++ b/src/cmd/services/m3dbnode/config/fs.go @@ -98,37 +98,37 @@ type FilesystemConfiguration struct { // Validate validates the Filesystem configuration. We use this method to validate // fields where the validator package falls short. func (f FilesystemConfiguration) Validate() error { - if f.WriteBufferSize != nil && *f.WriteBufferSize < 1 { + if f.WriteBufferSize != nil { return fmt.Errorf( "fs writeBufferSize is set to: %d, but must be at least 1", *f.WriteBufferSize) } - if f.DataReadBufferSize != nil && *f.DataReadBufferSize < 1 { + if f.DataReadBufferSize != nil { return fmt.Errorf( "fs dataReadBufferSize is set to: %d, but must be at least 1", *f.DataReadBufferSize) } - if f.InfoReadBufferSize != nil && *f.InfoReadBufferSize < 1 { + if f.InfoReadBufferSize != nil { return fmt.Errorf( "fs infoReadBufferSize is set to: %d, but must be at least 1", *f.InfoReadBufferSize) } - if f.SeekReadBufferSize != nil && *f.SeekReadBufferSize < 1 { + if f.SeekReadBufferSize != nil { return fmt.Errorf( "fs seekReadBufferSize is set to: %d, but must be at least 1", *f.SeekReadBufferSize) } - if f.ThroughputLimitMbps != nil && !(*f.ThroughputLimitMbps > 0) { + if f.ThroughputLimitMbps != nil { return fmt.Errorf( "fs throughputLimitMbps is set to: %f, but must be larger than 0", *f.ThroughputLimitMbps) } - if f.ThroughputCheckEvery != nil && !(*f.ThroughputCheckEvery > 0) { + if f.ThroughputCheckEvery != nil { return fmt.Errorf( "fs throughputCheckEvery is set to: %d, but must be larger than 0", *f.ThroughputCheckEvery) From 5fffe3cf2f36bacb9759498499c8bf08481ff5ce Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 12:13:34 -0500 Subject: [PATCH 37/54] Add commented all-config file --- src/dbnode/config/m3dbnode-all-config.yml | 276 ++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 src/dbnode/config/m3dbnode-all-config.yml diff --git a/src/dbnode/config/m3dbnode-all-config.yml b/src/dbnode/config/m3dbnode-all-config.yml new file mode 100644 index 0000000000..8155709b8a --- /dev/null +++ b/src/dbnode/config/m3dbnode-all-config.yml @@ -0,0 +1,276 @@ +# Include this field if you want to enable an embedded M3Coordinator instance. +coordinator: + # Address for M3Coordinator to listen for traffic. + listenAddress: + type: "config" + value: "0.0.0.0:7201" + + # All configured M3DB namespaces must be listed in this config if running an + # embedded M3Coordinator instance. + local: + namespaces: + - namespace: default + type: unaggregated + retention: 48h + + # Configuration for emitting M3Coordinator metrics. + metrics: + scope: + # Prefix to apply to all metrics. + prefix: "coordinator" + prometheus: + # Path and address to expose Prometheus scrape endpoint. + handlerPath: /metrics + listenAddress: 0.0.0.0:7203 # until https://github.com/m3db/m3/issues/682 is resolved + sanitization: prometheus + # Sampling rate for metrics, use 1.0 for no sampling. + samplingRate: 1.0 + extended: none + + limits: + maxComputedDatapoints: 10000 + +db: + # Minimum log level which will be emitted. + logging: + level: info + + # Configuration for emitting M3DB metrics. + metrics: + prometheus: + # Path to expose Prometheus scrape endpoint. + handlerPath: /metrics + sanitization: prometheus + # Sampling rate for metrics, use 1.0 for no sampling. + samplingRate: 1.0 + extended: detailed + + # Address to listen on for local thrift/tchannel APIs. + listenAddress: 0.0.0.0:9000 + # Address to listen on for cluster thrift/tchannel APIs. + clusterListenAddress: 0.0.0.0:9001 + # Address to listen on for local json/http APIs (used for debugging primarily). + httpNodeListenAddress: 0.0.0.0:9002 + # Address to listen on for cluster json/http APIs (used for debugging primarily). + httpClusterListenAddress: 0.0.0.0:9003 + # Address to listen on for debug APIs (pprof, etc). + debugListenAddress: 0.0.0.0:9004 + + # Configuration for resolving the instances host ID. + hostID: + # "Config" resolver states that the host ID will be resolved from this file. + resolver: config + value: m3db_local + + client: + # Consistency level for writes. + writeConsistencyLevel: majority + # Consistency level for reads. + readConsistencyLevel: unstrict_majority + # Timeout for writes. + writeTimeout: 10s + # Timeout for reads. + fetchTimeout: 15s + # Timeout for establishing a connection to the cluster. + connectTimeout: 20s + # Configuration for retrying writes. + writeRetry: + initialBackoff: 500ms + backoffFactor: 3 + maxRetries: 2 + jitter: true + # Configuration for retrying reads. + fetchRetry: + initialBackoff: 500ms + backoffFactor: 2 + maxRetries: 3 + jitter: true + # Number of times we background health check for a node can fail before + # considering the node unhealthy. + backgroundHealthCheckFailLimit: 4 + backgroundHealthCheckFailThrottleFactor: 0.5 + + # Sets GOGC value. + gcPercentage: 100 + + # Whether new series should be created asynchronously (recommended value + # of true for high throughput.) + writeNewSeriesAsync: true + # Maximum number of new series that can be created per second. + writeNewSeriesLimitPerSecond: 1048576 + writeNewSeriesBackoffDuration: 2ms + + bootstrap: + # Order in which to run the bootstrappers. Don't change these values unless + # you know what you're doing as non-standard configurations can cause data + # loss or make recovery from disaster scenarios difficult. + bootstrappers: + - filesystem + - commitlog + - peers + - uninitialized_topology + fs: + numProcessorsPerCPU: 0.125 + + cache: + # Caching policy for database blocks. + series: + policy: lru + + commitlog: + # Maximum number of bytes that will be buffered before flushing the commitlog. + flushMaxBytes: 524288 + # Maximum amount of time data can remain buffered before flushing the commitlog. + flushEvery: 1s + # Configuration for the commitlog queue. High throughput setups may require higher + # values. Higher values will use more memory. + queue: + calculationType: fixed + size: 2097152 + blockSize: 10m + + fs: + # Directory to store M3DB data in. + filePathPrefix: /var/lib/m3db + # Various fixed-sized buffers used for M3DB I/O. + writeBufferSize: 65536 + dataReadBufferSize: 65536 + infoReadBufferSize: 128 + seekReadBufferSize: 4096 + # Maximum Mib/s that can be written to disk by background operations like flushing + # and snapshotting to prevent them from interfering with the commitlog. Increasing + # this value can make node adds significantly faster if the underlyign disk can + # support the throughput. + throughputLimitMbps: 100.0 + throughputCheckEvery: 128 + + # This feature is currently not working, do not enable. + repair: + enabled: false + interval: 2h + offset: 30m + jitter: 1h + throttle: 2m + checkInterval: 1m + + # Configuration for various different object pools that M3DB uses. + pooling: + blockAllocSize: 16 + type: simple + seriesPool: + size: 262144 + lowWatermark: 0.7 + highWatermark: 1.0 + blockPool: + size: 262144 + lowWatermark: 0.7 + highWatermark: 1.0 + encoderPool: + size: 262144 + lowWatermark: 0.7 + highWatermark: 1.0 + closersPool: + size: 104857 + lowWatermark: 0.7 + highWatermark: 1.0 + contextPool: + size: 262144 + lowWatermark: 0.7 + highWatermark: 1.0 + segmentReaderPool: + size: 16384 + lowWatermark: 0.7 + highWatermark: 1.0 + iteratorPool: + size: 2048 + lowWatermark: 0.7 + highWatermark: 1.0 + fetchBlockMetadataResultsPool: + size: 65536 + capacity: 32 + lowWatermark: 0.7 + highWatermark: 1.0 + fetchBlocksMetadataResultsPool: + size: 32 + capacity: 4096 + lowWatermark: 0.7 + highWatermark: 1.0 + hostBlockMetadataSlicePool: + size: 131072 + capacity: 3 + lowWatermark: 0.7 + highWatermark: 1.0 + blockMetadataPool: + size: 65536 + lowWatermark: 0.7 + highWatermark: 1.0 + blockMetadataSlicePool: + size: 65536 + capacity: 32 + lowWatermark: 0.7 + highWatermark: 1.0 + blocksMetadataPool: + size: 65536 + lowWatermark: 0.7 + highWatermark: 1.0 + blocksMetadataSlicePool: + size: 32 + capacity: 4096 + lowWatermark: 0.7 + highWatermark: 1.0 + identifierPool: + size: 262144 + lowWatermark: 0.7 + highWatermark: 1.0 + bytesPool: + buckets: + - capacity: 16 + size: 524288 + lowWatermark: 0.7 + highWatermark: 1.0 + - capacity: 32 + size: 262144 + lowWatermark: 0.7 + highWatermark: 1.0 + - capacity: 64 + size: 131072 + lowWatermark: 0.7 + highWatermark: 1.0 + - capacity: 128 + size: 65536 + lowWatermark: 0.7 + highWatermark: 1.0 + - capacity: 256 + size: 65536 + lowWatermark: 0.7 + highWatermark: 1.0 + - capacity: 1440 + size: 16384 + lowWatermark: 0.7 + highWatermark: 1.0 + - capacity: 4096 + size: 8192 + lowWatermark: 0.7 + highWatermark: 1.0 + + # etcd configuration. + config: + service: + # KV environment, zone, and service from which to write/read KV data (placement + # and configuration). Leave these as the default values unless you know what + # you're doing. + env: default_env + zone: embedded + service: m3db + # Directory to store cached etcd data in. + cacheDir: /var/lib/m3kv + # Configuration to identify the etcd hosts this node should connect to. + etcdClusters: + - zone: embedded + endpoints: + - 127.0.0.1:2379 + # Should only be present if running an M3DB cluster with embedded etcd. + seedNodes: + initialCluster: + - hostID: m3db_local + endpoint: http://127.0.0.1:2380 From b031b75e7e0f10564339b492bf76d02e72ce3a6c Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 12:57:23 -0500 Subject: [PATCH 38/54] fix broken test --- src/query/server/server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/query/server/server.go b/src/query/server/server.go index 76d19e9701..390b71b35f 100644 --- a/src/query/server/server.go +++ b/src/query/server/server.go @@ -351,6 +351,7 @@ func newM3DBStorage( etcdCfg = &cfg.ClusterManagement.Etcd case len(cfg.Clusters) == 1 && + cfg.Clusters[0].Client.EnvironmentConfig != nil && cfg.Clusters[0].Client.EnvironmentConfig.Service != nil: etcdCfg = cfg.Clusters[0].Client.EnvironmentConfig.Service } From 2b0d2f2f1a4eda8055aef2037495d4db9371adc1 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 14:40:19 -0500 Subject: [PATCH 39/54] add pool validation --- src/cmd/services/m3dbnode/config/pooling.go | 115 +++++++++++++++++++- 1 file changed, 112 insertions(+), 3 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 65592133f3..43bfb0e89f 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -20,6 +20,8 @@ package config +import "fmt" + // PoolingType is a type of pooling, using runtime or mmap'd bytes pooling. type PoolingType string @@ -174,6 +176,7 @@ type PoolingPolicy struct { // The policy for the BlocksMetadataSlice pool. BlocksMetadataSlicePool BlocksMetadataSlicePool `yaml:"blocksMetadataSlicePool"` + // TODO: Fix me // The policy for the tags pool. TagsPool MaxCapacityPoolPolicy `yaml:"tagsPool"` @@ -196,6 +199,78 @@ type PoolingPolicy struct { PostingsListPool PostingsListPool `yaml:"postingsListPool"` } +// Validate validates the pooling policy config. +func (p *PoolingPolicy) Validate() error { + if err := p.ClosersPool.Validate("closersPool"); err != nil { + return err + } + if err := p.ContextPool.Validate("contextPool"); err != nil { + return err + } + if err := p.SeriesPool.Validate("seriesPool"); err != nil { + return err + } + if err := p.BlockPool.Validate("blockPool"); err != nil { + return err + } + if err := p.EncoderPool.Validate("encoderPool"); err != nil { + return err + } + if err := p.IteratorPool.Validate("iteratorPool"); err != nil { + return err + } + if err := p.SegmentReaderPool.Validate("segmentReaderPool"); err != nil { + return err + } + if err := p.IdentifierPool.Validate("identifierPool"); err != nil { + return err + } + if err := p.FetchBlockMetadataResultsPool.Validate("fetchBlockMetadataResultsPool"); err != nil { + return err + } + if err := p.FetchBlocksMetadataResultsPool.Validate("fetchBlocksMetadataResultsPool"); err != nil { + return err + } + if err := p.HostBlockMetadataSlicePool.Validate("hostBlockMetadataSlicePool"); err != nil { + return err + } + if err := p.BlockMetadataPool.Validate("blockMetadataPool"); err != nil { + return err + } + if err := p.BlockMetadataSlicePool.Validate("blockMetadataSlicePool"); err != nil { + return err + } + if err := p.BlocksMetadataPool.Validate("blocksMetadataPool"); err != nil { + return err + } + if err := p.BlocksMetadataSlicePool.Validate("blocksMetadataSlicePool"); err != nil { + return err + } + // TODO: tag pool + // if err := p.TagsPool.Validate("tagsPool"); err != nil { + // return err + // } + if err := p.TagsIteratorPool.Validate("tagsIteratorPool"); err != nil { + return err + } + if err := p.IndexResultsPool.Validate("indexResultsPool"); err != nil { + return err + } + if err := p.TagEncoderPool.Validate("tagEncoderPool"); err != nil { + return err + } + if err := p.TagDecoderPool.Validate("tagDecoderPool"); err != nil { + return err + } + // TODO: Write batch pool + // if err := p.WriteBatchPool.Validate("WriteBatchPool"); err != nil { + // return err + // } + // TODO: POSTINGS LIST POOL + + return nil +} + // BlockAllocSizeOrDefault returns the configured block alloc size if provided, // or a default value otherwise. func (p *PoolingPolicy) BlockAllocSizeOrDefault() int { @@ -219,13 +294,13 @@ func (p *PoolingPolicy) TypeOrDefault() PoolingType { // PoolPolicy specifies a single pool policy. type PoolPolicy struct { // The size of the pool. - Size *int `yaml:"size" validate:"min=0"` + Size *int `yaml:"size"` // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark *float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` + RefillLowWaterMark *float64 `yaml:"lowWatermark"` // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark *float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + RefillHighWaterMark *float64 `yaml:"highWatermark"` // Default values to be returned if the above values are not set. defaultSize int @@ -233,6 +308,23 @@ type PoolPolicy struct { defaultRefillHighWaterMark float64 } +// Validate validates the pool policy config. +func (p *PoolPolicy) Validate(poolName string) error { + if p.RefillLowWaterMark != nil && (*p.RefillLowWaterMark < 0 || *p.RefillLowWaterMark > 1) { + return fmt.Errorf( + "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", + poolName) + } + + if p.RefillHighWaterMark != nil && (*p.RefillHighWaterMark < 0 || *p.RefillHighWaterMark > 1) { + return fmt.Errorf( + "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", + poolName) + } + + return nil +} + // SizeOrDefault returns the configured size if present, or a default value otherwise. func (p *PoolPolicy) SizeOrDefault() int { if p.Size != nil { @@ -284,6 +376,23 @@ type CapacityPoolPolicy struct { defaultRefillHighWaterMark float64 } +// Validate validates the pool policy config. +func (p *CapacityPoolPolicy) Validate(poolName string) error { + if p.RefillLowWaterMark < 0 || p.RefillLowWaterMark > 1 { + return fmt.Errorf( + "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", + poolName) + } + + if p.RefillHighWaterMark < 0 || p.RefillHighWaterMark > 1 { + return fmt.Errorf( + "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", + poolName) + } + + return nil +} + // MaxCapacityPoolPolicy specifies a single pool policy that has a // per element capacity, and a maximum allowed capacity as well. type MaxCapacityPoolPolicy struct { From bb5b371f4cfbcc665edfcb9d94139b01afbf1d58 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 15:58:54 -0500 Subject: [PATCH 40/54] more pooling config nonsense --- src/cmd/services/m3dbnode/config/pooling.go | 147 +++++++++--------- src/cmd/services/m3dbnode/main/common_test.go | 1 - src/cmd/services/m3dbnode/main/main_test.go | 1 - src/dbnode/server/server.go | 84 ++++++---- 4 files changed, 127 insertions(+), 106 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 43bfb0e89f..2ca453619e 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -76,46 +76,60 @@ const ( var ( defaultBytesPoolBuckets = []CapacityPoolPolicy{ { - Capacity: 16, - Size: 524288, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 16, + PoolPolicy: PoolPolicy{ + defaultSize: 524288, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, { - Capacity: 32, - Size: 262144, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 32, + PoolPolicy: PoolPolicy{ + defaultSize: 262144, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, { - Capacity: 64, - Size: 131072, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 64, + PoolPolicy: PoolPolicy{ + defaultSize: 131072, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, { - Capacity: 128, - Size: 65536, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 128, + PoolPolicy: PoolPolicy{ + defaultSize: 65536, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, { - Capacity: 256, - Size: 65536, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 256, + PoolPolicy: PoolPolicy{ + defaultSize: 65536, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, { - Capacity: 1440, - Size: 16384, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 1440, + PoolPolicy: PoolPolicy{ + defaultSize: 16384, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, { - Capacity: 4096, - Size: 8192, - RefillLowWaterMark: 0.7, - RefillHighWaterMark: 1.0, + defaultCapacity: 4096, + PoolPolicy: PoolPolicy{ + defaultSize: 8192, + defaultRefillLowWaterMark: 0.7, + defaultRefillHighWaterMark: 1.0, + }, }, } ) @@ -246,10 +260,9 @@ func (p *PoolingPolicy) Validate() error { if err := p.BlocksMetadataSlicePool.Validate("blocksMetadataSlicePool"); err != nil { return err } - // TODO: tag pool - // if err := p.TagsPool.Validate("tagsPool"); err != nil { - // return err - // } + if err := p.TagsPool.Validate("tagsPool"); err != nil { + return err + } if err := p.TagsIteratorPool.Validate("tagsIteratorPool"); err != nil { return err } @@ -262,12 +275,9 @@ func (p *PoolingPolicy) Validate() error { if err := p.TagDecoderPool.Validate("tagDecoderPool"); err != nil { return err } - // TODO: Write batch pool - // if err := p.WriteBatchPool.Validate("WriteBatchPool"); err != nil { - // return err - // } - // TODO: POSTINGS LIST POOL - + if err := p.PostingsListPool.Validate("postingsListPool"); err != nil { + return err + } return nil } @@ -357,59 +367,44 @@ func (p *PoolPolicy) RefillHighWaterMarkOrDefault() float64 { // CapacityPoolPolicy specifies a single pool policy that has a // per element capacity. type CapacityPoolPolicy struct { - // The size of the pool. - Size int `yaml:"size"` + PoolPolicy `yaml:",inline"` // The capacity of items in the pool. - Capacity int `yaml:"capacity"` - - // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` - - // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` + Capacity *int `yaml:"capacity"` // Default values to be returned if the above values are not set. - defaultSize int - defaultCapacity int - defaultRefillLowWaterMark float64 - defaultRefillHighWaterMark float64 + defaultCapacity int } -// Validate validates the pool policy config. +// Validate validates the capacity pool policy config. func (p *CapacityPoolPolicy) Validate(poolName string) error { - if p.RefillLowWaterMark < 0 || p.RefillLowWaterMark > 1 { - return fmt.Errorf( - "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", - poolName) + if err := p.PoolPolicy.Validate(poolName); err != nil { + return err } - if p.RefillHighWaterMark < 0 || p.RefillHighWaterMark > 1 { - return fmt.Errorf( - "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", - poolName) + if p.Capacity != nil && *p.Capacity < 0 { + return fmt.Errorf("capacity of %s pool must be 0 or larger", poolName) } return nil } +// CapacityOrDefault returns the configured capacity if present, or a default value otherwise. +func (p *CapacityPoolPolicy) CapacityOrDefault() int { + if p.Capacity != nil { + return *p.Capacity + } + + return p.defaultCapacity +} + // MaxCapacityPoolPolicy specifies a single pool policy that has a // per element capacity, and a maximum allowed capacity as well. type MaxCapacityPoolPolicy struct { - // The size of the pool. - Size int `yaml:"size"` - - // The capacity of items in the pool. - Capacity int `yaml:"capacity"` + CapacityPoolPolicy `yaml:",inline"` // The max capacity of items in the pool. MaxCapacity int `yaml:"maxCapacity"` - - // The low watermark to start refilling the pool, if zero none. - RefillLowWaterMark float64 `yaml:"lowWatermark" validate:"min=0.0,max=1.0"` - - // The high watermark to stop refilling the pool, if zero none. - RefillHighWaterMark float64 `yaml:"highWatermark" validate:"min=0.0,max=1.0"` } // BucketPoolPolicy specifies a bucket pool policy. @@ -423,6 +418,9 @@ type BucketPoolPolicy struct { // WriteBatchPoolPolicy specifies the pooling policy for the WriteBatch pool. type WriteBatchPoolPolicy struct { + // The size of the pool. + Size *int `yaml:"size"` + // InitialBatchSize controls the initial batch size for each WriteBatch when // the pool is being constructed / refilled. InitialBatchSize *int `yaml:"initialBatchSize"` @@ -430,9 +428,6 @@ type WriteBatchPoolPolicy struct { // MaxBatchSize controls the maximum size that a pooled WriteBatch can grow to // and still remain in the pool. MaxBatchSize *int `yaml:"maxBatchSize"` - - // Pool is the Pooling Policy for the WriteBatch pool. - Pool PoolPolicy `yaml:"pool"` } // ContextPoolPolicy specifies the policy for the context pool. @@ -723,3 +718,7 @@ func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark return policy } + +func intPtr(x int) *int { + return &x +} diff --git a/src/cmd/services/m3dbnode/main/common_test.go b/src/cmd/services/m3dbnode/main/common_test.go index 178080ef83..49b4cb8acd 100644 --- a/src/cmd/services/m3dbnode/main/common_test.go +++ b/src/cmd/services/m3dbnode/main/common_test.go @@ -1,4 +1,3 @@ -// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 10e68061a4..8127e25334 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -1,4 +1,3 @@ -// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 22616cb627..18e23d4d3e 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -939,11 +939,11 @@ func withEncodingAndPoolingOptions( buckets := make([]pool.Bucket, len(policy.BytesPool.Buckets)) for i, bucket := range policy.BytesPool.Buckets { var b pool.Bucket - b.Capacity = bucket.Capacity - b.Count = bucket.Size + b.Capacity = bucket.CapacityOrDefault() + b.Count = bucket.SizeOrDefault() b.Options = bytesPoolOpts. - SetRefillLowWatermark(bucket.RefillLowWaterMark). - SetRefillHighWatermark(bucket.RefillHighWaterMark) + SetRefillLowWatermark(bucket.RefillLowWaterMarkOrDefault()). + SetRefillHighWatermark(bucket.RefillHighWaterMarkOrDefault()) buckets[i] = b logger.Infof("bytes pool registering bucket capacity=%d, size=%d, "+ "refillLowWatermark=%f, refillHighWatermark=%f", @@ -1016,11 +1016,10 @@ func withEncodingAndPoolingOptions( writeBatchPoolMaxBatchSize = policy.WriteBatchPool.MaxBatchSize } - writeBatchPoolPolicy := poolOptions( - policy.WriteBatchPool.Pool, - scope.SubScope("write-batch-pool"), - ) - if writeBatchPoolPolicy.Size() == 0 { + var writeBatchPoolSize int + if policy.WriteBatchPool.Size != nil { + writeBatchPoolSize = *policy.WriteBatchPool.Size + } else { // If no value set, calculate a reasonable value based on the commit log // queue size. We base it off the commitlog queue size because we will // want to be able to buffer at least one full commitlog queues worth of @@ -1028,10 +1027,23 @@ func withEncodingAndPoolingOptions( // allocate. commitlogQueueSize := opts.CommitLogOptions().BacklogQueueSize() expectedBatchSize := *writeBatchPoolInitialBatchSize - writeBatchPoolPolicy = writeBatchPoolPolicy.SetSize(commitlogQueueSize / expectedBatchSize) + writeBatchPoolSize = commitlogQueueSize / expectedBatchSize } + + writeBatchPoolOpts := pool.NewObjectPoolOptions() + writeBatchPoolOpts = writeBatchPoolOpts. + SetSize(writeBatchPoolSize). + // Set watermarks to zero because this pool is sized to be as large as we + // ever need it to be, so background allocations are usually wasteful. + SetRefillLowWatermark(0.0). + SetRefillHighWatermark(0.0). + SetInstrumentOptions( + writeBatchPoolOpts. + InstrumentOptions(). + SetMetricsScope(scope.SubScope("write-batch-pool"))) + writeBatchPool := ts.NewWriteBatchPool( - writeBatchPoolPolicy, + writeBatchPoolOpts, writeBatchPoolInitialBatchSize, writeBatchPoolMaxBatchSize) @@ -1039,7 +1051,7 @@ func withEncodingAndPoolingOptions( IDPoolOptions: poolOptions( policy.IdentifierPool.PoolPolicyOrDefault(), scope.SubScope("identifier-pool")), TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), - TagsCapacity: policy.TagsPool.Capacity, + TagsCapacity: policy.TagsPool.CapacityOrDefault(), TagsMaxCapacity: policy.TagsPool.MaxCapacity, TagsIteratorPoolOptions: poolOptions( policy.TagsIteratorPool.PoolPolicyOrDefault(), @@ -1049,12 +1061,12 @@ func withEncodingAndPoolingOptions( fetchBlockMetadataResultsPool := block.NewFetchBlockMetadataResultsPool( capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicyOrDefault(), scope.SubScope("fetch-block-metadata-results-pool")), - policy.FetchBlockMetadataResultsPool.Capacity) + policy.FetchBlockMetadataResultsPool.CapacityOrDefault()) fetchBlocksMetadataResultsPool := block.NewFetchBlocksMetadataResultsPool( capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicyOrDefault(), scope.SubScope("fetch-blocks-metadata-results-pool")), - policy.FetchBlocksMetadataResultsPool.Capacity) + policy.FetchBlocksMetadataResultsPool.CapacityOrDefault()) encodingOpts := encoding.NewOptions(). SetEncoderPool(encoderPool). @@ -1202,14 +1214,20 @@ func capacityPoolOptions( policy config.CapacityPoolPolicy, scope tally.Scope, ) pool.ObjectPoolOptions { - opts := pool.NewObjectPoolOptions() - if policy.Size > 0 { - opts = opts.SetSize(policy.Size) - if policy.RefillLowWaterMark > 0 && - policy.RefillHighWaterMark > 0 && - policy.RefillHighWaterMark > policy.RefillLowWaterMark { - opts = opts.SetRefillLowWatermark(policy.RefillLowWaterMark) - opts = opts.SetRefillHighWatermark(policy.RefillHighWaterMark) + var ( + opts = pool.NewObjectPoolOptions() + size = policy.SizeOrDefault() + refillLowWaterMark = policy.RefillLowWaterMarkOrDefault() + refillHighWaterMark = policy.RefillHighWaterMarkOrDefault() + ) + + if size > 0 { + opts = opts.SetSize(size) + if refillLowWaterMark > 0 && + refillHighWaterMark > 0 && + refillHighWaterMark > refillLowWaterMark { + opts = opts.SetRefillLowWatermark(refillLowWaterMark) + opts = opts.SetRefillHighWatermark(refillHighWaterMark) } } if scope != nil { @@ -1223,14 +1241,20 @@ func maxCapacityPoolOptions( policy config.MaxCapacityPoolPolicy, scope tally.Scope, ) pool.ObjectPoolOptions { - opts := pool.NewObjectPoolOptions() - if policy.Size > 0 { - opts = opts.SetSize(policy.Size) - if policy.RefillLowWaterMark > 0 && - policy.RefillHighWaterMark > 0 && - policy.RefillHighWaterMark > policy.RefillLowWaterMark { - opts = opts.SetRefillLowWatermark(policy.RefillLowWaterMark) - opts = opts.SetRefillHighWatermark(policy.RefillHighWaterMark) + var ( + opts = pool.NewObjectPoolOptions() + size = policy.SizeOrDefault() + refillLowWaterMark = policy.RefillLowWaterMarkOrDefault() + refillHighWaterMark = policy.RefillHighWaterMarkOrDefault() + ) + + if size > 0 { + opts = opts.SetSize(size) + if refillLowWaterMark > 0 && + refillHighWaterMark > 0 && + refillHighWaterMark > refillLowWaterMark { + opts = opts.SetRefillLowWatermark(refillLowWaterMark) + opts = opts.SetRefillHighWatermark(refillHighWaterMark) } } if scope != nil { From 7cc246b27574882a2685cbe7675e39316eadeff4 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:27:25 -0500 Subject: [PATCH 41/54] rewrite everything --- src/cmd/services/m3dbnode/config/config.go | 17 +- src/cmd/services/m3dbnode/config/fs.go | 28 +- src/cmd/services/m3dbnode/config/pooling.go | 766 +++++++++----------- src/cmd/services/m3dbnode/main/main.go | 2 +- src/cmd/services/m3dbnode/main/main_test.go | 2 +- src/dbnode/client/config.go | 9 +- src/dbnode/server/server.go | 53 +- 7 files changed, 395 insertions(+), 482 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config.go b/src/cmd/services/m3dbnode/config/config.go index 4397918c2c..4c850321f3 100644 --- a/src/cmd/services/m3dbnode/config/config.go +++ b/src/cmd/services/m3dbnode/config/config.go @@ -58,10 +58,10 @@ type Configuration struct { Coordinator *coordinatorcfg.Configuration `yaml:"coordinator"` } -// Validate validates the Configuration. We use this method to validate -// fields where the validator package falls short. -func (c Configuration) Validate() error { - if err := c.DB.Validate(); err != nil { +// InitDefaultsAndValidate initializes all default values and validates the Configuration. +// We use this method to validate fields where the validator package falls short. +func (c *Configuration) InitDefaultsAndValidate() error { + if err := c.DB.InitDefaultsAndValidate(); err != nil { return err } @@ -143,12 +143,15 @@ type DBConfiguration struct { WriteNewSeriesAsync bool `yaml:"writeNewSeriesAsync"` } -// Validate validates the Configuration. We use this method to validate -// fields where the validator package falls short. -func (c DBConfiguration) Validate() error { +// InitDefaultsAndValidate initializes all default values and validates the Configuration. +// We use this method to validate fields where the validator package falls short. +func (c *DBConfiguration) InitDefaultsAndValidate() error { if err := c.Filesystem.Validate(); err != nil { return err } + if err := c.PoolingPolicy.InitDefaultsAndValidate(); err != nil { + return err + } return nil } diff --git a/src/cmd/services/m3dbnode/config/fs.go b/src/cmd/services/m3dbnode/config/fs.go index 31eeaf050c..19fbfadd18 100644 --- a/src/cmd/services/m3dbnode/config/fs.go +++ b/src/cmd/services/m3dbnode/config/fs.go @@ -98,39 +98,39 @@ type FilesystemConfiguration struct { // Validate validates the Filesystem configuration. We use this method to validate // fields where the validator package falls short. func (f FilesystemConfiguration) Validate() error { - if f.WriteBufferSize != nil { + if f.WriteBufferSize != nil && *f.WriteBufferSize < 1 { return fmt.Errorf( "fs writeBufferSize is set to: %d, but must be at least 1", *f.WriteBufferSize) } - if f.DataReadBufferSize != nil { + if f.DataReadBufferSize != nil && *f.DataReadBufferSize < 1 { return fmt.Errorf( "fs dataReadBufferSize is set to: %d, but must be at least 1", *f.DataReadBufferSize) } - if f.InfoReadBufferSize != nil { + if f.InfoReadBufferSize != nil && *f.InfoReadBufferSize < 1 { return fmt.Errorf( "fs infoReadBufferSize is set to: %d, but must be at least 1", *f.InfoReadBufferSize) } - if f.SeekReadBufferSize != nil { + if f.SeekReadBufferSize != nil && *f.SeekReadBufferSize < 1 { return fmt.Errorf( "fs seekReadBufferSize is set to: %d, but must be at least 1", *f.SeekReadBufferSize) } - if f.ThroughputLimitMbps != nil { + if f.ThroughputLimitMbps != nil && *f.ThroughputLimitMbps < 1 { return fmt.Errorf( - "fs throughputLimitMbps is set to: %f, but must be larger than 0", + "fs throughputLimitMbps is set to: %f, but must be at least 1", *f.ThroughputLimitMbps) } - if f.ThroughputCheckEvery != nil { + if f.ThroughputCheckEvery != nil && *f.ThroughputCheckEvery < 1 { return fmt.Errorf( - "fs throughputCheckEvery is set to: %d, but must be larger than 0", + "fs throughputCheckEvery is set to: %d, but must be at least 1", *f.ThroughputCheckEvery) } @@ -150,7 +150,7 @@ func (f FilesystemConfiguration) FilePathPrefixOrDefault() string { // WriteBufferSizeOrDefault returns the configured write buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) WriteBufferSizeOrDefault() int { - if f.WriteBufferSize != nil && *f.WriteBufferSize > 1 { + if f.WriteBufferSize != nil { return *f.WriteBufferSize } @@ -160,7 +160,7 @@ func (f FilesystemConfiguration) WriteBufferSizeOrDefault() int { // DataReadBufferSizeOrDefault returns the configured data read buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) DataReadBufferSizeOrDefault() int { - if f.DataReadBufferSize != nil && *f.DataReadBufferSize > 1 { + if f.DataReadBufferSize != nil { return *f.DataReadBufferSize } @@ -170,7 +170,7 @@ func (f FilesystemConfiguration) DataReadBufferSizeOrDefault() int { // InfoReadBufferSizeOrDefault returns the configured info read buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) InfoReadBufferSizeOrDefault() int { - if f.InfoReadBufferSize != nil && *f.InfoReadBufferSize > 1 { + if f.InfoReadBufferSize != nil { return *f.InfoReadBufferSize } @@ -180,7 +180,7 @@ func (f FilesystemConfiguration) InfoReadBufferSizeOrDefault() int { // SeekReadBufferSizeOrDefault returns the configured seek read buffer size if configured, or a // default value otherwise. func (f FilesystemConfiguration) SeekReadBufferSizeOrDefault() int { - if f.SeekReadBufferSize != nil && *f.SeekReadBufferSize > 1 { + if f.SeekReadBufferSize != nil { return *f.SeekReadBufferSize } @@ -190,7 +190,7 @@ func (f FilesystemConfiguration) SeekReadBufferSizeOrDefault() int { // ThroughputLimitMbpsOrDefault returns the configured throughput limit mbps if configured, or a // default value otherwise. func (f FilesystemConfiguration) ThroughputLimitMbpsOrDefault() float64 { - if f.ThroughputLimitMbps != nil && *f.ThroughputLimitMbps > 0 { + if f.ThroughputLimitMbps != nil { return *f.ThroughputLimitMbps } @@ -200,7 +200,7 @@ func (f FilesystemConfiguration) ThroughputLimitMbpsOrDefault() float64 { // ThroughputCheckEveryOrDefault returns the configured throughput check every value if configured, or a // default value otherwise. func (f FilesystemConfiguration) ThroughputCheckEveryOrDefault() int { - if f.ThroughputCheckEvery != nil && *f.ThroughputCheckEvery > 0 { + if f.ThroughputCheckEvery != nil { return *f.ThroughputCheckEvery } diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 2ca453619e..6e9807aab0 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -33,108 +33,213 @@ const ( const ( defaultMaxFinalizerCapacity = 4 defaultBlockAllocSize = 16 +) - defaultPoolSize = 4096 - defaultRefillLowWaterMark = 0.0 - defaultRefillHighWaterMark = 0.0 - - commonRefillLowWaterMark = 0.7 - commonRefillHighWaterMark = 0.7 - - defaultContextPoolSize = 262144 - defaultSeriesPoolSize = 262144 - defaultBlockPoolSize = 262144 - defaultEncoderPoolSize = 262144 - defaultClosersPoolSize = 104857 - defaultSegmentReaderPoolSize = 16384 - defaultIteratorPoolSize = 2048 - defaultBlockMetadataPoolSize = 65536 - defaultBlocksMetadataPool = 65536 - defaultIdentifierPoolSize = 262144 - - // defaultPostingsListPoolSize has a small default pool size since postings - // lists can frequently reach the size of 4mb each in practice even when - // reset. - defaultPostingsListPoolSize = 16 - - defaultFetchBlockMetadataResultsPoolSize = 65536 - defaultFetchBlockMetadataResultsPoolCapacity = 32 - - defaultFetchBlocksMetadataResultsPoolSize = 32 - defaultFetchBlocksMetadataResultsPoolCapacity = 4096 - - defaultHostBlockMetadataSlicePoolSize = 131072 - defaultHostBlockMetadataSlicePoolCapacity = 3 +type poolPolicyDefault struct { + size int + refillLowWaterMark float64 + refillHighWaterMark float64 - defaultBlockMetadataSlicePoolSize = 65536 - defaultBlockMetadataSlicePoolCapacity = 32 + // Only used for capacity and max capacity pools. + capacity int + // Only used for max capacity pools. + maxCapacity int +} - defaultBlocksMetadataSlicePoolSize = 32 - defaultBlocksMetadataSlicePoolCapacity = 4096 -) +type bucketPoolPolicyDefault struct { + buckets []CapacityPoolPolicy +} var ( - defaultBytesPoolBuckets = []CapacityPoolPolicy{ - { - defaultCapacity: 16, - PoolPolicy: PoolPolicy{ - defaultSize: 524288, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - }, + defaultRefillLowWaterMark = 0.7 + defaultRefillHighWaterMark = 1.0 + + defaultPoolPolicy = poolPolicyDefault{ + size: 4096, + refillLowWaterMark: 0, + refillHighWaterMark: 0, + } + + defaultPoolPolicies = map[string]poolPolicyDefault{ + "tagsIterator": defaultPoolPolicy, + "indexResults": defaultPoolPolicy, + "tagEncoder": defaultPoolPolicy, + "tagDecoder": defaultPoolPolicy, + "context": poolPolicyDefault{ + size: 262144, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, }, - { - defaultCapacity: 32, - PoolPolicy: PoolPolicy{ - defaultSize: 262144, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - }, + "series": poolPolicyDefault{ + size: 262144, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, }, - { - defaultCapacity: 64, - PoolPolicy: PoolPolicy{ - defaultSize: 131072, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - }, + "block": poolPolicyDefault{ + size: 262144, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, }, - { - defaultCapacity: 128, - PoolPolicy: PoolPolicy{ - defaultSize: 65536, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - }, + "encoder": poolPolicyDefault{ + size: 262144, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, }, - { - defaultCapacity: 256, - PoolPolicy: PoolPolicy{ - defaultSize: 65536, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - }, + "closers": poolPolicyDefault{ + size: 104857, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, }, - { - defaultCapacity: 1440, - PoolPolicy: PoolPolicy{ - defaultSize: 16384, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, - }, + "segmentReader": poolPolicyDefault{ + size: 16384, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + }, + "iterator": poolPolicyDefault{ + size: 2048, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + }, + "blockMetadata": poolPolicyDefault{ + size: 65536, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + }, + "blocksMetadata": poolPolicyDefault{ + size: 65536, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + }, + "identifier": poolPolicyDefault{ + size: 262144, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + }, + "postingsList": poolPolicyDefault{ + // defaultPostingsListPoolSize has a small default pool size since postings + // lists can frequently reach the size of 4mb each in practice even when + // reset. + size: 16, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, }, - { - defaultCapacity: 4096, - PoolPolicy: PoolPolicy{ - defaultSize: 8192, - defaultRefillLowWaterMark: 0.7, - defaultRefillHighWaterMark: 1.0, + + // Capacity pools. + "fetchBlockMetadataResults": poolPolicyDefault{ + size: 65536, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + capacity: 32, + }, + "fetchBlocksMetadataResults": poolPolicyDefault{ + size: 32, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + capacity: 4096, + }, + "hostBlockMetadataSlice": poolPolicyDefault{ + size: 131072, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + capacity: 3, + }, + "blockMetadataSlice": poolPolicyDefault{ + size: 65536, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + capacity: 32, + }, + "blocksMetadataSlice": poolPolicyDefault{ + size: 32, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + capacity: 4096, + }, + + // Max capacity pools. + "tags": poolPolicyDefault{ + size: 4096, + refillLowWaterMark: defaultRefillLowWaterMark, + refillHighWaterMark: defaultRefillHighWaterMark, + capacity: 0, + maxCapacity: 16, + }, + } + + defaultBucketPoolPolicies = map[string]bucketPoolPolicyDefault{ + "bytes": bucketPoolPolicyDefault{ + buckets: []CapacityPoolPolicy{ + { + Capacity: intPtr(16), + PoolPolicy: PoolPolicy{ + Size: intPtr(524288), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, + { + Capacity: intPtr(32), + PoolPolicy: PoolPolicy{ + Size: intPtr(262144), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, + { + Capacity: intPtr(64), + PoolPolicy: PoolPolicy{ + Size: intPtr(131072), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, + { + Capacity: intPtr(128), + PoolPolicy: PoolPolicy{ + Size: intPtr(65536), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, + { + Capacity: intPtr(256), + PoolPolicy: PoolPolicy{ + Size: intPtr(65536), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, + { + Capacity: intPtr(1440), + PoolPolicy: PoolPolicy{ + Size: intPtr(16384), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, + { + Capacity: intPtr(4096), + PoolPolicy: PoolPolicy{ + Size: intPtr(8192), + RefillLowWaterMark: floatPtr(0.7), + RefillHighWaterMark: floatPtr(1.0), + }, + }, }, }, } ) -// PoolingPolicy specifies the pooling policy. +// PoolingPolicy specifies the pooling policy. To add a new pool, follow these steps: +// +// 1. Add the pool to the struct below. +// 2. Add the default values to the defaultPoolPolicies map. +// 3. Add a call to initDefaultsAndValidate() for the new pool in the +// PoolingPolicy.InitDefaultsAndValidate() method. +// +// Note that the steps above apply to PoolPolicy, CapacityPoolPolicy, and +// MaxCapacityPoolPolicy. If adding a new BucketPoolPolicy, follow the bytes pool +// example. type PoolingPolicy struct { // The initial alloc size for a block. BlockAllocSize *int `yaml:"blockAllocSize"` @@ -143,139 +248,141 @@ type PoolingPolicy struct { Type *PoolingType `yaml:"type"` // The Bytes pool buckets to use. - BytesPool BytesPool `yaml:"bytesPool"` + BytesPool BucketPoolPolicy `yaml:"bytesPool"` // The policy for the Closers pool. - ClosersPool ClosersPool `yaml:"closersPool"` + ClosersPool PoolPolicy `yaml:"closersPool"` // The policy for the Context pool. ContextPool ContextPoolPolicy `yaml:"contextPool"` // The policy for the DatabaseSeries pool. - SeriesPool SeriesPool `yaml:"seriesPool"` + SeriesPool PoolPolicy `yaml:"seriesPool"` // The policy for the DatabaseBlock pool. - BlockPool BlockPool `yaml:"blockPool"` + BlockPool PoolPolicy `yaml:"blockPool"` // The policy for the Encoder pool. - EncoderPool EncoderPool `yaml:"encoderPool"` + EncoderPool PoolPolicy `yaml:"encoderPool"` // The policy for the Iterator pool. - IteratorPool IteratorPool `yaml:"iteratorPool"` + IteratorPool PoolPolicy `yaml:"iteratorPool"` // The policy for the Segment Reader pool. - SegmentReaderPool SegmentReaderPool `yaml:"segmentReaderPool"` + SegmentReaderPool PoolPolicy `yaml:"segmentReaderPool"` // The policy for the Identifier pool. - IdentifierPool IdentifierPool `yaml:"identifierPool"` + IdentifierPool PoolPolicy `yaml:"identifierPool"` // The policy for the FetchBlockMetadataResult pool. - FetchBlockMetadataResultsPool FetchBlockMetadataResultsPool `yaml:"fetchBlockMetadataResultsPool"` + FetchBlockMetadataResultsPool CapacityPoolPolicy `yaml:"fetchBlockMetadataResultsPool"` // The policy for the FetchBlocksMetadataResults pool. - FetchBlocksMetadataResultsPool FetchBlocksMetadataResultsPool `yaml:"fetchBlocksMetadataResultsPool"` + FetchBlocksMetadataResultsPool CapacityPoolPolicy `yaml:"fetchBlocksMetadataResultsPool"` // The policy for the HostBlockMetadataSlice pool. - HostBlockMetadataSlicePool HostBlockMetadataSlicePool `yaml:"hostBlockMetadataSlicePool"` + HostBlockMetadataSlicePool CapacityPoolPolicy `yaml:"hostBlockMetadataSlicePool"` // The policy for the BlockMetadat pool. - BlockMetadataPool BlockMetadataPool `yaml:"blockMetadataPool"` + BlockMetadataPool PoolPolicy `yaml:"blockMetadataPool"` // The policy for the BlockMetadataSlice pool. - BlockMetadataSlicePool BlockMetadataSlicePool `yaml:"blockMetadataSlicePool"` + BlockMetadataSlicePool CapacityPoolPolicy `yaml:"blockMetadataSlicePool"` // The policy for the BlocksMetadata pool. - BlocksMetadataPool BlocksMetadataPool `yaml:"blocksMetadataPool"` + BlocksMetadataPool PoolPolicy `yaml:"blocksMetadataPool"` // The policy for the BlocksMetadataSlice pool. - BlocksMetadataSlicePool BlocksMetadataSlicePool `yaml:"blocksMetadataSlicePool"` + BlocksMetadataSlicePool CapacityPoolPolicy `yaml:"blocksMetadataSlicePool"` - // TODO: Fix me // The policy for the tags pool. TagsPool MaxCapacityPoolPolicy `yaml:"tagsPool"` // The policy for the tags iterator pool. - TagsIteratorPool DefaultPoolPolicy `yaml:"tagIteratorPool"` + TagsIteratorPool PoolPolicy `yaml:"tagIteratorPool"` // The policy for the index.ResultsPool. - IndexResultsPool DefaultPoolPolicy `yaml:"indexResultsPool"` + IndexResultsPool PoolPolicy `yaml:"indexResultsPool"` // The policy for the TagEncoderPool. - TagEncoderPool DefaultPoolPolicy `yaml:"tagEncoderPool"` + TagEncoderPool PoolPolicy `yaml:"tagEncoderPool"` // The policy for the TagDecoderPool. - TagDecoderPool DefaultPoolPolicy `yaml:"tagDecoderPool"` + TagDecoderPool PoolPolicy `yaml:"tagDecoderPool"` // The policy for the WriteBatchPool. WriteBatchPool WriteBatchPoolPolicy `yaml:"writeBatchPool"` // The policy for the PostingsListPool. - PostingsListPool PostingsListPool `yaml:"postingsListPool"` + PostingsListPool PoolPolicy `yaml:"postingsListPool"` } -// Validate validates the pooling policy config. -func (p *PoolingPolicy) Validate() error { - if err := p.ClosersPool.Validate("closersPool"); err != nil { +// InitDefaultsAndValidate initializes all default values and validates the configuration +func (p *PoolingPolicy) InitDefaultsAndValidate() error { + if err := p.ClosersPool.initDefaultsAndValidate("closers"); err != nil { + return err + } + if err := p.ContextPool.initDefaultsAndValidate("context"); err != nil { return err } - if err := p.ContextPool.Validate("contextPool"); err != nil { + if err := p.SeriesPool.initDefaultsAndValidate("series"); err != nil { return err } - if err := p.SeriesPool.Validate("seriesPool"); err != nil { + if err := p.BlockPool.initDefaultsAndValidate("block"); err != nil { return err } - if err := p.BlockPool.Validate("blockPool"); err != nil { + if err := p.EncoderPool.initDefaultsAndValidate("encoder"); err != nil { return err } - if err := p.EncoderPool.Validate("encoderPool"); err != nil { + if err := p.IteratorPool.initDefaultsAndValidate("iterator"); err != nil { return err } - if err := p.IteratorPool.Validate("iteratorPool"); err != nil { + if err := p.SegmentReaderPool.initDefaultsAndValidate("segmentReader"); err != nil { return err } - if err := p.SegmentReaderPool.Validate("segmentReaderPool"); err != nil { + if err := p.IdentifierPool.initDefaultsAndValidate("identifier"); err != nil { return err } - if err := p.IdentifierPool.Validate("identifierPool"); err != nil { + if err := p.FetchBlockMetadataResultsPool.initDefaultsAndValidate("fetchBlockMetadataResults"); err != nil { return err } - if err := p.FetchBlockMetadataResultsPool.Validate("fetchBlockMetadataResultsPool"); err != nil { + if err := p.FetchBlocksMetadataResultsPool.initDefaultsAndValidate("fetchBlocksMetadataResults"); err != nil { return err } - if err := p.FetchBlocksMetadataResultsPool.Validate("fetchBlocksMetadataResultsPool"); err != nil { + if err := p.HostBlockMetadataSlicePool.initDefaultsAndValidate("hostBlockMetadataSlice"); err != nil { return err } - if err := p.HostBlockMetadataSlicePool.Validate("hostBlockMetadataSlicePool"); err != nil { + if err := p.BlockMetadataPool.initDefaultsAndValidate("blockMetadata"); err != nil { return err } - if err := p.BlockMetadataPool.Validate("blockMetadataPool"); err != nil { + if err := p.BlockMetadataSlicePool.initDefaultsAndValidate("blockMetadataSlice"); err != nil { return err } - if err := p.BlockMetadataSlicePool.Validate("blockMetadataSlicePool"); err != nil { + if err := p.BlocksMetadataPool.initDefaultsAndValidate("blocksMetadata"); err != nil { return err } - if err := p.BlocksMetadataPool.Validate("blocksMetadataPool"); err != nil { + if err := p.BlocksMetadataSlicePool.initDefaultsAndValidate("blocksMetadataSlice"); err != nil { return err } - if err := p.BlocksMetadataSlicePool.Validate("blocksMetadataSlicePool"); err != nil { + if err := p.TagsPool.initDefaultsAndValidate("tags"); err != nil { return err } - if err := p.TagsPool.Validate("tagsPool"); err != nil { + if err := p.TagsIteratorPool.initDefaultsAndValidate("tagsIterator"); err != nil { return err } - if err := p.TagsIteratorPool.Validate("tagsIteratorPool"); err != nil { + if err := p.IndexResultsPool.initDefaultsAndValidate("indexResults"); err != nil { return err } - if err := p.IndexResultsPool.Validate("indexResultsPool"); err != nil { + if err := p.TagEncoderPool.initDefaultsAndValidate("tagEncoder"); err != nil { return err } - if err := p.TagEncoderPool.Validate("tagEncoderPool"); err != nil { + if err := p.TagDecoderPool.initDefaultsAndValidate("tagDecoder"); err != nil { return err } - if err := p.TagDecoderPool.Validate("tagDecoderPool"); err != nil { + if err := p.PostingsListPool.initDefaultsAndValidate("postingsList"); err != nil { return err } - if err := p.PostingsListPool.Validate("postingsListPool"); err != nil { + if err := p.BytesPool.initDefaultsAndValidate("bytes"); err != nil { return err } return nil @@ -311,22 +418,31 @@ type PoolPolicy struct { // The high watermark to stop refilling the pool, if zero none. RefillHighWaterMark *float64 `yaml:"highWatermark"` - - // Default values to be returned if the above values are not set. - defaultSize int - defaultRefillLowWaterMark float64 - defaultRefillHighWaterMark float64 } -// Validate validates the pool policy config. -func (p *PoolPolicy) Validate(poolName string) error { - if p.RefillLowWaterMark != nil && (*p.RefillLowWaterMark < 0 || *p.RefillLowWaterMark > 1) { +func (p *PoolPolicy) initDefaultsAndValidate(poolName string) error { + defaults, ok := defaultPoolPolicies[poolName] + if !ok { + return fmt.Errorf("no default values for pool: %s", poolName) + } + + if p.Size == nil { + p.Size = &defaults.size + } + if p.RefillLowWaterMark == nil { + p.RefillLowWaterMark = &defaults.refillLowWaterMark + } + if p.RefillHighWaterMark == nil { + p.RefillHighWaterMark = &defaults.refillHighWaterMark + } + + if *p.RefillLowWaterMark < 0 || *p.RefillLowWaterMark > 1 { return fmt.Errorf( "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", poolName) } - if p.RefillHighWaterMark != nil && (*p.RefillHighWaterMark < 0 || *p.RefillHighWaterMark > 1) { + if *p.RefillHighWaterMark < 0 || *p.RefillHighWaterMark > 1 { return fmt.Errorf( "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", poolName) @@ -337,31 +453,19 @@ func (p *PoolPolicy) Validate(poolName string) error { // SizeOrDefault returns the configured size if present, or a default value otherwise. func (p *PoolPolicy) SizeOrDefault() int { - if p.Size != nil { - return *p.Size - } - - return p.defaultSize + return *p.Size } // RefillLowWaterMarkOrDefault returns the configured refill low water mark if present, // or a default value otherwise. func (p *PoolPolicy) RefillLowWaterMarkOrDefault() float64 { - if p.RefillLowWaterMark != nil { - return *p.RefillLowWaterMark - } - - return p.defaultRefillLowWaterMark + return *p.RefillLowWaterMark } // RefillHighWaterMarkOrDefault returns the configured refill high water mark if present, // or a default value otherwise. func (p *PoolPolicy) RefillHighWaterMarkOrDefault() float64 { - if p.RefillHighWaterMark != nil { - return *p.RefillHighWaterMark - } - - return p.defaultRefillHighWaterMark + return *p.RefillHighWaterMark } // CapacityPoolPolicy specifies a single pool policy that has a @@ -371,18 +475,24 @@ type CapacityPoolPolicy struct { // The capacity of items in the pool. Capacity *int `yaml:"capacity"` - - // Default values to be returned if the above values are not set. - defaultCapacity int } // Validate validates the capacity pool policy config. -func (p *CapacityPoolPolicy) Validate(poolName string) error { - if err := p.PoolPolicy.Validate(poolName); err != nil { +func (p *CapacityPoolPolicy) initDefaultsAndValidate(poolName string) error { + if err := p.PoolPolicy.initDefaultsAndValidate(poolName); err != nil { return err } - if p.Capacity != nil && *p.Capacity < 0 { + defaults, ok := defaultPoolPolicies[poolName] + if !ok { + return fmt.Errorf("no default values for pool: %s", poolName) + } + + if p.Capacity == nil { + p.Capacity = &defaults.capacity + } + + if *p.Capacity < 0 { return fmt.Errorf("capacity of %s pool must be 0 or larger", poolName) } @@ -391,11 +501,7 @@ func (p *CapacityPoolPolicy) Validate(poolName string) error { // CapacityOrDefault returns the configured capacity if present, or a default value otherwise. func (p *CapacityPoolPolicy) CapacityOrDefault() int { - if p.Capacity != nil { - return *p.Capacity - } - - return p.defaultCapacity + return *p.Capacity } // MaxCapacityPoolPolicy specifies a single pool policy that has a @@ -404,16 +510,70 @@ type MaxCapacityPoolPolicy struct { CapacityPoolPolicy `yaml:",inline"` // The max capacity of items in the pool. - MaxCapacity int `yaml:"maxCapacity"` + MaxCapacity *int `yaml:"maxCapacity"` +} + +func (p *MaxCapacityPoolPolicy) initDefaultsAndValidate(poolName string) error { + if err := p.CapacityPoolPolicy.initDefaultsAndValidate(poolName); err != nil { + return err + } + + defaults, ok := defaultPoolPolicies[poolName] + if !ok { + return fmt.Errorf("no default values for pool: %s", poolName) + } + + if p.MaxCapacity == nil { + p.MaxCapacity = &defaults.maxCapacity + } + + if *p.MaxCapacity < 0 { + return fmt.Errorf("maxCapacity of %s pool must be 0 or larger", poolName) + } + + return nil +} + +// MaxCapacityOrDefault returns the configured maximum capacity if present, or a +// default value otherwise. +func (p *MaxCapacityPoolPolicy) MaxCapacityOrDefault() int { + return *p.MaxCapacity } // BucketPoolPolicy specifies a bucket pool policy. type BucketPoolPolicy struct { // The pool buckets sizes to use Buckets []CapacityPoolPolicy `yaml:"buckets"` +} + +func (p *BucketPoolPolicy) initDefaultsAndValidate(poolName string) error { + defaults, ok := defaultBucketPoolPolicies[poolName] + if !ok { + return fmt.Errorf("no default values for pool: %s", poolName) + } + + if p.Buckets == nil { + p.Buckets = defaults.buckets + } + + for i, bucket := range p.Buckets { + if bucket.RefillLowWaterMark == nil { + p.Buckets[i].RefillLowWaterMark = &defaultRefillLowWaterMark + } + if bucket.RefillHighWaterMark == nil { + p.Buckets[i].RefillHighWaterMark = &defaultRefillHighWaterMark + } + } - // Default values to be returned if the above values are not set. - defaultBuckets []CapacityPoolPolicy + for _, bucket := range p.Buckets { + if bucket.Size == nil { + return fmt.Errorf("bucket size for pool %s cannot be nil", poolName) + } + if bucket.Capacity == nil { + return fmt.Errorf("bucket capacity for pool %s cannot be nil", poolName) + } + } + return nil } // WriteBatchPoolPolicy specifies the pooling policy for the WriteBatch pool. @@ -441,16 +601,6 @@ type ContextPoolPolicy struct { MaxFinalizerCapacity int `yaml:"maxFinalizerCapacity" validate:"min=0"` } -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *ContextPoolPolicy) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultContextPoolSize - policy.defaultRefillLowWaterMark = commonRefillLowWaterMark - policy.defaultRefillHighWaterMark = commonRefillHighWaterMark - return policy -} - // MaxFinalizerCapacityOrDefault returns the maximum finalizer capacity and // fallsback to the default value if its not set. func (p ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { @@ -461,264 +611,10 @@ func (p ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { return p.MaxFinalizerCapacity } -// DefaultPoolPolicy is the default pool policy. -type DefaultPoolPolicy struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *DefaultPoolPolicy) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// SeriesPool is the pool policy for the series pool. -type SeriesPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *SeriesPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultSeriesPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// BlockPool is the pool policy for the block pool. -type BlockPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *BlockPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultBlockPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// EncoderPool is the pool policy for the encoder pool. -type EncoderPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *EncoderPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultEncoderPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// ClosersPool is the pool policy for the closers pool. -type ClosersPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *ClosersPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultClosersPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// SegmentReaderPool is the pool policy for the segment reader pool. -type SegmentReaderPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *SegmentReaderPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultSegmentReaderPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// IteratorPool is the pool policy for the iterator pool. -type IteratorPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *IteratorPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultIteratorPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// FetchBlockMetadataResultsPool is the pool policy for the fetch block metadata results pool. -type FetchBlockMetadataResultsPool struct { - CapacityPoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *FetchBlockMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { - policy := p.CapacityPoolPolicy - policy.defaultSize = defaultFetchBlockMetadataResultsPoolSize - policy.defaultCapacity = defaultFetchBlockMetadataResultsPoolCapacity - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// FetchBlocksMetadataResultsPool is the pool policy for the fetch blocks metadata results pool. -type FetchBlocksMetadataResultsPool struct { - CapacityPoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *FetchBlocksMetadataResultsPool) PoolPolicyOrDefault() CapacityPoolPolicy { - policy := p.CapacityPoolPolicy - policy.defaultSize = defaultFetchBlocksMetadataResultsPoolSize - policy.defaultCapacity = defaultFetchBlocksMetadataResultsPoolCapacity - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// HostBlockMetadataSlicePool is the pool policy for the host block metadata slice pool. -type HostBlockMetadataSlicePool struct { - CapacityPoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *HostBlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { - policy := p.CapacityPoolPolicy - policy.defaultSize = defaultHostBlockMetadataSlicePoolSize - policy.defaultCapacity = defaultHostBlockMetadataSlicePoolCapacity - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// BlockMetadataPool is the pool policy for the block metadata pool. -type BlockMetadataPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *BlockMetadataPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultBlockMetadataPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// BlockMetadataSlicePool is the pool policy for the block metadata slice pool. -type BlockMetadataSlicePool struct { - CapacityPoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *BlockMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { - policy := p.CapacityPoolPolicy - policy.defaultSize = defaultBlockMetadataSlicePoolSize - policy.defaultCapacity = defaultBlockMetadataSlicePoolCapacity - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// BlocksMetadataPool is the pool policy for the blocks metadata pool. -type BlocksMetadataPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *BlocksMetadataPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultBlocksMetadataPool - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// BlocksMetadataSlicePool is the pool policy for the blocks metadata slice pool. -type BlocksMetadataSlicePool struct { - CapacityPoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *BlocksMetadataSlicePool) PoolPolicyOrDefault() CapacityPoolPolicy { - policy := p.CapacityPoolPolicy - policy.defaultSize = defaultBlocksMetadataSlicePoolSize - policy.defaultCapacity = defaultBlocksMetadataSlicePoolCapacity - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// IdentifierPool is the pool policy for the identifier pool. -type IdentifierPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *IdentifierPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultIdentifierPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy -} - -// BytesPool is the pool policy for the bytes pool. -type BytesPool struct { - BucketPoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *BytesPool) PoolPolicyOrDefault() BucketPoolPolicy { - policy := p.BucketPoolPolicy - policy.defaultBuckets = defaultBytesPoolBuckets - return policy -} - -// PostingsListPool is the pool policy for the postings list pool. -type PostingsListPool struct { - PoolPolicy `yaml:",inline"` -} - -// PoolPolicyOrDefault returns the provided pool policy, or a default value if -// one is not provided. -func (p *PostingsListPool) PoolPolicyOrDefault() PoolPolicy { - policy := p.PoolPolicy - policy.defaultSize = defaultPostingsListPoolSize - policy.defaultRefillLowWaterMark = defaultRefillLowWaterMark - policy.defaultRefillHighWaterMark = defaultRefillHighWaterMark - return policy +func intPtr(x int) *int { + return &x } -func intPtr(x int) *int { +func floatPtr(x float64) *float64 { return &x } diff --git a/src/cmd/services/m3dbnode/main/main.go b/src/cmd/services/m3dbnode/main/main.go index 2d4dc10b23..30555f5d44 100644 --- a/src/cmd/services/m3dbnode/main/main.go +++ b/src/cmd/services/m3dbnode/main/main.go @@ -52,7 +52,7 @@ func main() { os.Exit(1) } - if err := cfg.Validate(); err != nil { + if err := cfg.InitDefaultsAndValidate(); err != nil { fmt.Fprintf(os.Stderr, "configuration validation failed %v\n", err) os.Exit(1) } diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 8127e25334..a3329d3810 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -172,7 +172,7 @@ func TestConfig(t *testing.T) { // NB(r): Make sure client config points to the root config // service since we're going to instantiate the client configuration // just by itself. - cfg.DB.Client.EnvironmentConfig.Service = cfg.DB.EnvironmentConfig.Service + cfg.DB.Client.EnvironmentConfig = &cfg.DB.EnvironmentConfig cli, err := cfg.DB.Client.NewClient(client.ConfigurationParameters{}) require.NoError(t, err) diff --git a/src/dbnode/client/config.go b/src/dbnode/client/config.go index 17962a94f8..e69f1c979e 100644 --- a/src/dbnode/client/config.go +++ b/src/dbnode/client/config.go @@ -154,11 +154,14 @@ func (c Configuration) NewAdminClient( var err error if envCfg.TopologyInitializer == nil { if c.EnvironmentConfig.Service != nil { - envCfg, err = c.EnvironmentConfig.Configure(environment.ConfigurationParameters{ + cfgParams := environment.ConfigurationParameters{ InstrumentOpts: iopts, - HashingSeed: c.HashingConfiguration.Seed, - }) + } + if c.HashingConfiguration != nil { + cfgParams.HashingSeed = c.HashingConfiguration.Seed + } + envCfg, err = c.EnvironmentConfig.Configure(cfgParams) if err != nil { err = fmt.Errorf("unable to create dynamic topology initializer, err: %v", err) return nil, err diff --git a/src/dbnode/server/server.go b/src/dbnode/server/server.go index 18e23d4d3e..695751837d 100644 --- a/src/dbnode/server/server.go +++ b/src/dbnode/server/server.go @@ -132,6 +132,12 @@ func Run(runOpts RunOptions) { cfg = runOpts.Config } + err := cfg.InitDefaultsAndValidate() + if err != nil { + fmt.Fprintf(os.Stderr, "error initializing config defaults and validating config: %v", err) + os.Exit(1) + } + logger, err := cfg.Logging.BuildLogger() if err != nil { fmt.Fprintf(os.Stderr, "unable to create logger: %v", err) @@ -292,13 +298,13 @@ func Run(runOpts RunOptions) { tagEncoderPool := serialize.NewTagEncoderPool( serialize.NewTagEncoderOptions(), poolOptions( - policy.TagEncoderPool.PoolPolicyOrDefault(), + policy.TagEncoderPool, scope.SubScope("tag-encoder-pool"))) tagEncoderPool.Init() tagDecoderPool := serialize.NewTagDecoderPool( serialize.NewTagDecoderOptions(), poolOptions( - policy.TagDecoderPool.PoolPolicyOrDefault(), + policy.TagDecoderPool, scope.SubScope("tag-decoder-pool"))) tagDecoderPool.Init() @@ -969,21 +975,21 @@ func withEncodingAndPoolingOptions( segmentReaderPool := xio.NewSegmentReaderPool( poolOptions( - policy.SegmentReaderPool.PoolPolicyOrDefault(), + policy.SegmentReaderPool, scope.SubScope("segment-reader-pool"))) segmentReaderPool.Init() encoderPool := encoding.NewEncoderPool( poolOptions( - policy.EncoderPool.PoolPolicyOrDefault(), + policy.EncoderPool, scope.SubScope("encoder-pool"))) closersPoolOpts := poolOptions( - policy.ClosersPool.PoolPolicyOrDefault(), + policy.ClosersPool, scope.SubScope("closers-pool")) contextPoolOpts := poolOptions( - policy.ContextPool.PoolPolicyOrDefault(), + policy.ContextPool.PoolPolicy, scope.SubScope("context-pool")) contextPool := context.NewPool(context.NewOptions(). @@ -993,12 +999,12 @@ func withEncodingAndPoolingOptions( iteratorPool := encoding.NewReaderIteratorPool( poolOptions( - policy.IteratorPool.PoolPolicyOrDefault(), + policy.IteratorPool, scope.SubScope("iterator-pool"))) multiIteratorPool := encoding.NewMultiReaderIteratorPool( poolOptions( - policy.IteratorPool.PoolPolicyOrDefault(), + policy.IteratorPool, scope.SubScope("multi-iterator-pool"))) var writeBatchPoolInitialBatchSize *int @@ -1047,26 +1053,31 @@ func withEncodingAndPoolingOptions( writeBatchPoolInitialBatchSize, writeBatchPoolMaxBatchSize) + tagPoolPolicy := policy.TagsPool identifierPool := ident.NewPool(bytesPool, ident.PoolOptions{ IDPoolOptions: poolOptions( - policy.IdentifierPool.PoolPolicyOrDefault(), scope.SubScope("identifier-pool")), - TagsPoolOptions: maxCapacityPoolOptions(policy.TagsPool, scope.SubScope("tags-pool")), - TagsCapacity: policy.TagsPool.CapacityOrDefault(), - TagsMaxCapacity: policy.TagsPool.MaxCapacity, + policy.IdentifierPool, scope.SubScope("identifier-pool")), + TagsPoolOptions: maxCapacityPoolOptions(tagPoolPolicy, scope.SubScope("tags-pool")), + TagsCapacity: tagPoolPolicy.CapacityOrDefault(), + TagsMaxCapacity: tagPoolPolicy.MaxCapacityOrDefault(), TagsIteratorPoolOptions: poolOptions( - policy.TagsIteratorPool.PoolPolicyOrDefault(), + policy.TagsIteratorPool, scope.SubScope("tags-iterator-pool")), }) + fetchBlockMetadataResultsPoolPolicy := policy.FetchBlockMetadataResultsPool fetchBlockMetadataResultsPool := block.NewFetchBlockMetadataResultsPool( - capacityPoolOptions(policy.FetchBlockMetadataResultsPool.PoolPolicyOrDefault(), + capacityPoolOptions( + fetchBlockMetadataResultsPoolPolicy, scope.SubScope("fetch-block-metadata-results-pool")), - policy.FetchBlockMetadataResultsPool.CapacityOrDefault()) + fetchBlockMetadataResultsPoolPolicy.CapacityOrDefault()) + fetchBlocksMetadataResultsPoolPolicy := policy.FetchBlocksMetadataResultsPool fetchBlocksMetadataResultsPool := block.NewFetchBlocksMetadataResultsPool( - capacityPoolOptions(policy.FetchBlocksMetadataResultsPool.PoolPolicyOrDefault(), + capacityPoolOptions( + fetchBlocksMetadataResultsPoolPolicy, scope.SubScope("fetch-blocks-metadata-results-pool")), - policy.FetchBlocksMetadataResultsPool.CapacityOrDefault()) + fetchBlocksMetadataResultsPoolPolicy.CapacityOrDefault()) encodingOpts := encoding.NewOptions(). SetEncoderPool(encoderPool). @@ -1127,7 +1138,7 @@ func withEncodingAndPoolingOptions( } blockPool := block.NewDatabaseBlockPool( poolOptions( - policy.BlockPool.PoolPolicyOrDefault(), + policy.BlockPool, scope.SubScope("block-pool"))) blockPool.Init(func() block.DatabaseBlock { return block.NewDatabaseBlock(time.Time{}, 0, ts.Segment{}, blockOpts) @@ -1141,7 +1152,7 @@ func withEncodingAndPoolingOptions( SetFetchBlockMetadataResultsPool(opts.FetchBlockMetadataResultsPool()) seriesPool := series.NewDatabaseSeriesPool( poolOptions( - policy.SeriesPool.PoolPolicyOrDefault(), + policy.SeriesPool, scope.SubScope("series-pool"))) opts = opts. @@ -1153,11 +1164,11 @@ func withEncodingAndPoolingOptions( resultsPool := index.NewResultsPool( poolOptions( - policy.IndexResultsPool.PoolPolicyOrDefault(), + policy.IndexResultsPool, scope.SubScope("index-results-pool"))) postingsListOpts := poolOptions( - policy.PostingsListPool.PoolPolicyOrDefault(), + policy.PostingsListPool, scope.SubScope("postingslist-pool")) postingsList := postings.NewPool(postingsListOpts, roaring.NewPostingsList) From 06211cabeeeb4272505b1b37dbb270d84a91ca2f Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:41:59 -0500 Subject: [PATCH 42/54] use constants --- src/cmd/services/m3dbnode/config/pooling.go | 32 ++++++++----------- src/cmd/services/m3dbnode/main/common_test.go | 1 + src/cmd/services/m3dbnode/main/main_test.go | 1 + 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 6e9807aab0..deea024224 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -173,56 +173,56 @@ var ( Capacity: intPtr(16), PoolPolicy: PoolPolicy{ Size: intPtr(524288), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, { Capacity: intPtr(32), PoolPolicy: PoolPolicy{ Size: intPtr(262144), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, { Capacity: intPtr(64), PoolPolicy: PoolPolicy{ Size: intPtr(131072), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, { Capacity: intPtr(128), PoolPolicy: PoolPolicy{ Size: intPtr(65536), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, { Capacity: intPtr(256), PoolPolicy: PoolPolicy{ Size: intPtr(65536), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, { Capacity: intPtr(1440), PoolPolicy: PoolPolicy{ Size: intPtr(16384), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, { Capacity: intPtr(4096), PoolPolicy: PoolPolicy{ Size: intPtr(8192), - RefillLowWaterMark: floatPtr(0.7), - RefillHighWaterMark: floatPtr(1.0), + RefillLowWaterMark: &defaultRefillLowWaterMark, + RefillHighWaterMark: &defaultRefillHighWaterMark, }, }, }, @@ -614,7 +614,3 @@ func (p ContextPoolPolicy) MaxFinalizerCapacityOrDefault() int { func intPtr(x int) *int { return &x } - -func floatPtr(x float64) *float64 { - return &x -} diff --git a/src/cmd/services/m3dbnode/main/common_test.go b/src/cmd/services/m3dbnode/main/common_test.go index 49b4cb8acd..178080ef83 100644 --- a/src/cmd/services/m3dbnode/main/common_test.go +++ b/src/cmd/services/m3dbnode/main/common_test.go @@ -1,3 +1,4 @@ +// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index a3329d3810..33609a19d1 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -1,3 +1,4 @@ +// +build big // // Copyright (c) 2017 Uber Technologies, Inc. // From 6d152bf03ab3fdbafdc622b813fb1d27d9a9032a Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:44:24 -0500 Subject: [PATCH 43/54] Fix comment explaining how to add new pool --- src/cmd/services/m3dbnode/config/pooling.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index deea024224..8354710ef5 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -233,13 +233,9 @@ var ( // PoolingPolicy specifies the pooling policy. To add a new pool, follow these steps: // // 1. Add the pool to the struct below. -// 2. Add the default values to the defaultPoolPolicies map. +// 2. Add the default values to the defaultPoolPolicies or defaultBucketPoolPolicies map. // 3. Add a call to initDefaultsAndValidate() for the new pool in the // PoolingPolicy.InitDefaultsAndValidate() method. -// -// Note that the steps above apply to PoolPolicy, CapacityPoolPolicy, and -// MaxCapacityPoolPolicy. If adding a new BucketPoolPolicy, follow the bytes pool -// example. type PoolingPolicy struct { // The initial alloc size for a block. BlockAllocSize *int `yaml:"blockAllocSize"` From 067dbeeb6ea0b7c8f7e13794d68a2694c9c4d1a4 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:45:10 -0500 Subject: [PATCH 44/54] add constant for default pooling type --- src/cmd/services/m3dbnode/config/pooling.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index 8354710ef5..d8063c6878 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -28,6 +28,8 @@ type PoolingType string const ( // SimplePooling uses the basic Go runtime to allocate bytes for bytes pools. SimplePooling PoolingType = "simple" + + defaultPoolingType = SimplePooling ) const ( @@ -401,7 +403,7 @@ func (p *PoolingPolicy) TypeOrDefault() PoolingType { return *p.Type } - return SimplePooling + return defaultPoolingType } // PoolPolicy specifies a single pool policy. From 255948617a9d432d0e69c058472af97ef560cc9c Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:46:09 -0500 Subject: [PATCH 45/54] fix error message --- src/cmd/services/m3dbnode/config/pooling.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index d8063c6878..ea441f8dbf 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -436,14 +436,12 @@ func (p *PoolPolicy) initDefaultsAndValidate(poolName string) error { if *p.RefillLowWaterMark < 0 || *p.RefillLowWaterMark > 1 { return fmt.Errorf( - "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", - poolName) + "invalid lowWatermark value for %s pool, should be >= 0 and <= 1", poolName) } if *p.RefillHighWaterMark < 0 || *p.RefillHighWaterMark > 1 { return fmt.Errorf( - "invalid lowWatermark value for %s pool, should be larger than 0 and smaller than 1", - poolName) + "invalid lowWatermark value for %s pool, should be >= 0 and <= 1", poolName) } return nil From 44ae4378c0b6b8fe608c471160c5558ab5f5161b Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:47:25 -0500 Subject: [PATCH 46/54] add comment --- src/cmd/services/m3dbnode/config/pooling.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/pooling.go b/src/cmd/services/m3dbnode/config/pooling.go index ea441f8dbf..3b0a0d8755 100644 --- a/src/cmd/services/m3dbnode/config/pooling.go +++ b/src/cmd/services/m3dbnode/config/pooling.go @@ -489,7 +489,7 @@ func (p *CapacityPoolPolicy) initDefaultsAndValidate(poolName string) error { } if *p.Capacity < 0 { - return fmt.Errorf("capacity of %s pool must be 0 or larger", poolName) + return fmt.Errorf("capacity of %s pool must be >= 0", poolName) } return nil @@ -524,7 +524,7 @@ func (p *MaxCapacityPoolPolicy) initDefaultsAndValidate(poolName string) error { } if *p.MaxCapacity < 0 { - return fmt.Errorf("maxCapacity of %s pool must be 0 or larger", poolName) + return fmt.Errorf("maxCapacity of %s pool must be >= 0", poolName) } return nil @@ -553,6 +553,8 @@ func (p *BucketPoolPolicy) initDefaultsAndValidate(poolName string) error { } for i, bucket := range p.Buckets { + // If the user provided buckets, but no values for refill low/high watermarks + // then set them to default values. if bucket.RefillLowWaterMark == nil { p.Buckets[i].RefillLowWaterMark = &defaultRefillLowWaterMark } From 1ef370bed20b99dad0e74bd1ec142ace5dbb22a4 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 18:54:56 -0500 Subject: [PATCH 47/54] fix broken test --- .../services/m3dbnode/config/config_test.go | 45 +++++++++---------- .../services/m3dbnode/config/pooling_test.go | 28 ++---------- 2 files changed, 24 insertions(+), 49 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config_test.go b/src/cmd/services/m3dbnode/config/config_test.go index a32342a2c4..931dc69e49 100644 --- a/src/cmd/services/m3dbnode/config/config_test.go +++ b/src/cmd/services/m3dbnode/config/config_test.go @@ -21,6 +21,7 @@ package config import ( + "fmt" "io/ioutil" "os" "testing" @@ -159,9 +160,9 @@ db: highWatermark: 0.02 fetchBlocksMetadataResultsPool: size: 32 - capacity: 4096 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 4096 hostBlockMetadataSlicePool: size: 131072 capacity: 3 @@ -208,12 +209,9 @@ db: lowWatermark: 0.01 highWatermark: 0.02 writeBatchPool: + size: 8192 initialBatchSize: 128 maxBatchSize: 100000 - pool: - size: 8192 - lowWatermark: 0.01 - highWatermark: 0.02 postingsListPool: size: 8 lowWatermark: 0 @@ -418,37 +416,37 @@ func TestConfiguration(t *testing.T) { bytesPool: buckets: - size: 6291456 - capacity: 16 lowWatermark: 0.1 highWatermark: 0.12 + capacity: 16 - size: 3145728 - capacity: 32 lowWatermark: 0.1 highWatermark: 0.12 + capacity: 32 - size: 3145728 - capacity: 64 lowWatermark: 0.1 highWatermark: 0.12 + capacity: 64 - size: 3145728 - capacity: 128 lowWatermark: 0.1 highWatermark: 0.12 + capacity: 128 - size: 3145728 - capacity: 256 lowWatermark: 0.1 highWatermark: 0.12 + capacity: 256 - size: 524288 - capacity: 1440 lowWatermark: 0.1 highWatermark: 0.12 + capacity: 1440 - size: 524288 - capacity: 4096 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 4096 - size: 32768 - capacity: 8192 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 8192 closersPool: size: 104857 lowWatermark: 0.01 @@ -484,43 +482,43 @@ func TestConfiguration(t *testing.T) { highWatermark: 0.02 fetchBlockMetadataResultsPool: size: 65536 - capacity: 32 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 32 fetchBlocksMetadataResultsPool: size: 32 - capacity: 4096 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 4096 hostBlockMetadataSlicePool: size: 131072 - capacity: 3 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 3 blockMetadataPool: size: 65536 lowWatermark: 0.01 highWatermark: 0.02 blockMetadataSlicePool: size: 65536 - capacity: 32 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 32 blocksMetadataPool: size: 65536 lowWatermark: 0.01 highWatermark: 0.02 blocksMetadataSlicePool: size: 32 - capacity: 4096 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 4096 tagsPool: size: 65536 - capacity: 8 - maxCapacity: 32 lowWatermark: 0.01 highWatermark: 0.02 + capacity: 8 + maxCapacity: 32 tagIteratorPool: size: 8192 lowWatermark: 0.01 @@ -538,12 +536,9 @@ func TestConfiguration(t *testing.T) { lowWatermark: 0.01 highWatermark: 0.02 writeBatchPool: + size: 8192 initialBatchSize: 128 maxBatchSize: 100000 - pool: - size: 8192 - lowWatermark: 0.01 - highWatermark: 0.02 postingsListPool: size: 8 lowWatermark: 0 @@ -609,6 +604,8 @@ coordinator: null actual := string(data) if expected != actual { diff := xtest.Diff(expected, actual) + fmt.Println("expected: ", expected) + fmt.Println("actual: ", actual) require.FailNow(t, "reverse config did not match:\n"+diff) } } diff --git a/src/cmd/services/m3dbnode/config/pooling_test.go b/src/cmd/services/m3dbnode/config/pooling_test.go index f8478fa937..c33c305d86 100644 --- a/src/cmd/services/m3dbnode/config/pooling_test.go +++ b/src/cmd/services/m3dbnode/config/pooling_test.go @@ -37,10 +37,9 @@ func TestContextPoolPolicyPoolPolicy(t *testing.T) { }, } - policy := cpp.PoolPolicyOrDefault() - require.Equal(t, size, policy.SizeOrDefault()) - require.Equal(t, refillLowWaterMark, policy.RefillLowWaterMarkOrDefault()) - require.Equal(t, refillHighWaterMark, policy.RefillHighWaterMarkOrDefault()) + require.Equal(t, size, cpp.SizeOrDefault()) + require.Equal(t, refillLowWaterMark, cpp.RefillLowWaterMarkOrDefault()) + require.Equal(t, refillHighWaterMark, cpp.RefillHighWaterMarkOrDefault()) } func TestContextPoolMaxFinalizerCapacityOrDefault(t *testing.T) { @@ -52,24 +51,3 @@ func TestContextPoolMaxFinalizerCapacityOrDefault(t *testing.T) { cpp.MaxFinalizerCapacity = 10 require.Equal(t, 10, cpp.MaxFinalizerCapacityOrDefault()) } - -func TestPostingsPoolPolicyDefaultSize(t *testing.T) { - policy := PoolingPolicy{ - PostingsListPool: PostingsListPool{}, - } - - parsed := policy.PostingsListPool.PoolPolicyOrDefault() - require.Equal(t, defaultPostingsListPoolSize, parsed.SizeOrDefault()) -} - -func TestPostingsPoolPolicyWithSize(t *testing.T) { - defaultPlus1 := defaultPostingsListPoolSize + 1 - policy := PoolingPolicy{ - PostingsListPool: PostingsListPool{ - PoolPolicy{Size: &defaultPlus1}, - }, - } - - parsed := policy.PostingsListPool.PoolPolicyOrDefault() - require.Equal(t, defaultPlus1, parsed.SizeOrDefault()) -} From 1ff90a330725d02240229585eb536050cabf3e11 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 19:40:51 -0500 Subject: [PATCH 48/54] use validate method on client --- src/cmd/services/m3dbnode/config/config.go | 5 +++ src/dbnode/client/config.go | 47 +++++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config.go b/src/cmd/services/m3dbnode/config/config.go index 4c850321f3..a9b6d2c94c 100644 --- a/src/cmd/services/m3dbnode/config/config.go +++ b/src/cmd/services/m3dbnode/config/config.go @@ -149,10 +149,15 @@ func (c *DBConfiguration) InitDefaultsAndValidate() error { if err := c.Filesystem.Validate(); err != nil { return err } + if err := c.PoolingPolicy.InitDefaultsAndValidate(); err != nil { return err } + if err := c.Client.Validate(); err != nil { + return err + } + return nil } diff --git a/src/dbnode/client/config.go b/src/dbnode/client/config.go index e69f1c979e..e525eb043f 100644 --- a/src/dbnode/client/config.go +++ b/src/dbnode/client/config.go @@ -55,13 +55,13 @@ type Configuration struct { ConnectConsistencyLevel *topology.ConnectConsistencyLevel `yaml:"connectConsistencyLevel"` // WriteTimeout is the write request timeout. - WriteTimeout *time.Duration `yaml:"writeTimeout" validate:"min=0"` + WriteTimeout *time.Duration `yaml:"writeTimeout"` // FetchTimeout is the fetch request timeout. - FetchTimeout *time.Duration `yaml:"fetchTimeout" validate:"min=0"` + FetchTimeout *time.Duration `yaml:"fetchTimeout"` // ConnectTimeout is the cluster connect timeout. - ConnectTimeout *time.Duration `yaml:"connectTimeout" validate:"min=0"` + ConnectTimeout *time.Duration `yaml:"connectTimeout"` // WriteRetry is the write retry config. WriteRetry *retry.Configuration `yaml:"writeRetry"` @@ -71,16 +71,47 @@ type Configuration struct { // BackgroundHealthCheckFailLimit is the amount of times a background check // must fail before a connection is taken out of consideration. - BackgroundHealthCheckFailLimit *int `yaml:"backgroundHealthCheckFailLimit" validate:"min=1,max=10"` + BackgroundHealthCheckFailLimit *int `yaml:"backgroundHealthCheckFailLimit"` // BackgroundHealthCheckFailThrottleFactor is the factor of the host connect // time to use when sleeping between a failed health check and the next check. - BackgroundHealthCheckFailThrottleFactor *float64 `yaml:"backgroundHealthCheckFailThrottleFactor" validate:"min=0,max=10"` + BackgroundHealthCheckFailThrottleFactor *float64 `yaml:"backgroundHealthCheckFailThrottleFactor"` // HashingConfiguration is the configuration for hashing of IDs to shards. HashingConfiguration *HashingConfiguration `yaml:"hashing"` } +// Validate validates the configuration. +func (c *Configuration) Validate() error { + if c.WriteTimeout != nil && *c.WriteTimeout < 0 { + return fmt.Errorf("m3db client writeTimeout was: %d but must be >= 0", *c.WriteTimeout) + } + + if c.FetchTimeout != nil && *c.FetchTimeout < 0 { + return fmt.Errorf("m3db client fetchTimeout was: %d but must be >= 0", *c.FetchTimeout) + } + + if c.ConnectTimeout != nil && *c.ConnectTimeout < 0 { + return fmt.Errorf("m3db client connectTimeout was: %d but must be >= 0", *c.ConnectTimeout) + } + + if c.BackgroundHealthCheckFailLimit != nil && + (*c.BackgroundHealthCheckFailLimit < 0 || *c.BackgroundHealthCheckFailLimit > 10) { + return fmt.Errorf( + "m3db client backgroundHealthCheckFailLimit was: %d but must be >= 0 and <=10", + *c.BackgroundHealthCheckFailLimit) + } + + if c.BackgroundHealthCheckFailThrottleFactor != nil && + (*c.BackgroundHealthCheckFailThrottleFactor < 0 || *c.BackgroundHealthCheckFailThrottleFactor > 10) { + return fmt.Errorf( + "m3db client backgroundHealthCheckFailThrottleFactor was: %f but must be >= 0 and <=10", + *c.BackgroundHealthCheckFailThrottleFactor) + } + + return nil +} + // HashingConfiguration is the configuration for hashing type HashingConfiguration struct { // Murmur32 seed value @@ -139,6 +170,11 @@ func (c Configuration) NewAdminClient( params ConfigurationParameters, custom ...CustomAdminOption, ) (AdminClient, error) { + err := c.Validate() + if err != nil { + return nil, err + } + iopts := params.InstrumentOptions if iopts == nil { iopts = instrument.NewOptions() @@ -151,7 +187,6 @@ func (c Configuration) NewAdminClient( TopologyInitializer: params.TopologyInitializer, } - var err error if envCfg.TopologyInitializer == nil { if c.EnvironmentConfig.Service != nil { cfgParams := environment.ConfigurationParameters{ From 088d1026355f52414fd16fcda68ec4fc3bc6321a Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 20:20:02 -0500 Subject: [PATCH 49/54] fix broken test --- src/cmd/services/m3dbnode/main/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index 33609a19d1..da7bb7dae1 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -372,7 +372,7 @@ func TestEmbeddedConfig(t *testing.T) { // NB(r): Make sure client config points to the root config // service since we're going to instantiate the client configuration // just by itself. - cfg.DB.Client.EnvironmentConfig.Service = cfg.DB.EnvironmentConfig.Service + cfg.DB.Client.EnvironmentConfig = cfg.DB.EnvironmentConfig cli, err := cfg.DB.Client.NewClient(client.ConfigurationParameters{}) require.NoError(t, err) From 93ac499eb6be1cdfdb7b4d22b60975ab19f089ae Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 20:48:28 -0500 Subject: [PATCH 50/54] fix integration tests timing out --- src/dbnode/integration/cluster_add_one_node_test.go | 4 ++++ src/dbnode/integration/serve.go | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dbnode/integration/cluster_add_one_node_test.go b/src/dbnode/integration/cluster_add_one_node_test.go index bba1ee7ce7..21e7f34ac4 100644 --- a/src/dbnode/integration/cluster_add_one_node_test.go +++ b/src/dbnode/integration/cluster_add_one_node_test.go @@ -273,8 +273,12 @@ func testClusterAddOneNode(t *testing.T, verifyCommitlogCanBootstrapAfterNodeJoi doneWritingWhilePeerStreaming <- struct{}{} }() + log.Debug("waiting for shards to be bootstrapped") waitUntilHasBootstrappedShardsExactly(setups[1].db, testutil.Uint32Range(midShard+1, maxShard)) + + log.Debug("waiting for background writes to complete") <-doneWritingWhilePeerStreaming + log.Debug("waiting for shards to be marked initialized") allMarkedAvailable := func( diff --git a/src/dbnode/integration/serve.go b/src/dbnode/integration/serve.go index 34964afd87..631b5978e1 100644 --- a/src/dbnode/integration/serve.go +++ b/src/dbnode/integration/serve.go @@ -36,6 +36,7 @@ import ( "github.com/m3db/m3/src/dbnode/sharding" "github.com/m3db/m3/src/dbnode/storage" "github.com/m3db/m3/src/dbnode/topology" + xretry "github.com/m3db/m3x/retry" ) // newTestShardSet creates a default shard set @@ -73,7 +74,12 @@ func newTopologyInitializerForShardSet( // defaultClientOptions creates a default m3db client options func defaultClientOptions(initializer topology.Initializer) client.Options { - return client.NewOptions().SetTopologyInitializer(initializer) + return client.NewOptions(). + SetTopologyInitializer(initializer). + // Default to zero retries to prevent tests from taking too long in situations where + // errors are expected. + SetWriteRetrier(xretry.NewRetrier(xretry.NewOptions().SetMaxRetries(0))). + SetFetchRetrier(xretry.NewRetrier(xretry.NewOptions().SetMaxRetries(0))) } // openAndServe opens the database, starts up the RPC servers and bootstraps From 521d31cb9d960b903e94c393588ca133fa51cd95 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 20:51:37 -0500 Subject: [PATCH 51/54] fix broken test --- src/cmd/services/m3dbnode/main/main_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/main/main_test.go b/src/cmd/services/m3dbnode/main/main_test.go index da7bb7dae1..e3213ea945 100644 --- a/src/cmd/services/m3dbnode/main/main_test.go +++ b/src/cmd/services/m3dbnode/main/main_test.go @@ -372,7 +372,7 @@ func TestEmbeddedConfig(t *testing.T) { // NB(r): Make sure client config points to the root config // service since we're going to instantiate the client configuration // just by itself. - cfg.DB.Client.EnvironmentConfig = cfg.DB.EnvironmentConfig + cfg.DB.Client.EnvironmentConfig = &cfg.DB.EnvironmentConfig cli, err := cfg.DB.Client.NewClient(client.ConfigurationParameters{}) require.NoError(t, err) From d2dffb62afde0f1340ef837f8a043e74886dc968 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 21:21:00 -0500 Subject: [PATCH 52/54] fix last broken test --- src/cmd/services/m3dbnode/main/main_index_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/main/main_index_test.go b/src/cmd/services/m3dbnode/main/main_index_test.go index 1f1ed6dd83..2377a31efa 100644 --- a/src/cmd/services/m3dbnode/main/main_index_test.go +++ b/src/cmd/services/m3dbnode/main/main_index_test.go @@ -179,7 +179,7 @@ func TestIndexEnabledServer(t *testing.T) { // NB(r): Make sure client config points to the root config // service since we're going to instantiate the client configuration // just by itself. - cfg.DB.Client.EnvironmentConfig.Service = cfg.DB.EnvironmentConfig.Service + cfg.DB.Client.EnvironmentConfig = &cfg.DB.EnvironmentConfig.Service cli, err := cfg.DB.Client.NewClient(client.ConfigurationParameters{}) require.NoError(t, err) From 5fd8caefb7ec4dfe2cbcf53d789f8ecf8ddcd8ae Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Wed, 13 Feb 2019 21:26:47 -0500 Subject: [PATCH 53/54] fix last broken test for eral --- src/cmd/services/m3dbnode/main/main_index_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/services/m3dbnode/main/main_index_test.go b/src/cmd/services/m3dbnode/main/main_index_test.go index 2377a31efa..8763518ca4 100644 --- a/src/cmd/services/m3dbnode/main/main_index_test.go +++ b/src/cmd/services/m3dbnode/main/main_index_test.go @@ -179,7 +179,7 @@ func TestIndexEnabledServer(t *testing.T) { // NB(r): Make sure client config points to the root config // service since we're going to instantiate the client configuration // just by itself. - cfg.DB.Client.EnvironmentConfig = &cfg.DB.EnvironmentConfig.Service + cfg.DB.Client.EnvironmentConfig = &cfg.DB.EnvironmentConfig cli, err := cfg.DB.Client.NewClient(client.ConfigurationParameters{}) require.NoError(t, err) From 1c955dd52cbb286b714c05a7e1ec5a894e153760 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Thu, 14 Feb 2019 10:18:26 -0500 Subject: [PATCH 54/54] remove print statements --- src/cmd/services/m3dbnode/config/config_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/cmd/services/m3dbnode/config/config_test.go b/src/cmd/services/m3dbnode/config/config_test.go index 931dc69e49..fd9b18664e 100644 --- a/src/cmd/services/m3dbnode/config/config_test.go +++ b/src/cmd/services/m3dbnode/config/config_test.go @@ -21,7 +21,6 @@ package config import ( - "fmt" "io/ioutil" "os" "testing" @@ -604,8 +603,6 @@ coordinator: null actual := string(data) if expected != actual { diff := xtest.Diff(expected, actual) - fmt.Println("expected: ", expected) - fmt.Println("actual: ", actual) require.FailNow(t, "reverse config did not match:\n"+diff) } }