diff options
| author | ruki <[email protected]> | 2022-08-25 00:36:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-25 00:36:08 +0800 |
| commit | d49bb9e79905d926ea331e60fd7d85597454958c (patch) | |
| tree | 96c14a9f50ccff77daa18d84fee8ddcfe12a44bd /xmake/core/base/os.lua | |
| parent | d0cf3945938f7e3ea971f825c22ef93a7684ac0b (diff) | |
improve default njob
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index fdbc3edbf..271e5546d 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -1301,17 +1301,22 @@ end -- get the default parallel jobs number function os.default_njob() - local njob = math.ceil(os.cpuinfo().ncpu * 3 / 2) - if os.host() == "windows" and njob > 128 then - njob = 128 - end - if njob > 512 then - njob = 512 - end - if njob < 1 then - njob = 1 + local njob + local ncpu = os.cpuinfo().ncpu + if ncpu > 2 then + njob = ncpu + 2 + if os.host() == "windows" and njob > 128 then + njob = 128 + end + if njob > 512 then + njob = 512 + end + elseif ncpu == 2 then + njob = 3 + else + njob = 2 end - return njob + return njob or 2 end -- read the content of symlink |
