Skip to content

Write symbolized jemalloc profiles (eliminating the need for a binary during heap profile generation)#93099

Merged
azat merged 3 commits intoClickHouse:masterfrom
azat:jemalloc-symbolize
Jan 1, 2026
Merged

Write symbolized jemalloc profiles (eliminating the need for a binary during heap profile generation)#93099
azat merged 3 commits intoClickHouse:masterfrom
azat:jemalloc-symbolize

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Dec 27, 2025

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Write symbolized jemalloc profiles (eliminating the need for a binary during heap profile generation)

It was inconvenience for a long time that you need the binary for jemalloc heap profiler (different architecture, different versions and so on)

This patch will write second file with a .symbolized prefix, for which you do not need binary anymore for jeprof, and you can simply run, i.e. jeprof --text heap.0.symbolized

Internally jeprof supports symbolized profiles, you just need to provide a map from addresses to symbols (with some quirks) and jeprof will read it out of the box.

Note, I've though about adding special hooks for jemalloc, but it is tricky, since you cannot everything inside generating this profile, so this implementation simply reads the file written my jemalloc, and creates a new profile with a .symbolized prefix.

Also note that query execution time for SYSTEM JEMALLOC FLUSH PROFILE increased to 10 seconds (egh, handling inlines is slow, in comparison plain jeprof works way slower, but jeprof --tools addr2line:/usr/bin/llvm-addr2line,nm:/usr/bin/llvm-nm,objdump:/usr/bin/objdump,c++filt:/usr/bin/llvm-cxxfilt takes ~90 seconds). And since it takes time, it is done only for SYSTEM JEMALLOC FLUSH PROFILE, and not for jemalloc_flush_profile_interval_bytes/jemalloc_flush_profile_on_memory_exceeded

P.S. I've compared the flamegraphs w/ symbolized profiles and w/o, and I did not noticed any difference except for differences in inline demangling, but this should be minor

@azat azat requested a review from antonio2368 December 27, 2025 17:05
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Dec 27, 2025

Workflow [PR], commit [6d5ce15]

Summary:

job_name test_name status info comment
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Dec 27, 2025
@azat azat force-pushed the jemalloc-symbolize branch 2 times, most recently from c218b92 to b655a61 Compare December 27, 2025 19:28
@azat azat added the 🎅 🎁 gift🎄 To make people wonder label Dec 27, 2025
@yariks5s yariks5s self-assigned this Dec 29, 2025
azat added 3 commits December 31, 2025 19:15
We already have "official documentation"
It was inconvenience for a long time that you need the binary for
jemalloc heap profiler (different architecture, different versions and
so on)

This patch will write second file with a `.symbolized` prefix, for which
you do not need binary anymore for `jeprof`, and you can simply run,
i.e. `jeprof --text heap.0.symbolized`

Internally `jeprof` supports symbolized profiles, you just need to
provide a map from addresses to symbols (with some quirks) and `jeprof`
will read it out of the box.

Note, I've though about adding special hooks for jemalloc, but it is
tricky, since you cannot everything inside generating this profile, so
this implementation simply reads the file written my jemalloc, and
creates a new profile with a `.symbolized` prefix.
@azat azat force-pushed the jemalloc-symbolize branch from 7b783e7 to 6d5ce15 Compare December 31, 2025 18:28
@azat azat enabled auto-merge December 31, 2025 18:47
@azat azat disabled auto-merge December 31, 2025 18:48
@azat azat added this pull request to the merge queue Jan 1, 2026
Merged via the queue into ClickHouse:master with commit 3fad310 Jan 1, 2026
129 of 131 checks passed
@azat azat deleted the jemalloc-symbolize branch January 1, 2026 04:03
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎅 🎁 gift🎄 To make people wonder pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants