Skip to content

debian: build with ninja - #73067

Merged
tchaikov merged 2 commits into
ceph:mainfrom
tchaikov:wip-deb-ninja
Nov 28, 2026
Merged

tchaikov merged 2 commits into
ceph:mainfrom
tchaikov:wip-deb-ninja

Conversation

@tchaikov

@tchaikov tchaikov commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Build Debian packages with Ninja so Ceph's compile and link pools limit concurrent links. Keep the existing 4500 MiB link budget. The GCC change bounds automatic LTRANS parallelism for links in either pool, including Ninja RPM builds on EL9 and EL10. On a 192-thread builder with 255 GiB, the existing pool has 29 heavy slots, giving six workers per link. Explicit GCC job counts are preserved.

Two earlier package builds explain why both changes are needed:

  • Noble build 10226 ran out of memory with automatic LTO parallelism. The heavy pool limited the number of links, but 21 links started about 1,485 LTRANS workers.
  • Build 10249 passed Noble but ran out of memory on Jammy x86_64. GCC 11 kept -flto=auto active even with a later numeric flag. Replacing the flag also in distro compile/link flags and CMake IPO options fixed this in a GCC 11.4 probe: with a requested cap of two, the actual make invocation changed from -j32 to -j2.

Dev-pipeline 11117 was started on the identical source tree at 876ebb14189 with the standard x86_64 matrix, including Jammy and Noble.

Memory after #73063

Measured on a 32-thread host using GCC 14.2, -O2 -g -ffat-lto-objects, and three heavy link slots. The table gives peak summed process-tree PSS in GiB, sampled every 250 ms, using the same objects for each pair. RGW's ELF dependencies include librgw_lancedb.so.1.

Heavy target -flto=auto -flto=10
radosgw 6.61 3.99
librgw.so 5.86 4.27
radosgw-admin 5.55 4.18
denc-mod-rgw.so 6.01 4.24
ceph-osd 4.77 2.42
crimson-osd 9.82 6.14

The existing heavy pool allows about 9000 MiB per slot. These measurements support keeping it. For radosgw-admin and denc-mod-rgw.so, both measurements used GNU ld with the archives in a --start-group/--end-group pair to resolve local link-order errors.

Refs: https://tracker.ceph.com/issues/82052

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@tchaikov
tchaikov requested a review from a team as a code owner October 25, 2026 05:59
@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov
tchaikov force-pushed the wip-deb-ninja branch 4 times, most recently from 2749fe5 to c9f4689 Compare October 25, 2026 07:11
@tchaikov

Copy link
Copy Markdown
Contributor Author

Peak RSS of each link's whole process tree, with -g -O2 -flto=auto -ffat-lto-objects and WITH_RADOSGW_LANCEDB=ON.

target link pool LTRANS jobs (32 threads) peak RSS (32 threads) est. peak RSS (192 threads) budget per link
radosgw heavy 27 7.2 GiB ~9.7 GiB ~12000 MiB
radosgw-admin heavy 29 7.0 GiB ~9.5 GiB ~12000 MiB
ceph-osd heavy 29 5.5 GiB ~8.0 GiB ~12000 MiB
libceph-common.so avg 32 3.1 GiB ~5.6 GiB 6000 MiB
ceph-mon avg 31 3.1 GiB ~5.6 GiB 6000 MiB
librbd.so avg 27 2.6 GiB ~5.1 GiB 6000 MiB
rbd avg 32 2.5 GiB ~5.0 GiB 6000 MiB
40 other links avg ≤ 10 < 1 GiB 6000 MiB

@tchaikov
tchaikov requested a review from yuvalif October 25, 2026 07:15
@tchaikov

Copy link
Copy Markdown
Contributor Author

@yuvalif

yuvalif commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@tchaikov do you know how much time does it add to the build process?
originally, i created the lancedb code as a shared library and linked dynamically, but the feedback was that we prefer static linking (since o/w we need to deliver the library as part of the install process).
given the above, maybe we should take the shared library approach?
(cc @cbodley)

Comment thread cmake/modules/LimitJobs.cmake Outdated
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION OR
"${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" MATCHES "-flto")
# ld, the WPA stage and its LTRANS jobs of a single LTO link
set(MAX_LINK_MEM 6000 CACHE INTERNAL "maximum memory used by each linking job (in MiB)")

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.

Suggested change
set(MAX_LINK_MEM 6000 CACHE INTERNAL "maximum memory used by each linking job (in MiB)")
set(MAX_LINK_MEM 8000 CACHE INTERNAL "maximum memory used by each linking job (in MiB)")

decrease the number of parallel links little further, since ubuntu noble still OOM here:
https://shaman.ceph.com/builds/ceph/wip-pr-73067-kefu/c9f4689ce8aff8ac6738a643dc0e6649d19481d1/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i was looking at it as well. the pools did limit it to 21 heavy links, but each one ran about 71 LTRANS jobs, around 12.4 GB per link. with make, -flto=auto takes job slots from make's jobserver. ninja doesn't have one, so every link starts an LTRANS job per CPU thread. so, in the latest revision, we now pass -flto=N to the linker, where N is the number of CPU threads divided by the heavy pool size.

@tchaikov

tchaikov commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@tchaikov do you know how much time does it add to the build process?

compile / avg link / heavy link jobs build time est. peak memory
192 / 192 / 192 (no pools, like make -j192) 8.5 min ~516 GiB
74 / 43 / 21 (this PR, 255 GiB host) 8.6 min ~264 GiB
74 / 58 / 29 (old 4500 MiB link budget) 8.6 min ~264 GiB
48 / 43 / 21 11.4 min ~212 GiB
32 / 43 / 21 16.8 min ~155 GiB
74 / 8 / 4 11.5 min ~247 GiB

(estimation of peak memory: sum of the per-job peak RSS of the jobs running at the same time.)

I measured what this PR costs. across two full local LTO builds, the LTRANS cap changed the build time by less than 1%.
the limits barely matter because the build time is set by the longest chain: the RGW sources wait for cargo, and crimson-osd has the slowest link.

originally, i created the lancedb code as a shared library and linked dynamically, but the feedback was that we prefer static linking (since o/w we need to deliver the library as part of the install process). given the above, maybe we should take the shared library approach? (cc @cbodley)

i don't have strong preferences. but i think we don't have to pick one -- we can have both of them. actually, what surprised me more is the package size. The linker only pulls in archive members that something references, but rgw_sal_rados.cc calls into the s3vector code, so anything using the rados SAL ends up with most of the archive. I compared the noble packages on shaman: a build of main from 09-15 (just before #66066), main from 10-24, and Matthew's two branches that link librgw_lancedb as a shared library on top of that same main. Installed sizes, in MiB:

package main 09-15 main 10-24 shared lib
ceph-common 136 1369 210
radosgw 76 982 113
librgw2 38 329 282
ceph-test 298 4747 692
all packages 1123 8024 1895

@mheler is already working on this. his wip-rgw-lancedb-link and wip-rgw-lancedb-link-so branches on ceph-ci build librgw_lancedb as a shared library, and they're the "shared lib" column above. going by the sizes, the .so lands in librgw2. if so, ceph-common package would need to depend on it, because radosgw-admin and the other tools in there link it. we already ship libceph-common.so as a private library under /usr/lib/ceph, so that kind of packaging has a precedent. I couldn't find an upstream PR for those branches. Matthew, do you plan to open one? it should be a separate PR from this one, which is just about the OOM.

EDIT, i just found #73063 which builds librgw_lancedb.so.

@mheler

mheler commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

@tchaikov do you know how much time does it add to the build process?

compile / avg link / heavy link jobs build time est. peak memory
192 / 192 / 192 (no pools, like make -j192) 8.5 min ~516 GiB
74 / 43 / 21 (this PR, 255 GiB host) 8.6 min ~264 GiB
74 / 58 / 29 (old 4500 MiB link budget) 8.6 min ~264 GiB
48 / 43 / 21 11.4 min ~212 GiB
32 / 43 / 21 16.8 min ~155 GiB
74 / 8 / 4 11.5 min ~247 GiB

(estimation of peak memory: sum of the per-job peak RSS of the jobs running at the same time.)

I measured what this PR costs. across two full local LTO builds, the LTRANS cap changed the build time by less than 1%. the limits barely matter because the build time is set by the longest chain: the RGW sources wait for cargo, and crimson-osd has the slowest link.

originally, i created the lancedb code as a shared library and linked dynamically, but the feedback was that we prefer static linking (since o/w we need to deliver the library as part of the install process). given the above, maybe we should take the shared library approach? (cc @cbodley)

i don't have strong preferences. but i think we don't have to pick one -- we can have both of them. actually, what surprised me more is the package size. The linker only pulls in archive members that something references, but rgw_sal_rados.cc calls into the s3vector code, so anything using the rados SAL ends up with most of the archive. I compared the noble packages on shaman: a build of main from 09-15 (just before #66066), main from 10-24, and Matthew's two branches that link librgw_lancedb as a shared library on top of that same main. Installed sizes, in MiB:
package main 09-15 main 10-24 shared lib
ceph-common 136 1369 210
radosgw 76 982 113
librgw2 38 329 282
ceph-test 298 4747 692
all packages 1123 8024 1895

@mheler is already working on this. his wip-rgw-lancedb-link and wip-rgw-lancedb-link-so branches on ceph-ci build librgw_lancedb as a shared library, and they're the "shared lib" column above. going by the sizes, the .so lands in librgw2. if so, ceph-common package would need to depend on it, because radosgw-admin and the other tools in there link it. we already ship libceph-common.so as a private library under /usr/lib/ceph, so that kind of packaging has a precedent. I couldn't find an upstream PR for those branches. Matthew, do you plan to open one? it should be a separate PR from this one, which is just about the OOM.

EDIT, i just found #73063 which builds librgw_lancedb.so.

I think both my PR and @tchaikov is the right direction. However I feel both are trying to solve symptoms of the problem. I did some digging, and the noble and jammy builds started failing in #72180 , I believe this is due to the fact the RadosVectorBucket became a subclass of RadosBucket with an inline destructor. Every rgw file that deletes a Bucket gets a copy of that destructor, and each copy needs RadosStore, so even the small rgw test and tool binaries now link most of rgw_common. That makes every rgw link heavier, and the debs are the ones that tip over. Before that merge, jammy and noble passed every time on the 264 GiB builders, and since then they mostly fail, while the rpm builds still pass on the same builders. Defining the destructor out of line, like RadosBucket's, should fix it, and I'm putting it through ceph-ci to confirm.

@yuvalif
yuvalif self-requested a review October 26, 2026 08:08
@yuvalif

yuvalif commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

@tchaikov did you test with clang?
when i tried:

$ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-flto ..

i got:

$ ninja radosgw
[48/84] Linking CXX shared library lib/libceph-common.so.2
FAILED: lib/libceph-common.so.2
...
clang++: error: unsupported argument '3' to option '-flto='

@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov did you test with clang? when i tried:

$ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS=-flto ..

i got:

$ ninja radosgw
[48/84] Linking CXX shared library lib/libceph-common.so.2
FAILED: lib/libceph-common.so.2
...
clang++: error: unsupported argument '3' to option '-flto='

just tested. and it seems like clang does not support -flto= -- it supports -flto-jobs=N though. fixed and repushed.

@djgalloway

Copy link
Copy Markdown
Contributor

@tchaikov

Copy link
Copy Markdown
Contributor Author

Claude suggests bumping https://github.com/tchaikov/ceph/blob/wip-deb-ninja/debian/control#L17 since cmake+ninja arrived in debhelper 11.2.

@djgalloway hi David, thanks! indeed. actually, debian/compat is already 12, so i changed it to 12.

@djgalloway

Copy link
Copy Markdown
Contributor

@tchaikov, thanks for the debhelper bump to 12. That item is resolved.

gcc 11 blocks the merge

The "cmake: cap the LTRANS jobs of each LTO link" commit doesn't work on jammy. Ubuntu's dpkg-buildflags puts -flto=auto in CXXFLAGS and LDFLAGS, then the PR appends -flto=N with add_link_options. In gcc 11, once lto-wrapper sees -flto=auto, it keeps auto_parallel set and builds its make -j from auto_parallel ? nthreads_var : parallel. The later -flto=N is ignored. gcc 13 honours the last value.

I intercepted the make spawned by lto-wrapper on an 80-thread host:

compiler -flto=auto -flto=2
gcc 13.3 (noble) make -j2
gcc 11.4 (jammy) make -j80

The CI history matches. The PR description cites build 10226, which OOMed on noble before the cap was added. The only dev-pipeline build of the capped version, 10249, also failed, on jammy x86_64 default on soko11 (80 threads, 251 GiB). All 270 link lines have -flto=3, but the OOM dump shows 21 heavy links each running about 71 lto1-ltrans processes. They were all under the jenkins-build uid on a single-executor node, so no other build was running on the host. Noble built fine in the same run. Neither failure is mentioned on the PR.

In the same commit, replace -flto=auto instead of appending to it. Use string(REPLACE "-flto=auto" "-flto=${_ltrans_jobs}" ...) over CMAKE_C_FLAGS, CMAKE_CXX_FLAGS, CMAKE_EXE_LINKER_FLAGS, CMAKE_SHARED_LINKER_FLAGS and CMAKE_MODULE_LINKER_FLAGS. Keep add_link_options only for the CMAKE_INTERPROCEDURAL_OPTIMIZATION case where the flags don't contain -flto=auto. Replacing it in the compile flags too is harmless and removes the four copies of -flto=auto from every link line. Stripping it in debian/rules is the wrong fix. Those flags also turn LTO on at compile time, and LimitJobs detects LTO from them.

Before merge

#73063 merged today, so the memory tables in the two cmake commits are stale. They were measured against the static librgw_lancedb.a tree. Please rebase on main and re-measure the heavy links. The 6000 MiB budget may no longer be needed. If it stays, justify it with post-73063 numbers.

Both cmake commits affect every Ninja + LTO build. RPM builds on el9/el10 will get fewer concurrent links and a 9-thread LTRANS cap on a 192-thread builder. Please mention that in the commit messages.

Before merge, please run the final head through dev-pipeline with jammy and noble on a gigantic node and get a green result. Please also link both failed builds in the description.

The "debian: build with ninja" commit is independent and fine on its own. If the dev-pipeline failures are holding things up, that commit could be split out and merged now.

Minor points I mentioned before: the cap applies to all links but is sized from the heavy pool; LTO detection misses CMAKE_CXX_FLAGS_<CONFIG> and the shared/module linker flags; and the two MAX_LINK_MEM cache sets could be one.

@tchaikov
tchaikov force-pushed the wip-deb-ninja branch 3 times, most recently from 876ebb1 to 02f08a0 Compare November 21, 2026 07:24
@tchaikov

Copy link
Copy Markdown
Contributor Author

@djgalloway Thanks, David. I folded the GCC 11 fix into the CMake commit and verified that -flto=2 now runs make -j2. I remeasured the heavy links after #73063 and kept the 4500 MiB budget. The PR now documents the RPM impact and both earlier failures. Jammy and Noble passed on the same source tree as the current head, see https://shaman.ceph.com/builds/ceph/wip-pr-73067-kefu-4/876ebb14189f376abdee9fb8b589a007a8de6ca5/

Use the compile and link pools in LimitJobs for Debian package builds.
With Make, several memory-intensive links can start together as soon as
their common dependencies finish. Ninja lets us limit concurrent links
separately while keeping the rest of the package build parallel.

Select cmake+ninja for all debhelper build steps. It requires debhelper
11.2 or later. Raise the minimum to 12 to match debian/compat.

Refs: https://tracker.ceph.com/issues/82052
Signed-off-by: Kefu Chai <[email protected]>
Without a jobserver, GCC's -flto=auto can start an LTRANS worker per
CPU in each concurrent link. Divide the CPU count by the heavy link
pool size and use the result for automatic LTO links in either pool.
This also applies to Ninja RPM builds on EL9 and EL10. A 192-thread
host with 255 GiB has 29 heavy slots at the existing 4500 MiB budget,
giving six workers per link.

Replace -flto=auto in the C/C++ compile flags, executable, shared and
module linker flags, active configuration flags, and GNU IPO options.
GCC 11 remembers auto even after a later -flto=N. Jammy's GCC 11.4
ran make -j32 for -flto=auto -flto=2 and make -j2 after replacement.
Keep explicit GCC job counts and use -flto-jobs=N for Clang ThinLTO.

After ceph#73063, RGW loads librgw_lancedb.so.1. Peak process-tree PSS
in GiB on GCC 14.2, using the same -O2 -g fat LTO objects, 32 CPUs
and three heavy slots:

  target             auto   N=10
  radosgw            6.61   3.99
  librgw.so          5.86   4.27
  radosgw-admin      5.55   4.18
  denc-mod-rgw.so    6.01   4.24
  ceph-osd           4.77   2.42
  crimson-osd        9.82   6.14

Both radosgw-admin and denc-mod-rgw used a GNU ld archive group in
both runs. The capped peaks fit the existing heavy pool allowance of
about 9000 MiB per slot.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov
tchaikov merged commit 5f06189 into ceph:main Nov 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants