Skip to content

boost_build: derive b2's -j from resource_size - #1577

Open
kwlzn wants to merge 1 commit into
bazel-contrib:mainfrom
kwlzn:kwlzn/boost_b2_jobs
Open

boost_build: derive b2's -j from resource_size#1577
kwlzn wants to merge 1 commit into
bazel-contrib:mainfrom
kwlzn:kwlzn/boost_b2_jobs

Conversation

@kwlzn

@kwlzn kwlzn commented Jul 28, 2026

Copy link
Copy Markdown

b2 reads none of the parallelism environment variables the framework sets (CMAKE_BUILD_PARALLEL_LEVEL, GNUMAKEFLAGS, MESON_NUM_PROCESSES, NINJA_JOBS), and modern b2 defaults -j to every detected CPU thread. So a boost_build target with a resource_size reserved N cpus from the Bazel scheduler and then forked as many compilers as the machine had cores -- the reservation bought nothing, and Bazel kept scheduling other actions alongside it.

Derive the job count from the same resource_size that produces the resource_set, and put it on the b2 command line ahead of user_options so an explicit user -j still wins. Targets without a resource_size are unchanged.

The arithmetic moves into parallelism_for/get_resource_parallelism so the env vars and the command line flag come from one place and cannot drift.

boost_build.bzl had no stardoc target, so its attributes were not rendered anywhere; add one.

@kwlzn
kwlzn force-pushed the kwlzn/boost_b2_jobs branch from 7efba52 to 88dec15 Compare July 28, 2026 04:12
b2 reads none of the parallelism environment variables the framework sets
(CMAKE_BUILD_PARALLEL_LEVEL, GNUMAKEFLAGS, MESON_NUM_PROCESSES, NINJA_JOBS),
and modern b2 defaults -j to every detected CPU thread. So a boost_build
target with a resource_size reserved N cpus from the Bazel scheduler and then
forked as many compilers as the machine had cores -- the reservation bought
nothing, and Bazel kept scheduling other actions alongside it.

Derive the job count from the same resource_size that produces the
resource_set, and put it on the b2 command line ahead of user_options so an
explicit user -j still wins. Targets without a resource_size are unchanged.

The arithmetic moves into parallelism_for/get_resource_parallelism so the env
vars and the command line flag come from one place and cannot drift.

boost_build.bzl had no stardoc target, so its attributes were not rendered
anywhere; add one.
@kwlzn
kwlzn force-pushed the kwlzn/boost_b2_jobs branch from 88dec15 to 1934e98 Compare July 29, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant