Commit 4cd1deab authored by kouhei@chromium.org's avatar kouhei@chromium.org

cr: Allow ninja to use more CPUs on many core workstations.

Before this patch, the number of CPUs allowed to be used by ninja was hardcoded.
This patch tries to find the optimal number by querying the number of available
cpus in the system.

BUG=324806
NOTRY=true

Review URL: https://codereview.chromium.org/248673002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266118 0039d316-1c4b-4281-b951-d872f2087c98
parent 665e48d9
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"""A module to add ninja support to cr.""" """A module to add ninja support to cr."""
import multiprocessing
import os import os
import cr import cr
...@@ -20,10 +21,11 @@ class NinjaBuilder(cr.Builder): ...@@ -20,10 +21,11 @@ class NinjaBuilder(cr.Builder):
"""An implementation of Builder that uses ninja to do the actual build.""" """An implementation of Builder that uses ninja to do the actual build."""
# Some basic configuration installed if we are enabled. # Some basic configuration installed if we are enabled.
EXTRA_FOR_IO_BOUND_JOBS = 2
ENABLED = cr.Config.From( ENABLED = cr.Config.From(
NINJA_BINARY=os.path.join('{DEPOT_TOOLS}', 'ninja'), NINJA_BINARY=os.path.join('{DEPOT_TOOLS}', 'ninja'),
NINJA_JOBS=10, NINJA_JOBS=multiprocessing.cpu_count() + EXTRA_FOR_IO_BOUND_JOBS,
NINJA_PROCESSORS=4, NINJA_PROCESSORS=multiprocessing.cpu_count(),
NINJA_BUILD_FILE=os.path.join('{CR_BUILD_DIR}', 'build.ninja'), NINJA_BUILD_FILE=os.path.join('{CR_BUILD_DIR}', 'build.ninja'),
# Don't rename to GOMA_* or Goma will complain: "unkown GOMA_ parameter". # Don't rename to GOMA_* or Goma will complain: "unkown GOMA_ parameter".
NINJA_GOMA_LINE='cc = {CR_GOMA_CC} $', NINJA_GOMA_LINE='cc = {CR_GOMA_CC} $',
...@@ -35,8 +37,7 @@ class NinjaBuilder(cr.Builder): ...@@ -35,8 +37,7 @@ class NinjaBuilder(cr.Builder):
GOMA_DIR='{CR_GOMA_DIR}', GOMA_DIR='{CR_GOMA_DIR}',
GYP_DEF_gomadir='{CR_GOMA_DIR}', GYP_DEF_gomadir='{CR_GOMA_DIR}',
GYP_DEF_use_goma=1, GYP_DEF_use_goma=1,
NINJA_JOBS=200, NINJA_JOBS=multiprocessing.cpu_count() * 10,
NINJA_PROCESSORS=12,
) )
# A placeholder for the system detected configuration # A placeholder for the system detected configuration
DETECTED = cr.Config('DETECTED') DETECTED = cr.Config('DETECTED')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment