Skip to content

fix: make perf-self-profile compile on macOS#174

Merged
rcoh merged 15 commits into
dial9-rs:mainfrom
yulnr:fix/compile-perf-profiling-macos
Apr 10, 2026
Merged

fix: make perf-self-profile compile on macOS#174
rcoh merged 15 commits into
dial9-rs:mainfrom
yulnr:fix/compile-perf-profiling-macos

Conversation

@yulnr
Copy link
Copy Markdown
Collaborator

@yulnr yulnr commented Apr 9, 2026

Closes #14

Summary

Makes dial9-perf-self-profile compile on platforms other than Linux by re-organizing some of the implementation through splitting between platform specific and platform-agnostic code (and gating the linux-specific).

Note: I think that this approach could be a good idea long-term, it prevents lots of individual cfg gates everywhere, this might make it easier to maintain/extend without having to manually add cfgs frequently, and it should make adding support for other platforms later easier. That said it comes at the cost of some bigger diffs now, so I'm happy to switch to a smaller set of changes and more individual gating if that's preferred.

Breakdown

Moves Linux-specific code behind sys/linux/. On non-Linux, PerfSampler constructors return io::ErrorKind::Unsupported and everything else is a no-op.

Shared types (Sample, SymbolInfo, SymbolTableEntry, etc.) stay in their original files. The Linux impl. (PerfSampler, ringbuffer, resolve_symbol, offline symbolization) moves intosys/linux/.

In case it makes it easier to review, it now looks like this:

perf-self-profile/src/
  lib.rs
  sampler.rs                     # shared types: EventSource, SamplerConfig, Sample
  symbolize.rs                   # shared types: MapsEntry, SymbolInfo, CodeInfo
  offline_symbolize.rs           # SymbolTableEntry + cross-platform entry point
  sys.rs                         # cfg dispatch
  sys/
    linux.rs                     # mod declarations, USER_ADDR_LIMIT
    linux/
      sampler.rs                 # PerfSampler, perf_event_open, ring buffer consumer
      ring_buffer.rs            # moved from src/
      symbolize.rs
      offline_symbolize.rs
    unsupported.rs               # stubs returning Unsupported

While at it, fixed a few things that caused warnings on macOS: the blocking_pool_tracking example was missing required-features, some items in events.rs/event_writer.rs needed cpu-profiling feature gating, and a couple test files were pulling in mod common unconditionally but they only use it behind feature gates.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 9, 2026

Deploy Preview for dial9-tokio-telemetry canceled.

Name Link
🔨 Latest commit 7ab78eb
🔍 Latest deploy log https://app.netlify.com/projects/dial9-tokio-telemetry/deploys/69d922ae0581950008afbb92

@yulnr yulnr marked this pull request as draft April 9, 2026 16:07
@yulnr yulnr force-pushed the fix/compile-perf-profiling-macos branch 2 times, most recently from b99ba44 to 6b67704 Compare April 9, 2026 16:16
@yulnr yulnr marked this pull request as ready for review April 9, 2026 16:22
Copy link
Copy Markdown
Contributor

@rcoh rcoh left a comment

Choose a reason for hiding this comment

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

LGTM. Do you mind adding something to the github actions matrix that verifies these changes to make sure we don't regress?

Comment thread dial9-tokio-telemetry/tests/cpu_sample_clock_alignment.rs Outdated
Comment thread perf-self-profile/src/sys/unsupported.rs Outdated
Comment thread perf-self-profile/src/sys.rs Outdated
Comment thread perf-self-profile/src/sampler.rs
yulnr added 6 commits April 10, 2026 18:23
Cfg-gates linux-specific code to allow compilation on non-linux platofrms.
Also fixes missing required-features for blocking_pool_tracking example and silences dead code warnings that fired without the cpu-profiling feature enabled.
@yulnr yulnr force-pushed the fix/compile-perf-profiling-macos branch from 7ab78eb to d4dc2bc Compare April 10, 2026 16:27
@rcoh rcoh added this pull request to the merge queue Apr 10, 2026
Merged via the queue into dial9-rs:main with commit 2a756e7 Apr 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CPU profiling should still compile on macOS

2 participants