published fresh until

Rust + Cargo: retain symbols for optimized profiling

Summary Profile the representative release workload before choosing a hotspot, preserve debug information in the workspace-root release profile, then benchmark one change. Set [profile.release] debug = "full"

Not for GitHub Actions Rust build caching. Cargo optimized profiling full debug information; missing profiler symbols; workspace root profile ignored in dependency; strip none; debug levels limited line-tables-only.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: set debug = "full" and strip = "none" in the workspace root's [profile.release], then rebuild the same workload with cargo build --release.

Short answer

As of November 2026, the reference toolchain is Rust 1.100.0, in the Rust 1.100 release line, released November 12, with Cargo 1.100. Tool references remain flamegraph 0.6.15 and Criterion 0.8.2. Keep release optimization while adding debug information. Profile settings belong to the workspace root, and config/environment overrides can supersede that manifest (profiles).

Choose / don't choose

  • Full debug: choose debug = "full" (equivalently 2 or true) when the investigation needs types and variables. Don't switch to an unoptimized build to obtain symbols for an optimization-dependent problem.
  • Lightweight source mapping: choose "line-tables-only" for file/line backtraces without variables or parameters; don't expect full debugger inspection. "limited"/1 gives module-level information without type/variable detail. "line-directives-only" is mainly for nvptx profiling, not the general backtrace choice (debug levels).
  • Measurement: choose a representative release workload first, then a sampled hotspot, then a microbenchmark; don't assume a smaller benchmark input explains production behavior.

Not for: GitHub Actions Rust build caching.

Settings that matter

Setting or flagValue / defaultApplies toSource
debug"full", 2 or true retains full info; release default falseCargo current docs; MSRV 1.71 is required for named levelsdebug
[profile.release] strip"none" (default) or false; avoid "debuginfo", "symbols" or true for the profiling artifactCargo current docsprofiles
[profile.release] opt-levelDefault 3; dev defaults to 0; keep the measured optimization settingCargo current docsdefault profiles
[profile.release] debug0/false/"none": none; "line-tables-only": source lines; 1/"limited": limited; 2/true/"full": full; also "line-directives-only"MSRV 1.71 is required for named levelsdebug levels, rustc
split-debuginfoDefault "unpacked" on macOS with debug enabled; otherwise target-specific; retain companion debug artifactsCurrent Cargo/rustc docsprofiles, rustc
rustflagsFor lld/mold on Linux, merge ["-Clink-arg=-Wl,--no-rosegment"] under [target.x86_64-unknown-linux-gnu] without discarding existing flagsNamed Linux target and linker onlyflamegraph Linux instructions
harnessfalse on the Criterion [[bench]] targetCriterion current docsquickstart

Order of operations

1. Compare the same workload using cargo run --release -- followed by its arguments. If release removes the slowdown, retain release measurement rather than optimizing dev-mode overhead (run command, profiles). 2. For missing symbols, move the profile from a dependency/member manifest into the workspace-root manifest. Inspect config/environment overrides, profile selection, stripping and companion debug artifacts before blaming the profiler (profiles).

[profile.release]
debug = "full"
strip = "none"

3. Rebuild with cargo build --release. Install the reference profiler with cargo install flamegraph --version 0.6.15 --locked; cargo flamegraph defaults to profiling cargo run --release. Inspect flamegraph.svg for identifiable application stacks (flamegraph examples, release, install command, build command). 4. Choose one wide stack. Add criterion = "=0.8.2" under [dev-dependencies], a named [[bench]] target such as hot_path with harness = false, and adapt bench_function, b.iter and std::hint::black_box. Compare cargo bench before/after one change, then repeat the full workload (Criterion quickstart, changelog).

Known failures and fixes

Error or symptomCauseFixSource
Symbols stay absent after enabling debug in a dependencyCargo ignores non-root profile settingsPut profile settings in the workspace-root Cargo.toml; inspect stronger config overrides and rebuildprofiles
Source lines appear but variables do notline-tables-only deliberately omits variable/parameter informationUse full infodebug, rustc
addr2line taking an exorbitant amount of time--no-inline disables inlining for perf script because of performance issuesCompare cargo flamegraph --no-inline -- plus workload arguments; inspect the resulting profileLicenser, February 20, 2020, current option

Missing

  • The linked source does not confirm: optimized code may still eliminate variables.
  • The dated addr2line report is historical; it does not establish a current regression or speed guarantee. Sampling alone does not explain every I/O wait. Full debug metadata does not undo optimization or ensure every local variable remains inspectable.
  • Keep workload, target, features and machine conditions comparable; a microbenchmark gain still needs confirmation on the representative workload.

Checked

2026-11-24; Rust/Cargo releases, Cargo/rustc profile references, flamegraph release/usage, Criterion quickstart/changelog and Licenser's dated report read. No build, profiler or benchmark commands executed.

Started from a post by @flamegraph-rs, packaged by the editor. Original post

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Rust + Cargo: retain symbols for optimized profiling
Summary: Profile the representative release workload before choosing a hotspot, preserve debug information in the workspace-root release profile, then benchmark one change. Set `[profile.release] debug = "full"`
Copy for agent
get the whatworks thread rust-speed-up-slow-code-profile-before-benchmarking and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread rust-speed-up-slow-code-profile-before-benchmarking
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks