Skip to content

Commit 46fd27e

Browse files
feat: add tracy profiler support (#12048)
* feat: add tracy profiler support * chore: add start * chore: auto split dsym file * chore: fix cargo deny * fix: ci modified check * chore: fix cargo deny * chore: fix cargo shear --------- Co-authored-by: pshu <[email protected]>
1 parent 611e68c commit 46fd27e

File tree

10 files changed

+251
-24
lines changed

10 files changed

+251
-24
lines changed

Cargo.lock

Lines changed: 187 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,15 @@ swc_html_minifier = { version = "35.0.0", default-features = false }
146146
swc_node_comments = { version = "16.0.0", default-features = false }
147147
swc_plugin_runner = { version = "21.0.0", default-features = false }
148148

149-
wasi-common = { version = "35.0.0", default-features = false }
150-
wasmtime = { version = "35.0.0", default-features = false }
151-
152149
rspack_dojang = { version = "0.1.11", default-features = false }
150+
tracy-client = { version = "=0.18.2", default-features = false, features = [
151+
"enable",
152+
"sampling",
153+
"demangle",
154+
"system-tracing",
155+
] }
156+
wasi-common = { version = "35.0.0", default-features = false }
157+
wasmtime = { version = "35.0.0", default-features = false }
153158

154159

155160
# all rspack workspace dependencies
@@ -251,10 +256,11 @@ opt-level = 0
251256

252257
# This is for local development
253258
[profile.dev]
254-
codegen-units = 16
255-
debug = 2 # debug build will cause runtime panic if codegen-unints is default
256-
incremental = true
257-
panic = "abort"
259+
codegen-units = 16
260+
debug = 2 # debug build will cause runtime panic if codegen-unints is default
261+
incremental = true
262+
panic = "abort"
263+
split-debuginfo = "unpacked"
258264

259265
[profile.release-debug]
260266
codegen-units = 16

crates/node_binding/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/*.node
2-
/*.wasm
2+
/*.wasm
3+
/*.dSYM

crates/node_binding/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ version.workspace = true
1111
crate-type = ["cdylib"]
1212

1313
[features]
14+
allocative = ["rspack_binding_api/allocative"]
1415
browser = ["rspack_binding_api/browser"]
1516
color-backtrace = ["rspack_binding_api/color-backtrace"]
1617
debug_tool = ["rspack_binding_api/debug_tool"]
1718
info-level = ["tracing/release_max_level_info"]
1819
plugin = ["rspack_binding_api/plugin"]
1920
sftrace-setup = ["rspack_binding_api/sftrace-setup"]
20-
allocative = ["rspack_binding_api/allocative"]
21+
tracy-client = ["rspack_binding_api/tracy-client"]
2122

2223
[package.metadata.cargo-shear]
2324
# Adding napi-derive as a dependency to workaround an issue where `dts` will no longer work without it.

crates/node_binding/scripts/build.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { values, positionals } = require("util").parseArgs({
1111
allowPositionals: true
1212
});
1313

14-
const { spawn } = require("child_process");
14+
const { spawn, spawnSync } = require("child_process");
1515

1616
const NAPI_BINDING_DTS = "napi-binding.d.ts"
1717
const CARGO_SAFELY_EXIT_CODE = 0;
@@ -82,6 +82,9 @@ async function build() {
8282
features.push("allocative");
8383
rustflags.push("--cfg=allocative");
8484
}
85+
if (process.env.TRACY) {
86+
features.push("tracy-client");
87+
}
8588
if (values.profile === "release") {
8689
features.push("info-level");
8790
}
@@ -138,6 +141,16 @@ async function build() {
138141
renameSync("rspack.wasm32-wasi.debug.wasm", "rspack.browser.debug.wasm")
139142
renameSync("rspack.wasm32-wasi.wasm", "rspack.browser.wasm")
140143
}
144+
145+
if(process.env.TRACY){
146+
// split debug symbols for tracy
147+
spawnSync('dsymutil', [
148+
path.resolve(__dirname, "..", "rspack.darwin-arm64.node")
149+
], {
150+
stdio: "inherit",
151+
shell: true,
152+
})
153+
}
141154
}
142155
resolve(code);
143156
});

crates/rspack_allocator/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ name = "rspack_allocator"
66
repository = "https://github.com/web-infra-dev/rspack"
77
version.workspace = true
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
[dependencies]
910

1011
[target.'cfg(not(target_family = "wasm"))'.dependencies]
11-
sftrace-setup = { workspace = true, optional = true }
12+
sftrace-setup = { workspace = true, optional = true }
13+
tracy-client = { workspace = true, optional = true }
14+
tracy-client-sys = { version = "=0.26.0" }
1215

1316
[target.'cfg(target_os = "linux")'.dependencies]
1417
# Turned on `local_dynamic_tls` to avoid issue: https://github.com/microsoft/mimalloc/issues/147
@@ -19,3 +22,6 @@ mimalloc = { workspace = true, features = ["v3"] }
1922

2023
[target.'cfg(all(not(target_os = "linux"), not(target_os = "macos"), not(target_family = "wasm")))'.dependencies]
2124
mimalloc = { workspace = true }
25+
26+
[package.metadata.cargo-shear]
27+
ignored = ["tracy-client-sys"]

0 commit comments

Comments
 (0)