Enable limiting the maximum number of query workers
This commit is contained in:
parent
3bc445ac05
commit
e8accd1b8e
2 changed files with 8 additions and 2 deletions
|
@ -232,14 +232,16 @@ func (i *iterator) checkState(ctx context.Context) bool {
|
|||
|
||||
func (i *iterator) setupWorkers(ctx context.Context) {
|
||||
|
||||
count := ints.Between(1, maxWorkers, workerCount)
|
||||
|
||||
if i.checkState(ctx) {
|
||||
switch {
|
||||
case i.tasks == 0:
|
||||
for w := 1; w <= workerCount; w++ {
|
||||
for w := 1; w <= count; w++ {
|
||||
go i.setupWorker(ctx, i.jobs, i.vals)
|
||||
}
|
||||
default:
|
||||
for w := 1; w <= ints.Between(1, workerCount, i.tasks); w++ {
|
||||
for w := 1; w <= ints.Between(1, count, i.tasks); w++ {
|
||||
go i.setupWorker(ctx, i.jobs, i.vals)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
// maxWorkers enables limiting the maximum number of
|
||||
// workers to start, regardless of the CPU count.
|
||||
maxWorkers = 1
|
||||
|
||||
// workerCount specifies how many workers should be used
|
||||
// to process each query statement concurrently.
|
||||
workerCount = runtime.NumCPU() * 2
|
||||
|
|
Loading…
Reference in a new issue