1
0

Command line flag for changing number of threads

This commit is contained in:
dump_stack() 2019-08-16 07:02:51 +00:00
parent b7d785f0c8
commit ddec4adf57
2 changed files with 10 additions and 6 deletions

View File

@ -11,7 +11,9 @@ import (
"os" "os"
"os/exec" "os/exec"
"os/user" "os/user"
"runtime"
"sort" "sort"
"strconv"
"time" "time"
kingpin "gopkg.in/alecthomas/kingpin.v2" kingpin "gopkg.in/alecthomas/kingpin.v2"
@ -130,6 +132,9 @@ func main() {
pewDistFlag := pewCommand.Flag("dist", "Build result path") pewDistFlag := pewCommand.Flag("dist", "Build result path")
pewDist := pewDistFlag.Default(PATH_DEV_NULL).String() pewDist := pewDistFlag.Default(PATH_DEV_NULL).String()
pewThreadsFlag := pewCommand.Flag("threads", "Build result path")
pewThreads := pewThreadsFlag.Default(strconv.Itoa(runtime.NumCPU())).Int()
kernelCommand := app.Command("kernel", "Manipulate kernels") kernelCommand := app.Command("kernel", "Manipulate kernels")
kernelUseHost := kernelCommand.Flag("host", "Use also host kernels").Bool() kernelUseHost := kernelCommand.Flag("host", "Use also host kernels").Bool()
kernelListCommand := kernelCommand.Command("list", "List kernels") kernelListCommand := kernelCommand.Command("list", "List kernels")
@ -240,7 +245,7 @@ func main() {
case pewCommand.FullCommand(): case pewCommand.FullCommand():
err = pewHandler(kcfg, *path, *pewKernel, *pewBinary, err = pewHandler(kcfg, *path, *pewKernel, *pewBinary,
*pewTest, *pewGuess, *qemuTimeout, *dockerTimeout, *pewTest, *pewGuess, *qemuTimeout, *dockerTimeout,
*pewMax, *pewDist, db) *pewMax, *pewDist, *pewThreads, db)
case kernelListCommand.FullCommand(): case kernelListCommand.FullCommand():
err = kernelListHandler(kcfg) err = kernelListHandler(kcfg)
case kernelAutogenCommand.FullCommand(): case kernelAutogenCommand.FullCommand():

9
pew.go
View File

@ -15,7 +15,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"os/user" "os/user"
"runtime"
"strings" "strings"
"time" "time"
@ -373,11 +372,11 @@ func shuffleKernels(a []config.KernelInfo) []config.KernelInfo {
func performCI(ka config.Artifact, kcfg config.KernelConfig, binaryPath, func performCI(ka config.Artifact, kcfg config.KernelConfig, binaryPath,
testPath string, qemuTimeout, dockerTimeout time.Duration, testPath string, qemuTimeout, dockerTimeout time.Duration,
max int64, dist string, db *sql.DB) (err error) { max int64, dist string, threads int, db *sql.DB) (err error) {
found := false found := false
swg := sizedwaitgroup.New(runtime.NumCPU()) swg := sizedwaitgroup.New(threads)
for _, kernel := range shuffleKernels(kcfg.Kernels) { for _, kernel := range shuffleKernels(kcfg.Kernels) {
if max <= 0 { if max <= 0 {
break break
@ -448,7 +447,7 @@ func genAllKernels() (sk []config.KernelMask, err error) {
func pewHandler(kcfg config.KernelConfig, func pewHandler(kcfg config.KernelConfig,
workPath, ovrrdKrnl, binary, test string, guess bool, workPath, ovrrdKrnl, binary, test string, guess bool,
qemuTimeout, dockerTimeout time.Duration, qemuTimeout, dockerTimeout time.Duration,
max int64, dist string, db *sql.DB) (err error) { max int64, dist string, threads int, db *sql.DB) (err error) {
ka, err := config.ReadArtifactConfig(workPath + "/.out-of-tree.toml") ka, err := config.ReadArtifactConfig(workPath + "/.out-of-tree.toml")
if err != nil { if err != nil {
@ -477,7 +476,7 @@ func pewHandler(kcfg config.KernelConfig,
} }
err = performCI(ka, kcfg, binary, test, qemuTimeout, dockerTimeout, err = performCI(ka, kcfg, binary, test, qemuTimeout, dockerTimeout,
max, dist, db) max, dist, threads, db)
if err != nil { if err != nil {
return return
} }