为什么即使设置了构建选项“ --jobs = 240”,bazel也限制了24个动作的运行?

时间:2018-10-08 13:19:31

标签: bazel

我已经为distcc配置了一个工具链,参数通过包装脚本转发到distcc。

distcc_wrapper_gcc.sh:

#!/bin/bash
set -euo pipefail
ccache distcc g++ "$@"

我想先启动240个并行任务,例如“ make -j240”。构建命令是:

bazel build --action_env=HOME --action_env=DISTCC_HOSTS="***" --config=joint_compilation --jobs=240 target

但是输出是: 238 actions, 24 running

如果我将--jobs设置为小于24,则正在执行的操作数将等于它,否则无论参数中的值如何,最多有24个正在运行的进程。

如果仅运行24个动作,则确实需要花费很长时间进行编译。 运行动作是否有硬性限制? (这台计算机每个核心有12个CPU和2个线程)

是否有办法打破或忽略此限制?


下面是配置内容。

.bazelrc

# Create a new CROSSTOOL file for our toolchain.

build:joint_compilation --crosstool_top=//toolchain:distcc

# Use --cpu as a differentiator.

build:joint_compilation --cpu=joint_compilation

# Specify a "sane" C++ toolchain for the host platform.

build:joint_compilation --host_crosstool_top=@bazel_tools//tools/cpp:toolchain

工具链/已构建

package(default_visibility = ['//visibility:public'])
cc_toolchain_suite(
    name = "distcc",
    toolchains = {
        "joint_compilation": ":joint_compilation_toolchain",
        "distcc|joint_compilation": ":joint_compilation_toolchain",
    },
)
filegroup(name = "empty")

filegroup(
name = "all",
srcs = [
   "distcc_wrapper_gcc.sh",
],
)

cc_toolchain(
    name = "joint_compilation_toolchain",
    toolchain_identifier = "joint_compilation-toolchain",
    all_files = ":all",
    compiler_files = ":all",
    cpu = "distcc",
    dwp_files = ":empty",
    dynamic_runtime_libs = [":empty"],
    linker_files = ":all",
    objcopy_files = ":empty",
    static_runtime_libs = [":empty"],
    strip_files = ":empty",
    supports_param_files = 0,
)

工具链/交叉工具

major_version: "1"
minor_version: "0"
default_target_cpu: "joint_compilation"

toolchain {
  toolchain_identifier: "joint_compilation-toolchain"
  host_system_name: "i686-unknown-linux-gnu"
  target_system_name: "joint_compilation-unknown-distcc"
  target_cpu: "joint_compilation"
  target_libc: "unknown"
  compiler: "distcc"
  abi_version: "unknown"
  abi_libc_version: "unknown"
  tool_path {
      name: "gcc"
      path: "distcc_wrapper_gcc.sh"
  }
   tool_path {
      name: "g++"
      path: "distcc_wrapper_gcc.sh"
  }
  tool_path {
      name: "ld"
      path: "/usr/bin/ld"
  }
  tool_path {
      name: "ar"
      path: "/usr/bin/ar"
  }
  tool_path {
      name: "cpp"
      path: "distcc_wrapper_gcc.sh"
  }
  tool_path {
      name: "gcov"
      path: "/usr/bin/gcov"
  }
  tool_path {
      name: "nm"
      path: "/usr/bin/nm"
  }
  tool_path {
      name: "objdump"
      path: "/usr/bin/objdump"
  }
  tool_path {
      name: "strip"
      path: "/usr/bin/strip"
  }


  cxx_builtin_include_directory: "/usr/lib/gcc/"
  cxx_builtin_include_directory: "/usr/local/include"
  cxx_builtin_include_directory: "/usr/include"
}

1 个答案:

答案 0 :(得分:3)

除非我不知道distcc和bazel之间有一些集成,否则bazel认为它正在执行 local 机器上的所有操作,因此受到本地机器资源的限制。有一个可以调整的本地资源arg,但我强烈建议您按预期使用bazel。远程构建时,这意味着使用支持REAPI的构建场。

至少存在两个:

我已经尝试了前者,而即将尝试后者-部分是由于缓存,部分是由于语言:我发现它比Java更容易读(写)。