Filter Rust stdlib/dependency paths from profiling by default#272
Closed
emeryberger wants to merge 1 commit intomasterfrom
Closed
Filter Rust stdlib/dependency paths from profiling by default#272emeryberger wants to merge 1 commit intomasterfrom
emeryberger wants to merge 1 commit intomasterfrom
Conversation
camelid
reviewed
Mar 3, 2026
libcoz/path_filter.h
Outdated
Comment on lines
+47
to
+52
| if(path_contains(normalized, "/.rustup/")) | ||
| return true; | ||
| if(path_contains(normalized, "/.cargo/registry/")) | ||
| return true; | ||
| if(path_contains(normalized, "/.cargo/git/")) | ||
| return true; |
Member
There was a problem hiding this comment.
Probably would be good to check that it's $HOME/.rustup not any old .rustup.
b553f51 to
015dd43
Compare
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>
015dd43 to
9af475f
Compare
4 tasks
4 tasks
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 outputTest 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