Skip to content

feat: add tracy profiler support#12048

Merged
hardfist merged 7 commits intomainfrom
yj/add-tracy-support
Nov 11, 2025
Merged

feat: add tracy profiler support#12048
hardfist merged 7 commits intomainfrom
yj/add-tracy-support

Conversation

@hardfist
Copy link
Copy Markdown
Contributor

@hardfist hardfist commented Oct 30, 2025

Summary

add tracy profiler support for better memory profiling

cd crates/node_binding && TRACY=1 pnpm build:dev # build binding with tracy profiler support

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link
Copy Markdown

netlify bot commented Oct 30, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit f6c46fe
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6912f1daee65090008cf061d

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Oct 30, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 30, 2025

📦 Binary Size-limit

Comparing f6c46fe to fix: mf container entry use startup to load initial chunks (#12142) by Gengkun

🙈 Size remains the same at 48.09MB

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 30, 2025

CodSpeed Performance Report

Merging #12048 will not alter performance

Comparing yj/add-tracy-support (f6c46fe) with main (f70f870)

Summary

✅ 17 untouched

@hardfist hardfist force-pushed the yj/add-tracy-support branch from 4836b9e to 4ff5db8 Compare November 10, 2025 14:59
@hardfist hardfist marked this pull request as ready for review November 11, 2025 08:47
@hardfist hardfist requested a review from quininer as a code owner November 11, 2025 08:47
Copilot AI review requested due to automatic review settings November 11, 2025 08:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds Tracy profiler integration to rspack for enhanced memory profiling capabilities. The implementation enables Tracy profiling by setting the TRACY environment variable during build time, which activates the tracy-client feature and uses Tracy's ProfiledAllocator for allocation tracking.

Key changes:

  • Added tracy-client (v0.18.2) as a workspace dependency with required features
  • Implemented conditional feature flags and allocator switching logic between mimalloc, sftrace, and Tracy
  • Updated build script to support Tracy-specific compilation and debug symbol extraction

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
deny.toml Added windows-core to skip list for external dependencies
crates/rspack_binding_api/src/lib.rs Added Tracy client initialization with demangler registration
crates/rspack_binding_api/Cargo.toml Added tracy-client feature flag and dependency with alphabetized formatting
crates/rspack_allocator/src/lib.rs Added conditional global allocator for Tracy's ProfiledAllocator with System allocator
crates/rspack_allocator/Cargo.toml Added tracy-client and tracy-client-sys dependencies with cargo-shear metadata
crates/node_binding/scripts/build.js Added TRACY environment variable support and dsymutil call for debug symbol extraction
crates/node_binding/Cargo.toml Added tracy-client feature flag
crates/node_binding/.gitignore Added *.dSYM to ignore debug symbol directories
Cargo.toml Added tracy-client workspace dependency and split-debuginfo profile setting
Cargo.lock Added tracy-client ecosystem dependencies (loom, generator, nu-ansi-term, etc.)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sftrace-setup = { workspace = true, optional = true }
sftrace-setup = { workspace = true, optional = true }
tracy-client = { workspace = true, optional = true }
tracy-client-sys = { version = "=0.26.0" }
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The tracy-client-sys dependency should be marked as optional to avoid unnecessarily building it when the tracy-client feature is not enabled. This dependency is only needed when the tracy-client feature is active.

Suggestion:

tracy-client-sys = { version = "=0.26.0", optional = true }
Suggested change
tracy-client-sys = { version = "=0.26.0" }
tracy-client-sys = { version = "=0.26.0", optional = true }

Copilot uses AI. Check for mistakes.
Comment on lines +145 to +153
if(process.env.TRACY){
// split debug symbols for tracy
spawnSync('dsymutil', [
path.resolve(__dirname, "..", "rspack.darwin-arm64.node")
], {
stdio: "inherit",
shell: true,
})
}
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The dsymutil command and hardcoded path rspack.darwin-arm64.node are macOS-specific. This code will fail on other platforms (Linux, Windows) when TRACY is set. Consider adding a platform check or making the artifact path dynamic based on the build target.

Suggestion:

if(process.env.TRACY && process.platform === 'darwin'){
  // split debug symbols for tracy
  const target = process.env.RUST_TARGET || 'darwin-arm64';
  const artifactPath = path.resolve(__dirname, "..", `rspack.${target}.node`);
  spawnSync('dsymutil', [artifactPath], {
    stdio: "inherit",
    shell: true,
  })
}

Copilot uses AI. Check for mistakes.
renameSync("rspack.wasm32-wasi.wasm", "rspack.browser.wasm")
}

if(process.env.TRACY){
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Missing space after if keyword. JavaScript style conventions typically require a space between if and the opening parenthesis.

Suggestion:

if (process.env.TRACY) {
Suggested change
if(process.env.TRACY){
if (process.env.TRACY){

Copilot uses AI. Check for mistakes.
@hardfist hardfist merged commit 46fd27e into main Nov 11, 2025
97 of 102 checks passed
@hardfist hardfist deleted the yj/add-tracy-support branch November 11, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants