Skip to content

Cherry pick #102759 to 26.3: Apply Poisson sampling correction to collapsed jemalloc heap profiles - #102872

Merged
robot-ch-test-poll2 merged 7 commits into
backport/26.3/102759from
cherrypick/26.3/102759
Apr 16, 2026
Merged

robot-ch-test-poll2 merged 7 commits into
backport/26.3/102759from
cherrypick/26.3/102759

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #102759

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

antonio2368 and others added 6 commits April 15, 2026 11:22
Previously, `JemallocProfileSource::generateCollapsed` reported raw
sampled bytes/counts without the Poisson sampling correction that
jeprof applies via `AdjustSamples`. This caused collapsed profiles to
underestimate actual allocation sizes (e.g. ~5.9 GB raw vs ~11.2 GB
corrected for a real profile with 524288-byte sampling interval).

The fix parses the `heap_v2/N` header to extract the sampling interval,
then scales each sample by `1/(1-exp(-mean_size/interval))` using
`std::expm1` for numerical stability. Edge cases (zero bytes, zero
count, non-finite results, overflow) are guarded.

Also adds a `WriteBuffer` overload of `symbolizeJemallocHeapProfile`
and unit tests verifying the correction against a hardcoded expected
value computed from jeprof's formula.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Use tryReadIntText instead of parseInt so that malformed heap_v2
headers (e.g. heap_v2/abc) return 0 instead of throwing, keeping
collapsed output generation best-effort.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Verify that heap_v2/abc falls back to raw values without throwing.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
# Conflicts:
#	src/Processors/Sources/JemallocProfileSource.cpp
Resolve conflict in symbolizeJemallocHeapProfile overloads — master
already extracted pullProfileLines and added
symbolizeJemallocHeapProfileToString, so drop the redundant WriteBuffer
overload and use the new API in tests. Also use std::move on
out.str() to avoid copying the string buffer.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Apply Poisson sampling correction to collapsed jemalloc heap profiles
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants