Skip to content

rgw: declare rgw_a's dependency on heap_profiler - #71481

Merged
mkogan1 merged 1 commit into
ceph:mainfrom
aaltshuler:rgw-a-heap-profiler
Sep 23, 2026
Merged

mkogan1 merged 1 commit into
ceph:mainfrom
aaltshuler:rgw-a-heap-profiler

Conversation

@aaltshuler

@aaltshuler aaltshuler commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Building main (and wip-s3vector, which is rebased on it) with
-DWITH_MOLD=ON fails to link radosgw-admin:

mold: error: undefined symbol: ceph_heap_profiler_init()
mold: error: undefined symbol: ceph_using_tcmalloc()
mold: error: undefined symbol: ceph_heap_profiler_handle_command(std::vector<std::string>...)

Root cause: 6d8851a (#67446) made rgw_appmain.cc — a member of
rgw_a — call the heap profiler, but declared heap_profiler only on
radosgw, rgw (librgw) and rgw_a_standalone, never on rgw_a.
radosgw-admin does not use AppMain; mold pulls the object in anyway
through archive resolution. Replaying the link with -Wl,-y:

trace-symbol: src/arrow/lib/libarrow.a(pretty_print.cc.o) keeps lib/librgw_a.a(rgw_file.cc.o) for std::__cxx11::basic_string<...>::front()
trace-symbol: lib/librgw_a.a(rgw_lib.cc.o): definition of rgw::RGWLibProcess::process_request(rgw::RGWLibRequest*)
trace-symbol: lib/librgw_a.a(rgw_appmain.cc.o): definition of rgw::AppMain::init_frontends1(bool)
trace-symbol: lib/librgw_a.a(rgw_appmain.cc.o): unresolved symbol ceph_heap_profiler_init()

The identical link command with -fuse-ld=bfd succeeds (lazy extraction
never touches rgw_appmain.o), which is why CI does not see it.

This declares the dependency on the library whose translation unit uses
it — the pattern kv/mon/osd/mds/bluestore already follow, and the same fix
shape as 056b706 ("rgw: declare rgw_a's dependency on rgw_schedulers
and kmip") — and drops the now-redundant explicit links.

Consequences: under tcmalloc builds, rgw_a-linking tools gain a
libtcmalloc.so.4 runtime dependency (radosgw-admin, rgw-policy-check/
-test, radosgw-es, radosgw-object-expirer, denc-mod-rgw); packaging picks
it up automatically, as it already does for rgw-standalone-admin. Under
ALLOCATOR=libc the stub archive has no dependencies. Note that
6d8851a also re-linked librgw.so against tcmalloc (cf. c4b4ba5 /
tracker 63394); this change leaves librgw as it is today.

Verified: Ubuntu 24.04 aarch64, gcc-14, mold 2.41.0, Debug, tcmalloc —
radosgw-admin, radosgw, radosgw-es, radosgw-object-expirer,
rgw-policy-check and rgw-policy-test link; ceph_heap_profiler_init is
defined in each; vstart radosgw-admin user list works.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E63tgb7eXHwzmaQBSErFWu

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

6d8851a added the tcmalloc heap profiler hook to rgw_appmain.cc, which
is part of rgw_a, but only declared the heap_profiler dependency on
radosgw, the rgw shared library and rgw_a_standalone. rgw_a itself never
declared it, so every other consumer of rgw_a depends on the linker not
extracting rgw_appmain.cc.o.

ld.bfd hides this via lazy archive extraction. mold resolves COMDAT
symbols to the earliest archive member on the command line, so a
std::string::front() reference from libarrow.a pulls librgw_a.a(rgw_file)
-> rgw_lib -> rgw_appmain into radosgw-admin, which then fails with
undefined ceph_heap_profiler_init(), ceph_using_tcmalloc() and
ceph_heap_profiler_handle_command(). Any rgw_a consumer (radosgw-es,
rgw-policy-*, denc-mod-rgw, the rgw unit tests) can fail the same way.

Declare heap_profiler on rgw_a (PRIVATE), matching rgw_a_standalone, and
drop the now redundant explicit links from radosgw and the rgw shared
library.

Fixes: 6d8851a
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E63tgb7eXHwzmaQBSErFWu
Signed-off-by: Andrew Altshuler <[email protected]>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR ci-approved to allow Jenkins CI jobs to run.

@yuvalif

yuvalif commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@aaltshuler can you please add the PR checklist to the main comment:

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)

@aaltshuler

Copy link
Copy Markdown
Contributor Author

@yuvalif checklist added (Verify Checklist is green now); make check passed on x86 and arm64. Ready for review whenever convenient.

@mkogan1 flagging you as the merger of #67446, which this fixes — it declares the heap_profiler dependency on rgw_a where rgw_appmain.cc uses it, so mold-linked builds of radosgw-admin (and the other rgw_a consumers) link again; GNU ld only masked it via lazy archive extraction.

@yuvalif yuvalif mentioned this pull request Sep 14, 2026
4 of 14 tasks
@yuvalif

yuvalif commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@aaltshuler thanks for you contribution!
looks like there is overlap with this one: #71481
can you please have a look there?

@aaltshuler

Copy link
Copy Markdown
Contributor Author

Thanks — yes, #70307's 7efbf932b ("rgw: link heap_profiler into rgw_a") is the same fix; it landed there first and I missed it. Happy to close this one in favor of #70307, since that PR is approved and covers the other mold link fixes too.

The only extra here is dropping the now-redundant explicit heap_profiler links on radosgw and rgw (they become transitive via rgw_a); I can send that as a one-liner after #70307 merges if you want it. I'll close this PR once you confirm.

@mkogan1 mkogan1 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.

@mkogan1 flagging you as the merger of #67446, which this fixes — it declares the heap_profiler dependency on rgw_a where rgw_appmain.cc uses it, so mold-linked builds of radosgw-admin (and the other rgw_a consumers) link again; GNU ld only masked it via lazy archive extraction.

Thanks, was able to repro the link failure to check the fix:

on current main:

❯ glo | head
481c3130957 (origin/main, origin/HEAD) Merge pull request #71761 from tchaikov/wip-test-seastore-looku

❯ ./do_cmake.sh -DWITH_MOLD=ON -DALLOCATOR=tcmalloc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_MGR_DASHBOARD_FRONTEND=OFF -DWITH_TESTS=OFF

❯ cmake --build ./build --parallel $(nproc --ignore=1) --verbose
...
mold: error: undefined symbol: ceph_using_tcmalloc()  
...

after cherry-pick of this PR commiit

❯ git cherry-pick -ex b0e20b08e1a5732437a761ee3bd9d56bb4fee7b2

it builds and the tcmalloc heap stats work:

❯ sudo ./bin/ceph daemon 'client.rgw.8000' heap stats
client.rgw.8000 tcmalloc heap stats:------------------------------------------------
MALLOC:       55560512 (   53.0 MiB) Bytes in use by application
MALLOC: +       491520 (    0.5 MiB) Bytes in page heap freelist
MALLOC: +       385376 (    0.4 MiB) Bytes in central cache freelist
MALLOC: +      3570176 (    3.4 MiB) Bytes in transfer cache freelist
MALLOC: +      2489184 (    2.4 MiB) Bytes in thread cache freelists
MALLOC: +      2883584 (    2.8 MiB) Bytes in malloc metadata
MALLOC:   ------------
MALLOC: =     65380352 (   62.4 MiB) Actual memory used (physical + swap)
MALLOC: +            0 (    0.0 MiB) Bytes released to OS (aka unmapped)
MALLOC:   ------------
MALLOC: =     65380352 (   62.4 MiB) Virtual address space used
MALLOC:
MALLOC:            916              Spans in use
MALLOC:             82              Thread heaps in use
MALLOC:           8192              Tcmalloc page size
------------------------------------------------
Call ReleaseFreeMemory() to release freelist memory to the OS (via madvise()).
Bytes released to the OS take up virtual address space but no physical memory.

@anrao19

anrao19 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-09-17-04:59.

@anrao19

anrao19 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-09-17-04:59.

Testing completed and got approval from @ivancich, morr details in https://tracker.ceph.com/issues/80592).
@aaltshuler , if no further testing is needed then this pr can be merged

@mkogan1
mkogan1 merged commit 7f6c02e into ceph:main Sep 23, 2026
19 of 20 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