mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Limit typecheck parallelism by default
This commit is contained in:
parent
9af4ad5c45
commit
7cbdb4fb14
@ -38,7 +38,8 @@ var (
|
|||||||
platforms = flag.String("platform", "", "comma-separated list of platforms to typecheck")
|
platforms = flag.String("platform", "", "comma-separated list of platforms to typecheck")
|
||||||
timings = flag.Bool("time", false, "output times taken for each phase")
|
timings = flag.Bool("time", false, "output times taken for each phase")
|
||||||
defuses = flag.Bool("defuse", false, "output defs/uses")
|
defuses = flag.Bool("defuse", false, "output defs/uses")
|
||||||
serial = flag.Bool("serial", false, "don't type check platforms in parallel")
|
serial = flag.Bool("serial", false, "don't type check platforms in parallel (equivalent to --parallel=1)")
|
||||||
|
parallel = flag.Int("parallel", 4, "limits how many platforms can be checked in parallel. 0 means no limit.")
|
||||||
skipTest = flag.Bool("skip-test", false, "don't type check test code")
|
skipTest = flag.Bool("skip-test", false, "don't type check test code")
|
||||||
tags = flag.String("tags", "", "comma-separated list of build tags to apply in addition to go's defaults")
|
tags = flag.String("tags", "", "comma-separated list of build tags to apply in addition to go's defaults")
|
||||||
ignoreDirs = flag.String("ignore-dirs", "", "comma-separated list of directories to ignore in addition to the default hardcoded list including staging, vendor, and hidden dirs")
|
ignoreDirs = flag.String("ignore-dirs", "", "comma-separated list of directories to ignore in addition to the default hardcoded list including staging, vendor, and hidden dirs")
|
||||||
@ -273,9 +274,24 @@ func main() {
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var failMu sync.Mutex
|
var failMu sync.Mutex
|
||||||
failed := false
|
failed := false
|
||||||
|
|
||||||
|
if *serial {
|
||||||
|
*parallel = 1
|
||||||
|
} else if *parallel == 0 {
|
||||||
|
*parallel = len(plats)
|
||||||
|
}
|
||||||
|
throttle := make(chan int, *parallel)
|
||||||
|
|
||||||
for _, plat := range plats {
|
for _, plat := range plats {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
fn := func(plat string) {
|
go func(plat string) {
|
||||||
|
// block until there's room for this task
|
||||||
|
throttle <- 1
|
||||||
|
defer func() {
|
||||||
|
// indicate this task is done
|
||||||
|
<-throttle
|
||||||
|
}()
|
||||||
|
|
||||||
f := false
|
f := false
|
||||||
serialFprintf(os.Stdout, "type-checking %s\n", plat)
|
serialFprintf(os.Stdout, "type-checking %s\n", plat)
|
||||||
errors, err := c.verify(plat)
|
errors, err := c.verify(plat)
|
||||||
@ -295,12 +311,7 @@ func main() {
|
|||||||
failed = failed || f
|
failed = failed || f
|
||||||
failMu.Unlock()
|
failMu.Unlock()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}
|
}(plat)
|
||||||
if *serial {
|
|
||||||
fn(plat)
|
|
||||||
} else {
|
|
||||||
go fn(plat)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
if failed {
|
if failed {
|
||||||
|
Loading…
Reference in New Issue
Block a user