Skip to content

docs(book): rewrite the profiling chapter around perf and --cpu-prof - #1640

Merged
Wodann merged 5 commits into
NomicFoundation:mainfrom
Wodann:docs/profiling-guide
Aug 25, 2026
Merged

docs(book): rewrite the profiling chapter around perf and --cpu-prof#1640
Wodann merged 5 commits into
NomicFoundation:mainfrom
Wodann:docs/profiling-guide

Conversation

@Wodann

@Wodann Wodann commented Aug 21, 2026

Copy link
Copy Markdown
Member

This change in documentation pairs with NomicFoundation/hardhat#8546

The chapter now documents three lenses with an up-front comparison of what each can and cannot see:

  • Rust-only: cargo flamegraph over a recorded scenario (fixed the stale crates/tools path — scenarios live in js/benchmark/scenarios/ and the replay bin is edr_tool_cli).
  • Cross-language sampling: Linux perf over the whole process tree, with the build:perf-js artifact injected via NAPI_RS_NATIVE_LIBRARY_PATH (or Verdaccio) and V8 perf maps for JS frame names. Rendering via inferno or speedscope.
  • JS-level attribution: node --cpu-prof, including interval trade-offs, NODE_OPTIONS propagation, the graceful-exit flush caveat, and bun's equivalent flags.

The 0x section is removed: --kernel-tracing wraps the same perf data source (the old text claiming it runs the V8 tick profiler and perf simultaneously was incorrect) with less control and no reusable output.

A permissions appendix covers perf_event_paranoid and containers, preferring a seccomp profile that allows unprivileged perf_event_open (no added capabilities; own-process sampling only) over capabilities, with CAP_PERFMON as the fallback — SYS_ADMIN is obsolete for this, so the devcontainer suggestion now names PERFMON.

build:perf-js now sets CARGO_PROFILE_NAPI_PUBLISH_DEBUG=line-tables-only itself: a profiling build should always carry symbol names (the .node artifact grows to ~160 MB, acceptable for this purpose-built profile).

The chapter now documents three lenses with an up-front comparison of
what each can and cannot see:

- Rust-only: cargo flamegraph over a recorded scenario (fixed the stale
  crates/tools path — scenarios live in js/benchmark/scenarios/ and the
  replay bin is edr_tool_cli).
- Cross-language sampling: Linux perf over the whole process tree, with
  the build:perf-js artifact injected via NAPI_RS_NATIVE_LIBRARY_PATH
  (or Verdaccio) and V8 perf maps for JS frame names. Rendering via
  inferno or speedscope.
- JS-level attribution: node --cpu-prof, including interval trade-offs,
  NODE_OPTIONS propagation, the graceful-exit flush caveat, and bun's
  equivalent flags.

The 0x section is removed: --kernel-tracing wraps the same perf data
source (the old text claiming it runs the V8 tick profiler and perf
simultaneously was incorrect) with less control and no reusable output.

A permissions appendix covers perf_event_paranoid and containers,
preferring a seccomp profile that allows unprivileged perf_event_open
(no added capabilities; own-process sampling only) over capabilities,
with CAP_PERFMON as the fallback — SYS_ADMIN is obsolete for this, so
the devcontainer suggestion now names PERFMON.

build:perf-js now sets CARGO_PROFILE_NAPI_PUBLISH_DEBUG=line-tables-only
itself: a profiling build should always carry symbol names (the .node
artifact grows to ~160 MB, acceptable for this purpose-built profile).
@Wodann
Wodann requested review from a team and a balanced review from Copilot August 21, 2026 11:10
@Wodann Wodann self-assigned this Aug 21, 2026
@Wodann Wodann added the no changeset needed This PR doesn't require a changeset label Aug 21, 2026
@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1aac99a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Rewrites profiling guidance around Rust, cross-language, and JavaScript profiling methods.

Changes:

  • Adds perf and --cpu-prof workflows.
  • Enables debug symbols in performance builds.
  • Updates devcontainer profiling capability guidance.

Reviewed changes

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

File Description
crates/edr_napi/package.json Adds symbols to profiling builds.
book/src/01_getting_started/06_profiling.md Reworks profiling documentation.
.devcontainer/devcontainer.json Replaces SYS_ADMIN guidance with PERFMON.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread book/src/01_getting_started/06_profiling.md
Comment thread book/src/01_getting_started/06_profiling.md Outdated
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.06%. Comparing base (855d3db) to head (1aac99a).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1640       +/-   ##
===========================================
- Coverage   80.01%   47.06%   -32.96%     
===========================================
  Files         464      439       -25     
  Lines       80392    69186    -11206     
  Branches    80392    69186    -11206     
===========================================
- Hits        64329    32565    -31764     
- Misses      13856    35324    +21468     
+ Partials     2207     1297      -910     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@popescuoctavian popescuoctavian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for updating the docs! Just one nit (as a mac user 😄 )

Comment thread book/src/01_getting_started/06_profiling.md
@Wodann

Wodann commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

Tests are failing as this is a PR originating from my fork, which is lacking an ALCHEMY_URL. I tried setting one, but to no avail.

@Wodann
Wodann enabled auto-merge August 25, 2026 07:09
@Wodann
Wodann added this pull request to the merge queue Aug 25, 2026
Merged via the queue into NomicFoundation:main with commit 617568b Aug 25, 2026
37 of 41 checks passed
@Wodann
Wodann deleted the docs/profiling-guide branch August 25, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changeset needed This PR doesn't require a changeset

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants