mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
runtime: decrement default cpu amount in nr_jobs (#10841)
This commit is contained in:
@ -11,12 +11,15 @@ import os
|
||||
// then `nr_jobs` will return that number instead.
|
||||
// This is useful for runtime tweaking of e.g. threaded or concurrent code.
|
||||
pub fn nr_jobs() int {
|
||||
mut cpus := nr_cpus()
|
||||
mut cpus := nr_cpus() - 1
|
||||
// allow for overrides, for example using `VJOBS=32 ./v test .`
|
||||
vjobs := os.getenv('VJOBS').int()
|
||||
if vjobs > 0 {
|
||||
cpus = vjobs
|
||||
}
|
||||
if cpus == 0 {
|
||||
return 1
|
||||
}
|
||||
return cpus
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user