diff --git a/src/dbnode/client/session.go b/src/dbnode/client/session.go index 6ffa119ad6..fc3bbf1708 100644 --- a/src/dbnode/client/session.go +++ b/src/dbnode/client/session.go @@ -1005,7 +1005,7 @@ func (s *session) setTopologyWithLock(topoMap topology.Map, queues []hostQueue, s.pools.multiReaderIteratorArray = encoding.NewMultiReaderIteratorArrayPool([]pool.Bucket{ { Capacity: replicas, - Count: s.opts.SeriesIteratorPoolSize(), + Count: pool.Size(s.opts.SeriesIteratorPoolSize()), }, }) s.pools.multiReaderIteratorArray.Init() diff --git a/src/dbnode/encoding/multi_reader_iterator_array_pool.go b/src/dbnode/encoding/multi_reader_iterator_array_pool.go index cd0330962c..c5ac88c36d 100644 --- a/src/dbnode/encoding/multi_reader_iterator_array_pool.go +++ b/src/dbnode/encoding/multi_reader_iterator_array_pool.go @@ -66,7 +66,7 @@ func (p *multiReaderIteratorArrayPool) Init() { for i := range p.sizesAsc { buckets[i].capacity = p.sizesAsc[i].Capacity buckets[i].values = make(chan []MultiReaderIterator, p.sizesAsc[i].Count) - for j := 0; j < p.sizesAsc[i].Count; j++ { + for j := 0; pool.Size(j) < p.sizesAsc[i].Count; j++ { buckets[i].values <- p.alloc(p.sizesAsc[i].Capacity) } } diff --git a/src/dbnode/encoding/mutable_series_iterators_pool.go b/src/dbnode/encoding/mutable_series_iterators_pool.go index 914b2c5b0e..0b9a2f5bc8 100644 --- a/src/dbnode/encoding/mutable_series_iterators_pool.go +++ b/src/dbnode/encoding/mutable_series_iterators_pool.go @@ -59,7 +59,7 @@ func (p *seriesIteratorsPool) Init() { for i := range p.sizesAsc { buckets[i].capacity = p.sizesAsc[i].Capacity buckets[i].values = make(chan MutableSeriesIterators, p.sizesAsc[i].Count) - for j := 0; j < p.sizesAsc[i].Count; j++ { + for j := 0; pool.Size(j) < p.sizesAsc[i].Count; j++ { buckets[i].values <- p.alloc(p.sizesAsc[i].Capacity) } } diff --git a/src/query/ts/m3db/options.go b/src/query/ts/m3db/options.go index 153df2aac7..03606790cd 100644 --- a/src/query/ts/m3db/options.go +++ b/src/query/ts/m3db/options.go @@ -70,7 +70,7 @@ type encodedBlockOptions struct { func NewOptions() Options { bytesPool := pool.NewCheckedBytesPool([]pool.Bucket{{ Capacity: defaultCapacity, - Count: defaultCount, + Count: pool.Size(defaultCount), }}, nil, func(s []pool.Bucket) pool.BytesPool { return pool.NewBytesPool(s, nil) }) diff --git a/src/x/pool/bucketized.go b/src/x/pool/bucketized.go index 75bfd32907..3a43807572 100644 --- a/src/x/pool/bucketized.go +++ b/src/x/pool/bucketized.go @@ -77,8 +77,10 @@ func (p *bucketizedObjectPool) Init(alloc BucketizedAllocator) { opts = perBucketOpts } - if !opts.Dynamic() { - opts = opts.SetSize(size) + if size > 0 { + opts = opts.SetSize(int(size)) + } else if size == _dynamicPoolSize { + opts.SetDynamic(true) } iopts := opts.InstrumentOptions() diff --git a/src/x/pool/bytes_test.go b/src/x/pool/bytes_test.go index 39a3c0c620..f151b039ac 100644 --- a/src/x/pool/bytes_test.go +++ b/src/x/pool/bytes_test.go @@ -89,7 +89,7 @@ func getBytesPool(bucketSizes int, bucketCaps []int) *bytesPool { buckets := make([]Bucket, len(bucketCaps)) for i, cap := range bucketCaps { buckets[i] = Bucket{ - Count: bucketSizes, + Count: Size(bucketSizes), Capacity: cap, } } diff --git a/src/x/pool/checked_bytes_test.go b/src/x/pool/checked_bytes_test.go index 7cecaf8158..dabb1f0a91 100644 --- a/src/x/pool/checked_bytes_test.go +++ b/src/x/pool/checked_bytes_test.go @@ -109,7 +109,7 @@ func getCheckedBytesPool( buckets := make([]Bucket, len(bucketCaps)) for i, cap := range bucketCaps { buckets[i] = Bucket{ - Count: bucketSizes, + Count: Size(bucketSizes), Capacity: cap, } } diff --git a/src/x/pool/config.go b/src/x/pool/config.go index c6c1098d0f..7e31721d2a 100644 --- a/src/x/pool/config.go +++ b/src/x/pool/config.go @@ -92,7 +92,7 @@ func (c *BucketizedPoolConfiguration) NewBuckets() []Bucket { // BucketConfiguration contains configuration for a pool bucket. type BucketConfiguration struct { // The count of the items in the bucket. - Count int `yaml:"count"` + Count Size `yaml:"count"` // The capacity of each item in the bucket. Capacity int `yaml:"capacity"` diff --git a/src/x/pool/floats_test.go b/src/x/pool/floats_test.go index 544a4f065a..aa92e82e9b 100644 --- a/src/x/pool/floats_test.go +++ b/src/x/pool/floats_test.go @@ -53,7 +53,7 @@ func getFloatsPool(bucketSizes int, bucketCaps []int) *floatsPool { buckets := make([]Bucket, len(bucketCaps)) for i, cap := range bucketCaps { buckets[i] = Bucket{ - Count: bucketSizes, + Count: Size(bucketSizes), Capacity: cap, } } diff --git a/src/x/pool/types.go b/src/x/pool/types.go index e01017b6a0..4926139247 100644 --- a/src/x/pool/types.go +++ b/src/x/pool/types.go @@ -96,7 +96,7 @@ type Bucket struct { Capacity int // Count is the number of fixed elements in the bucket. - Count int + Count Size // Options is an optional override to specify options to use for a bucket, // specify nil to use the options specified to the bucketized pool