Skip to content

Commit

Permalink
wiring for bucketized pool
Browse files Browse the repository at this point in the history
  • Loading branch information
vdarulis committed Mar 7, 2021
1 parent 2d4915f commit 4f30713
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/dbnode/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/encoding/multi_reader_iterator_array_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/encoding/mutable_series_iterators_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/query/ts/m3db/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
6 changes: 4 additions & 2 deletions src/x/pool/bucketized.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/x/pool/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/x/pool/checked_bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/x/pool/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion src/x/pool/floats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/x/pool/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f30713

Please sign in to comment.