Skip to content

Add profiling_frameptr feature for jemalloc --enable-prof-frameptr#171

Open
ArniDagur wants to merge 1 commit into
tikv:mainfrom
ArniDagur:profiling-frameptr
Open

Add profiling_frameptr feature for jemalloc --enable-prof-frameptr#171
ArniDagur wants to merge 1 commit into
tikv:mainfrom
ArniDagur:profiling-frameptr

Conversation

@ArniDagur

@ArniDagur ArniDagur commented Jun 30, 2026

Copy link
Copy Markdown

Similar to #159, we introduce profiling_frameptr to enable frame-pointer based profiling via --enable-prof-frameptr.

This option was introduced in jemalloc/jemalloc#2712, which was released as a part of 5.3.1.

We make profiling_frameptr mutually exclusive with profiling_libunwind, since jemalloc configures just a single backtrace method, and we don't want it to silently prefer one over the other.

Summary by CodeRabbit

  • New Features
    • Added a new profiling option using frame-pointer backtraces, enabled via a new feature flag and wired through the allocator crates.
  • Bug Fixes
    • Enforced that libunwind-based and frame-pointer-based profiling modes cannot be enabled together.
    • Restricted the frame-pointer profiling mode to Linux targets.
  • Documentation
    • Updated profiling feature descriptions to note mutual exclusivity and platform/option requirements.

@ti-chi-bot

ti-chi-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Welcome @ArniDagur! It looks like this is your first PR to tikv/jemallocator 🎉

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3db920e2-53d6-4e8d-b4dc-69fd7f2617a5

📥 Commits

Reviewing files that changed from the base of the PR and between 453356d and d6f8285.

📒 Files selected for processing (5)
  • jemalloc-ctl/Cargo.toml
  • jemalloc-sys/Cargo.toml
  • jemalloc-sys/README.md
  • jemalloc-sys/build.rs
  • jemallocator/Cargo.toml
✅ Files skipped from review due to trivial changes (1)
  • jemalloc-sys/README.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • jemallocator/Cargo.toml
  • jemalloc-sys/Cargo.toml
  • jemalloc-sys/build.rs

📝 Walkthrough

Walkthrough

Adds a new profiling_frameptr feature across jemalloc crates, wires build-script support for --enable-prof-frameptr, and documents Linux-only frame-pointer profiling alongside profiling_libunwind.

Changes

profiling_frameptr feature addition

Layer / File(s) Summary
Build script feature wiring and validation
jemalloc-sys/build.rs
Computes profiling_libunwind and profiling_frameptr booleans, rejects enabling both together, and emits --enable-prof-frameptr only for Linux targets.
Cargo feature declarations across crates
jemalloc-sys/Cargo.toml, jemalloc-ctl/Cargo.toml, jemallocator/Cargo.toml
Adds profiling_frameptr feature wiring and mutual-exclusivity comments alongside the existing profiling feature declarations.
README documentation for profiling features
jemalloc-sys/README.md
Adds frame-pointer walk to the profiling options list and documents profiling_frameptr behavior, Linux-only support, and mutual exclusivity with profiling_libunwind.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • tikv/jemallocator#159: Extends the same jemalloc profiling feature wiring that this PR adds profiling_frameptr to.

Suggested reviewers

  • BusyJay

Poem

A rabbit hops with frame-pinned cheer,
Two profiling paths now crystal-clear.
On Linux hops the new one sings,
While unwinding keeps its wings.
🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely captures the main change: adding the new jemalloc profiling_frameptr feature for --enable-prof-frameptr.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Similar to tikv#159, we introduce `profiling_frameptr`
to enable frame-pointer based profiling via `--enable-prof-frameptr`.

This option was introduced in jemalloc/jemalloc#2712, which was released as a part of `5.3.1`.

We make `profiling_frameptr` mutually exclusive with `profiling_libunwind`, since jemalloc configures just a single
backtrace method, and we don't want it to silently prefer one over the other.

Signed-off-by: Arni Dagur <adg@adg.is>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@jemalloc-sys/build.rs`:
- Around line 321-328: The `profiling_frameptr` branch in `build.rs` currently
gates `--enable-prof-frameptr` only on `target`, so a non-Linux build host can
still pass a flag that jemalloc ignores. Update the `profiling_frameptr`
handling to check `host` (or both `host` and `target`) before calling
`cmd.arg("--enable-prof-frameptr")`, and keep the existing `info!`/panic
behavior aligned with the new host-based gate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c8e4ae1-7835-4ab2-ad50-850933ec51f2

📥 Commits

Reviewing files that changed from the base of the PR and between 0e91291 and 453356d.

📒 Files selected for processing (5)
  • jemalloc-ctl/Cargo.toml
  • jemalloc-sys/Cargo.toml
  • jemalloc-sys/README.md
  • jemalloc-sys/build.rs
  • jemallocator/Cargo.toml

Comment thread jemalloc-sys/build.rs

@BusyJay BusyJay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rest LGTM

Comment thread jemalloc-sys/build.rs
// wins over frameptr if both are enabled. We make them mutually exclusive to
// avoid confusion resulting from configuration priority.
if profiling_libunwind && profiling_frameptr {
panic!(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about a warning instead?

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.

2 participants