Skip to content

Commit

Permalink
Problem: can't use more parallelism than GOMAXPROCS (#17)
Browse files Browse the repository at this point in the history
Solution:
- take the minimum between GOMAXPROCS and NumCPU
  • Loading branch information
yihuang committed Sep 19, 2024
1 parent 91b2d04 commit 6c49aef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stm.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ExecuteBlockWithEstimates(
return fmt.Errorf("invalid number of executors: %d", executors)
}
if executors == 0 {
executors = runtime.NumCPU()
executors = maxParallelism()
}

// Create a new scheduler
Expand Down Expand Up @@ -68,3 +68,7 @@ func ExecuteBlockWithEstimates(
mvMemory.WriteSnapshot(storage)
return nil
}

func maxParallelism() int {
return min(runtime.GOMAXPROCS(0), runtime.NumCPU())
}

0 comments on commit 6c49aef

Please sign in to comment.