Skip to content

Lower minimum OCaml version from 5.1 to 4.11 - #20

Merged
cuihtlauac merged 1 commit into
mainfrom
lower-ocaml-floor-4.08
Oct 25, 2026
Merged

cuihtlauac merged 1 commit into
mainfrom
lower-ocaml-floor-4.08

Conversation

@cuihtlauac

@cuihtlauac cuihtlauac commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Lowers the supported OCaml floor from 5.1 to 4.11 for both packages.

The library and its FFI stack were already 4.x-compatible. The only OCaml 5-only use was Domain.recommended_domain_count in the build configurator (config/discover.ml), used to pick the -j count for the vendored CMake fallback. It now shells out to getconf _NPROCESSORS_ONLN (falling back to nproc --all) — both report online CPUs, ignore OMP_NUM_THREADS (pinned to 1 in CI), and are compiler-independent.

4.11 is the oldest compiler still carried by the default opam-repository (everything below it has been moved to the archive repo), so it is the lowest floor that is practically installable and CI-testable today.

Changes

  • config/discover.ml — replace Domain.recommended_domain_count with a getconf/nproc shell-out via C.Process.run
  • dune-project, xgboost.opam, xgboost-bench.opam — (ocaml (>= 4.11)) (opam files are hand-maintained; generate_opam_files false)
  • .github/workflows/ci.yml — matrix oldest compiler 5.1 → 4.11; the oldest (4.11) and newest (5.5) exercise both the system fast path and the vendored CMake fallback, middle versions run the fast path only
  • CHANGES.md — changelog entry

Verification

  • dune build -p xgboost and opam lint pass locally (OCaml 5.5.1, system libxgboost 3.0.4)
  • Scanned src/, bin/, config/: no post-4.08 stdlib or syntax features remain
  • The actual 4.11 build (opam solve for a 4.11-compatible ctypes/dune-configurator set, plus the vendored path under 4.11) is validated by CI

🤖 Generated with Claude Code

@cuihtlauac
cuihtlauac force-pushed the lower-ocaml-floor-4.08 branch from 614b3c5 to 3e51703 Compare October 21, 2026 15:41
@cuihtlauac cuihtlauac changed the title Lower minimum OCaml version from 5.1 to 4.08 Lower minimum OCaml version from 5.1 to 4.11 Oct 21, 2026
@cuihtlauac cuihtlauac closed this Oct 21, 2026
@cuihtlauac cuihtlauac reopened this Oct 21, 2026
@cuihtlauac
cuihtlauac force-pushed the lower-ocaml-floor-4.08 branch from 3e51703 to 79b2f7f Compare October 21, 2026 15:59
@cuihtlauac

Copy link
Copy Markdown
Member Author

Note: this must not be merged-and-released as-is. The opam-repository CI for the previous release (xgboost.0.2.2) is failing, and the root cause is a latent bug in code this PR ships unchanged.

On workers without a system libxgboost >= 3.0, the build falls back to compiling vendored XGBoost from source. config/discover.ml (build_jobs) sizes cmake --build -j N from the online CPU count. On opam-repo-ci's 80-core ocluster workers that means -j 80, which spawns enough parallel g++ to exhaust the job's memory and the kernel OOM-kills cc1plus (surfaces as "cmake build failed (exit 2)").

PR20's own CI is green only because GitHub-hosted runners are ~4 vCPU, so the fallback builds at -j 4 and fits in RAM. It hides the bug rather than disproving it: the next release cut from main will reproduce the same OOM on opam-repo-ci.

Fix needed before merge/release: cap the vendored build parallelism. nproc//proc/meminfo report host figures, not the job budget, so the cap should come from the cgroup limit with a conservative constant fallback (+ an env override).

Full diagnosis and ongoing discussion with @mseri: ocaml/opam-repository#30964 (comment)

The library and its FFI stack were already 4.x-compatible. The only
OCaml 5-only use was Domain.recommended_domain_count in the build
configurator (config/discover.ml), which selected the -j count for the
vendored CMake fallback. Replace it with a shell-out to
`getconf _NPROCESSORS_ONLN` (falling back to `nproc --all`), both of
which report online CPUs while ignoring OMP_NUM_THREADS (pinned to 1 in
CI) and are compiler-independent.

Lower the (ocaml (>= ...)) bound to 4.11 in dune-project and both
hand-maintained .opam files, and extend the CI matrix so the oldest
supported compiler (4.11) exercises both the system fast path and the
vendored CMake fallback. 4.11 is the oldest compiler still carried by
the default opam-repository.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cuihtlauac added a commit that referenced this pull request Oct 25, 2026
Domain.recommended_domain_count was the only OCaml 5-only use in the
build, and it pinned the package to OCaml >= 5. Use the same approach
as #20: getconf _NPROCESSORS_ONLN, falling back to nproc --all (both
ignore OMP_NUM_THREADS), still capped at 6 jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cuihtlauac
cuihtlauac force-pushed the lower-ocaml-floor-4.08 branch from 79b2f7f to 677eea0 Compare October 25, 2026 04:26
@cuihtlauac

cuihtlauac commented Oct 25, 2026 •

Copy link
Copy Markdown
Member Author

Addressed by 0.2.3 (min 6 ncpus, per @mseri on ocaml/opam-repository#30964); this PR is rebased on it and keeps the cap.

@cuihtlauac
cuihtlauac merged commit 4feb282 into main Oct 25, 2026
9 checks passed
cuihtlauac added a commit that referenced this pull request Oct 25, 2026
Domain.recommended_domain_count was the only OCaml 5-only use in the
build, and it pinned the package to OCaml >= 5. Use the same approach
as #20: getconf _NPROCESSORS_ONLN, falling back to nproc --all (both
ignore OMP_NUM_THREADS), still capped at 6 jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cuihtlauac added a commit that referenced this pull request Oct 28, 2026
Domain.recommended_domain_count was the only OCaml 5-only use in the
build, and it pinned the package to OCaml >= 5. Use the same approach
as #20: getconf _NPROCESSORS_ONLN, falling back to nproc --all (both
ignore OMP_NUM_THREADS), still capped at 6 jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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