Skip to content

Add note about how to preserve debug symbols in Rust #21347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/content/docs/workers/observability/dev-tools/cpu-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ To generate a CPU profile:

You now have a CPU profile.

:::note

For Rust Workers, add the following to your `Cargo.toml` to preserve [DWARF](https://dwarfstd.org/) debug symbols (from [this comment](https://github.com/rustwasm/wasm-pack/issues/1351#issuecomment-2100231587)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @lukevalenta 👋 Is wasm an industry standard that we trust? It can be tricky to use external dependencies like that in the docs if it could be subject to change or even become malware. If not, is there some more general advice we can provide instead? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ToriLindsay, Web Assembly (wasm) is the the glue that allows us to run any compiled language (like Rust, Go, or C on Workers (see https://developers.cloudflare.com/workers/runtime-apis/webassembly/), so this PR isn't suggesting to add any external dependencies that aren't already present.

(cc @zebp or @irvinebroque)

Copy link
Contributor

Choose a reason for hiding this comment

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

@lukevalenta Ah ok. I didn't recognize the acronym. Thanks for the clarification! I'll approve.


```toml title="wrangler.toml"
[package.metadata.wasm-pack.profile.dev.wasm-bindgen]
dwarf-debug-info = true
```

Then, update your `wrangler.toml` to configure wasm-pack (via worker-build) to use the `dev` [profile](https://rustwasm.github.io/docs/wasm-pack/commands/build.html#profile) to preserve debug symbols.

```toml title="Cargo.toml"
[build]
command = "cargo install -q worker-build && worker-build --dev"
```

:::

## An Example Profile

Let's look at an example to learn how to read a CPU profile. Imagine you have the following Worker:
Expand Down