Repository navigation
[chore](build) Build BE against the prebuilt OpenBLAS and datasketches-cpp - #68619
Draft
morningman wants to merge 1 commit into
Draft
morningman wants to merge 1 commit into
morningman wants to merge 1 commit into
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
3 of 16 tasks
Contributor
Author
|
Folded into #68617, which now carries the third-party and the BE changes as a single commit. |
…s-cpp ### What problem does this PR solve? Issue Number: N/A Related PR: apache#68617 (adds the two libraries to the third-party build) Problem Summary: contrib/openblas and contrib/datasketches-cpp are git submodules that `build.sh --be` and `run-be-ut.sh` update on every run. On a fresh checkout that clones the whole apache/doris-thirdparty repository for contrib/openblas (about 650 MB on GitHub), or downloads a 24.7 MB tarball when the clone fails. Every cold BE build then compiles OpenBLAS in its build directory: 6,725 build steps on macOS arm64, where the rest of the BE is 740 unity steps, and 12,577 on Linux x86_64, where DYNAMIC_ARCH builds kernels for every CPU generation. apache#68617 adds both libraries to the third-party build; this PR builds the BE against them and removes the submodules. - be/cmake/thirdparty.cmake imports lib64/libopenblas.a as the `openblas` target, with NOTADD because only faiss needs it. contrib/faiss already links a target of that name when one exists, so faiss itself is unchanged, and the cmake-protect directory no longer configures OpenBLAS. - The datasketches-cpp headers come from include/DataSketches and are included as <DataSketches/hll.hpp>, the way BE included them before apache#66511. The add_subdirectory() build and its DataSketches::HLL link go away. - build.sh and run-be-ut.sh stop updating the two submodules, and .gitmodules drops them. build.sh drops --enable-dynamic-arch / --disable-dynamic-arch, which only set DYNAMIC_ARCH for the in-tree OpenBLAS; the third-party build decides that now. (The ENABLE_DYNAMIC_ARCH environment variable they documented was overwritten before it was read.) - conf/ubsan_ignorelist.txt drops contrib/openblas: the prebuilt library is not instrumented, like every other third-party library. - Comments and docs that named the two submodules are updated. A side effect on macOS: the in-tree OpenBLAS configure step ran an ASAN-instrumented getarch probe, which is where ASAN builds hung on macOS 26.4+ with llvm@20. BE builds no longer run it. A BE build needs a third-party tree that has the two libraries, so this lands only after the prebuilt packages have been refreshed; a local tree can add them with `thirdparty/build-thirdparty.sh openblas datasketches`. Without them the BE build stops before compiling anything, with ninja reporting libopenblas.a as missing. ### Release note None ### Check List (For Author) - Test: Manual test - macOS arm64: with the two libraries from build-thirdparty.sh, `build.sh --be` (Release, clang 20) builds and links doris_be. faiss is configured with the imported target ("Using OpenBLAS target for linking"), and doris_be resolves sgemm_, ssyrk_ and dsyev_ from the prebuilt libopenblas.a. The libfaiss.a of this build, linked against the prebuilt library, passes the smoke test described in apache#68617. - build-support/check-build-hygiene.sh passes; clang-format 16 reports no changes to the two C++ files. - Behavior changed: Yes. build.sh no longer accepts --enable-dynamic-arch or --disable-dynamic-arch, and a BE build needs a third-party tree that contains OpenBLAS and datasketches-cpp. - Does this need documentation: No Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
Author
morningman
added a commit
to morningman/doris
that referenced
this pull request
Sep 29, 2026
…rty build ### What problem does this PR solve? Issue Number: N/A Related PR: apache#68619 (switches BE to these packages) Problem Summary: OpenBLAS (which faiss uses for the ANN index) and datasketches-cpp are git submodules under contrib/. Every `build.sh --be` and `run-be-ut.sh` runs `git submodule update` on them; on a fresh checkout that clones the whole apache/doris-thirdparty repository for contrib/openblas (about 650 MB on GitHub), or downloads a 24.7 MB tarball when the clone fails. Every cold BE build then compiles OpenBLAS in its build directory: 6,725 build steps on macOS arm64, where the rest of the BE is 740 unity steps, and 12,577 on Linux x86_64, where DYNAMIC_ARCH builds kernels for every CPU generation. Doris does not modify either library, so both belong in the third-party build like the other dependencies. This PR adds them there. apache#68619 switches BE over and removes the submodules; it can only land after the prebuilt third-party packages carry the two libraries. OpenBLAS 0.3.30 comes from the upstream release. The doris-thirdparty openblas branch is that release plus two build-only edits (it forces `-O3 -Wno-everything` so that the in-tree Debug and ASAN builds compile, and it comments out a CMake message); every other file is identical, and a Release third-party build compiles with -O3 anyway. It is configured the way be/src/storage/index/ann/cmake-protect configured the in-tree build: static, LAPACK built from its C translation plus ReLAPACK, no CBLAS, no Fortran, OpenMP threading, no AVX-512. Three settings that the in-tree build took from the machine running it are pinned, since a prebuilt archive is built on a CI runner and then runs everywhere: - NUM_THREADS=128. It defaults to the build host's core count and caps the threads one call can use at run time, so a 4-vCPU runner would cap it at 4. - DYNAMIC_ARCH on Linux, now on aarch64 too, so the kernels are chosen on the CPU that runs BE. On aarch64 the in-tree build compiled for the build host only. The arm64 prebuilt is built on GitHub's Cobalt 100 (Neoverse N2) runners, and when OpenBLAS detects that core it compiles the whole library with -march=armv8.5-a+sve+sve2, which faults on Graviton2, Ampere Altra or Kunpeng 920. - TARGET, the CPU the code outside the kernels is compiled for, which also follows the build host unless set (OpenBLAS's README recommends setting it with DYNAMIC_ARCH): HASWELL, or NEHALEM plus NO_AVX/NO_AVX2 when USE_AVX2=0 as cmake-protect did, and ARMV8 on aarch64, the same baselines BE uses. With gcc the build names the OpenMP flag and library itself. gcc in the LDB toolchain v0.25, which the Linux job of build-thirdparty.yml builds with, is configured for offloading (--enable-offload-targets=nvptx-none) but ships no crtoffloadbegin.o or crtoffloadend.o, so every link with -fopenmp fails and so does FindOpenMP's probe. Compiling with -fopenmp works, and a static library is never linked. macOS keeps host detection, as before. Homebrew's LLVM ships no OpenMP runtime, so the build points FindOpenMP at Homebrew's libomp, the runtime BE already links on macOS, and stops with an explicit message when it is not installed. The macOS jobs of build-thirdparty.yml install it. The apache/doris-thirdparty automation installs its own macOS packages and needs the same addition before this lands, or its macOS legs fail at this package. datasketches-cpp is pinned to 46025e9, the commit contrib/ pins, because no release carries its HLL union fix yet. It is header-only and installs into include/DataSketches, where BE included it from before apache#66511. ### Release note None ### Check List (For Author) - Test: Manual test - macOS arm64, clang 20: `build-thirdparty.sh openblas datasketches` with no libomp flags in the environment, as on CI. With a stubbed `brew` that has no libomp, the build stops with the explicit message. - Linux x86_64 in apache/doris:build-env-ldb-toolchain-latest: `DORIS_TOOLCHAIN=clang build-thirdparty.sh openblas datasketches`, the configuration of the doris-thirdparty automation; faiss built against the result passes the smoke test below. At run time DYNAMIC_ARCH picks the Nehalem kernels on the Rosetta-emulated CPU, and the library reports MAX_THREADS=128. - aarch64 DYNAMIC_ARCH with TARGET=ARMV8 and clang 20 (on the macOS host, as there is no aarch64 Linux image with the toolchain here): all 14 cores compile, the SVE and SME ones included, and on a CPU without SVE the library selects neoversen1 and passes the smoke test. - Smoke test: faiss linked against the prebuilt libopenblas.a runs IndexFlatL2 search (sgemm), PCA training (ssyrk + dsyev; the eigenvalues add up to the trace), OPQ training (sgesvd; the rotation is orthonormal to 1e-6) and IVF-PQ training and search under OpenMP, all correct. - Linux x86_64 in the same image with DORIS_TOOLCHAIN=gcc, the configuration of the Linux job of build-thirdparty.yml: without the explicit OpenMP settings configure fails with "Could NOT find OpenMP_C"; with them both packages build. The gcc-built library calls the GOMP_* entry points; faiss built with clang against it passes the smoke test with the LDB libomp supplying them, so a third-party tree built with gcc still links into a clang-built BE. - The OpenBLAS 0.3.30 release differs from the doris-thirdparty openblas branch only in the edits described above (`diff -r`). - thirdparty/test: the download fallback, md5, juicefs mirror, azure retry and adbc JNI configuration tests pass. - Behavior changed: No. Nothing uses the new packages yet. - Does this need documentation: No Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
morningman
force-pushed
the
be-use-prebuilt-openblas-datasketches
branch
from
September 29, 2026 07:56
392c6fa to
76ab92d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: N/A
Related PR: #68617 (adds the two libraries to the third-party build; must be merged first), #66511 (moved datasketches-cpp into the BE CMake tree)
Do not merge before #68617 is merged and the prebuilt third-party archives from apache/doris-thirdparty contain
libopenblas.aandinclude/DataSketches. Until then BE fails to build: ninja stops right away withlibopenblas.amissing.Problem Summary:
Context. faiss (the ANN index) links OpenBLAS, and the
datasketches_hll_union_aggfunctions include the datasketches-cpp headers. Both are git submodules undercontrib/, fetched bybuild.sh --beandrun-be-ut.shbefore every build and built inside the BE build directory:be/src/storage/index/ann/cmake-protectadd_subdirectory()s OpenBLAS, andbe/CMakeLists.txtadd_subdirectory()s datasketches-cpp (header-only). #68617 adds both tothirdparty/, whose prebuilt archives CI and developers already download.1. The problem, and what it cost
git submodule updateclones the whole apache/doris-thirdparty repository (about 650 MB on GitHub) forcontrib/openblas, or downloads a 24.7 MB tarball when the clone fails.DYNAMIC_ARCHbuilds kernels for every CPU generation.getarchprobe, which is where macOS ASAN builds hung before [fix](build) Move the macOS toolchain to LLVM 22 so ASAN works on macOS 26.4+ #68595.2. What this PR does, and why it helps
be/cmake/thirdparty.cmakeimportslib64/libopenblas.aas theopenblastarget, withNOTADDbecause only faiss needs it.contrib/faissalready links a target of that name when one exists (it printsUsing OpenBLAS target for linking), so faiss itself is unchanged, andcmake-protectno longer configures OpenBLAS.include/DataSketchesand are included as<DataSketches/hll.hpp>, the way BE included them before [Fix](build) Manage datasketches-cpp in the BE CMake build tree #66511. Theadd_subdirectory()build, itsDataSketches::HLLlink and theBUILD_TESTSsetting it needed go away.build.shandrun-be-ut.shstop updating the two submodules, and.gitmodulesdrops them.build.shdrops--enable-dynamic-arch/--disable-dynamic-arch: they only setDYNAMIC_ARCHfor the in-tree OpenBLAS, and the third-party build decides that now. (TheENABLE_DYNAMIC_ARCHenvironment variable they documented was overwritten before it was read.)conf/ubsan_ignorelist.txtdropscontrib/openblas: the prebuilt library is not instrumented, like every other third-party library.be-ut-mac.yml,compile-bench,fe/.idea/vcs.xml).What it buys:
getarchprobe.3. How the pieces fit
Not touched: faiss, apache-orc and clucene stay submodules; the BE source only changes the include path of
hll.hppin two files.Release note
None
Check List (For Author)
Test
build-thirdparty.sh,build.sh --be(Release, clang 20) builds and linksdoris_be. faiss is configured with the imported target (Using OpenBLAS target for linking), anddoris_beresolvessgemm_,ssyrk_anddsyev_from the prebuiltlibopenblas.a. Thelibfaiss.aof that build, linked against the prebuilt library, passes the smoke test described in [chore](thirdparty) Add OpenBLAS and datasketches-cpp to the third-party build #68617 (sgemm,ssyrk+dsyev,sgesvd, IVF-PQ under OpenMP).build-support/check-build-hygiene.shpasses; clang-format 16 reports no changes to the two C++ files.Behavior changed:
build.shno longer accepts--enable-dynamic-archor--disable-dynamic-arch. A BE build needs a third-party tree that contains OpenBLAS and datasketches-cpp: refresh the prebuilt package, or runthirdparty/build-thirdparty.sh openblas datasketches.Does this need documentation?
Check List (For Reviewer who merge this PR)