Skip to content

mono, or-tools: cap build parallelism to nproc/4 - #132

Merged
bryan-minimal merged 2 commits into
mainfrom
cap-build-parallelism-mono-ortools
Apr 29, 2026
Merged

bryan-minimal merged 2 commits into
mainfrom
cap-build-parallelism-mono-ortools

Conversation

@bryan-minimal

@bryan-minimal bryan-minimal commented Apr 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Caps build parallelism on or-tools and mono at nproc/4, matching the existing pattern in packages/foundationdb/build.sh.

Both packages were running their build at -j$(nproc) — -j32 on the buildbot res-servers. Each has a known memory blow-up at full parallelism:

  • or-tools links its inline-built deps (protobuf, abseil, HiGHS, eigen) together at peak; -j32 OOMs the host.
  • mono bootstraps byacc + jay + corlib + the runtime; the corlib compile + .NET assembly phase OOMs at -j32.

Both observed OOMing on buildbot in the last day with exit code 125: container received signal SIGKILL. Standard practice across Debian/Fedora/Arch is to cap these specific packages similarly — it's not a workaround, it's how memory-greedy C++ builds are handled at scale.

Implementation

Identical pattern to packages/foundationdb/build.sh:41-44:

JOBS=$(( $(nproc) / 4 ))
[ "$JOBS" -lt 1 ] && JOBS=1

ninja -j"$JOBS"     # or-tools
make -j"$JOBS"      # mono

nproc / 4 is 8 jobs on the current 32-core res-servers, with a floor of 1 so single-core CI environments don't end up at -j0. Relative rather than absolute — scales if VM size changes later.

Test plan

  • Open the buildbot PR (this one) and verify the next build of mono/or-tools completes without SIGKILL on either arch
  • Confirm the build doesn't slow down disproportionately — -j8 should still be plenty for the actual compile work; the speedup from -j32 to -j8 on a memory-bound C++ build is often <2x because the bottleneck moves from CPU to memory bandwidth anyway

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Optimized build process resource usage by reducing parallel job execution to one-quarter of available CPU cores during compilation and linking stages. This change affects build performance and system resource consumption during the build process.

Both packages were running their build at -j$(nproc), which on the
buildbot res-servers is -j32. Each package has a known memory blow-up
at full parallelism:

- or-tools links its inline-built deps (protobuf, abseil, HiGHS,
  eigen) together at peak; -j32 OOMs the build.
- Mono bootstraps byacc + jay + corlib + the runtime; the corlib
  compile + .NET assembly phase OOMs at -j32.

Caps both at nproc/4 (8 jobs on the current 32-core boxes) with a
floor of 1 for low-core CI runs. Matches the existing pattern in
packages/foundationdb/build.sh, which solved the same issue there.

Other distros (Debian/Fedora/Arch) cap these packages similarly --
this is standard practice, not a workaround.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Both build scripts limit parallelism to one quarter of available CPU cores (minimum 1) by calculating JOBS and passing it to their respective build tools, replacing full CPU parallelism. This reduces resource contention during compilation and linking.

Changes

Cohort / File(s) Summary
Build Parallelism Reduction
packages/mono/build.sh, packages/or-tools/build.sh
Both scripts cap build parallelism at nproc/4 (minimum 1) instead of using full CPU count via -j$(nproc). Calculated JOBS variable passed to make and ninja respectively to control concurrency levels during compilation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Four quarters make a whole, or so they say,
Our builds now use just one-fourth CPU's play,
No more the system groans from too much cheer,
We've balanced load and resources sincere!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: capping build parallelism to nproc/4 for both mono and or-tools packages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cap-build-parallelism-mono-ortools

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/mono/build.sh (1)

48-55: Autotools parallelism now diverges from the repository standard.

This uses make -j"$JOBS" instead of make -j$(nproc). If this exception is intentional for memory pressure, please codify a package-specific exception (or update the guideline) so policy and build scripts stay aligned.

As per coding guidelines: "For Autotools projects, use './configure --prefix=/usr' followed by 'make -j$(nproc)' and 'make DESTDIR=$OUTPUT_DIR install'".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/mono/build.sh` around lines 48 - 55, The build script diverges from
policy by using a custom JOBS calculation and make -j"$JOBS" instead of the
standard make -j$(nproc); either revert to the policy-compliant commands or
explicitly codify this as a package-specific exception: replace the JOBS block
with make -j$(nproc) and keep make DESTDIR=$OUTPUT_DIR install, or if memory
pressure requires limiting jobs, add a clear package-specific override (e.g. a
MONO_BUILD_JOBS env var or a COMMENT noting the exception) and apply it only
when set so the default remains make -j$(nproc); ensure references to JOBS, make
-j"$JOBS", nproc and OUTPUT_DIR are updated accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/mono/build.sh`:
- Around line 48-55: The build script diverges from policy by using a custom
JOBS calculation and make -j"$JOBS" instead of the standard make -j$(nproc);
either revert to the policy-compliant commands or explicitly codify this as a
package-specific exception: replace the JOBS block with make -j$(nproc) and keep
make DESTDIR=$OUTPUT_DIR install, or if memory pressure requires limiting jobs,
add a clear package-specific override (e.g. a MONO_BUILD_JOBS env var or a
COMMENT noting the exception) and apply it only when set so the default remains
make -j$(nproc); ensure references to JOBS, make -j"$JOBS", nproc and OUTPUT_DIR
are updated accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d43d13b-1a35-44da-b7fe-cbe62433e6b1

📥 Commits

Reviewing files that changed from the base of the PR and between 2781d9c and 3103092.

📒 Files selected for processing (2)
  • packages/mono/build.sh
  • packages/or-tools/build.sh

@bryan-minimal
bryan-minimal added this pull request to the merge queue Apr 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Apr 29, 2026
@bryan-minimal
bryan-minimal added this pull request to the merge queue Apr 29, 2026
Merged via the queue into main with commit 40d2d99 Apr 29, 2026
3 checks passed
@bryan-minimal
bryan-minimal deleted the cap-build-parallelism-mono-ortools branch April 29, 2026 03:30
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.

2 participants