From 71527c18c7caff2fe3f6fa1b84c4e8b3ff720288 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Wed, 18 Nov 2026 18:32:49 +0000 Subject: [PATCH] Account for macOS voice build parallelism in Bazel (#62338) ## Why The local native voice prefix build can run eight jobs in parallel. Bazel needs to account for those jobs when scheduling other local compile actions against the same CPU budget. ## What changed Use the same job count for the native build and the macOS `VoiceNativePrefix` action's CPU estimate. GitOrigin-RevId: 0bda242b98bae8b3f3c412c95c85e398a0dfc9b2 --- third_party/voice/native.bzl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/third_party/voice/native.bzl b/third_party/voice/native.bzl index 5dacbcaf22..9fb3ebbeea 100644 --- a/third_party/voice/native.bzl +++ b/third_party/voice/native.bzl @@ -5,6 +5,13 @@ load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_foreign_cc//foreign_cc/private:cc_toolchain_util.bzl", "absolutize_path_in_str", "get_env_vars", "get_flags_info", "get_tools_info") load("@rules_python//python:py_runtime_info.bzl", "PyRuntimeInfo") +_NATIVE_BUILD_JOBS = 8 + +def _macos_prefix_resources(_os_name, _inputs_size): + # The local prefix action launches its own build system with -j; account for + # those workers in Bazel's CPU budget alongside other local compile actions. + return {"cpu": _NATIVE_BUILD_JOBS} + def _native_prefix_impl(ctx): cc = find_cpp_toolchain(ctx) features = cc_common.configure_features( @@ -31,7 +38,7 @@ def _native_prefix_impl(ctx): "receipt": receipt.path, "target": ctx.attr.target, "deployment_target": minimums[0] if minimums else None, - "jobs": 8, + "jobs": _NATIVE_BUILD_JOBS, "cc": tools.cc, "cxx": tools.cxx, "ar": tools.cxx_linker_static, @@ -80,6 +87,7 @@ def _native_prefix_impl(ctx): "no-remote-exec": "1", "no-remote-cache": "1", } if ctx.attr.target.endswith("apple-darwin") else {}, + resource_set = _macos_prefix_resources if ctx.attr.target.endswith("apple-darwin") else None, mnemonic = "VoiceNativePrefix", progress_message = "Building native voice prefix for " + ctx.attr.target, )