From c69139e99d1c3fdb9e9627ba51da7f71bb89e684 Mon Sep 17 00:00:00 2001 From: Luke Valenta Date: Wed, 2 Apr 2025 16:56:49 -0400 Subject: [PATCH 1/2] Add note about how to preserve debug symbols in Rust --- .../observability/dev-tools/cpu-usage.mdx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx b/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx index b6aa18ff83acb0..6623e6bcb0affe 100644 --- a/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx +++ b/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx @@ -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)): + +```toml title="wrangler.toml" +[package.metadata.wasm-pack.profile.dev.wasm-bindgen] +dwarf-debug-info = true +``` + +And update `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: From ab9dc8f0858ff107877a1617ad080c969d677358 Mon Sep 17 00:00:00 2001 From: Luke Valenta Date: Mon, 14 Apr 2025 11:26:58 -0400 Subject: [PATCH 2/2] Update src/content/docs/workers/observability/dev-tools/cpu-usage.mdx Co-authored-by: ToriLindsay --- src/content/docs/workers/observability/dev-tools/cpu-usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx b/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx index 6623e6bcb0affe..3c9bf5749df8dd 100644 --- a/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx +++ b/src/content/docs/workers/observability/dev-tools/cpu-usage.mdx @@ -41,7 +41,7 @@ For Rust Workers, add the following to your `Cargo.toml` to preserve [DWARF](htt dwarf-debug-info = true ``` -And update `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: +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]