Filter Rust stdlib/dependency paths from profiling by default#275
Merged
emeryberger merged 4 commits intomasterfrom Mar 3, 2026
Merged
Filter Rust stdlib/dependency paths from profiling by default#275emeryberger merged 4 commits intomasterfrom
emeryberger merged 4 commits intomasterfrom
Conversation
When profiling Rust programs, coz was attributing results to lines in
the Rust standard library and third-party dependencies because their
source paths (e.g. /rustc/<hash>/..., ~/.rustup/..., ~/.cargo/...)
were not recognized as system paths.
Changes:
- Extract path filtering functions into libcoz/path_filter.h for
reuse and testability
- Add is_rust_path() to identify Rust toolchain and dependency paths:
/rustc/... (always filtered), $HOME/.rustup/... and
$HOME/.cargo/{registry,git}/... (filtered using actual $HOME)
- Rust paths are filtered by default but an explicit --source-scope
overrides the filter
- Remove #[cfg(target_os = "linux")] gate from the Rust crate's
coz_get_counter — dlsym is POSIX-standard, so progress macros now
work on macOS too
- Add unit tests (65 assertions) and a Rust integration test that
verifies DWARF debug info contains /rustc/ paths and confirms
they are excluded from profiling output
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9af475f to
2302161
Compare
…tform gates - Remove duplicate static is_coz_header() from inspect.cpp (already in path_filter.h) - Remove #[cfg(target_os = "linux")] gates re-added during merge to rust/src/lib.rs - Remove #[cfg(not(target_os = "linux"))] no-op stubs re-added during merge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When profiling Rust programs, coz was attributing results to lines in the Rust standard library and third-party dependencies. Their source paths (
/rustc/<hash>/...,~/.rustup/...,~/.cargo/registry/...) were not recognized as system paths, so they passed through source filtering and appeared in profiling output.libcoz/path_filter.hfor reuse and testabilityis_rust_path()to identify Rust toolchain/dependency paths:/rustc/...— always filtered (synthetic paths embedded by rustc)$HOME/.rustup/...— filtered only when under the user's actual$HOME$HOME/.cargo/registry/...and$HOME/.cargo/git/...— same%source scope), but an explicit--source-scopeoverrides the filter#[cfg(target_os = "linux")]gate from the Rust crate'scoz_get_counterfunction —dlsymis POSIX-standard, socoz::progress!()and other macros now work on macOS too$HOMEscoping, scope override behavior/rustc/paths, and validates they are excluded from profiling outputSupersedes #272 and #274.
Test plan
tests/path_filter/path_filter_test.cpp)tests/run_rust_filter_test.sh)/rustc/paths in DWARF debug info--source-scope '/rustc/%'overrides the filter when explicitly requested🤖 Generated with Claude Code