-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support measuring process-wide perf events (#357)
* [WIP] support measuring perf events for mutator and GC * Write again from scratch because I git reset --hard HEAD * Check the total number of threads in gc_init * Rephrase the warning * Conditionally import * Get rid of debug prints * Initialize logging before printing log msg * Fix build error * Adjust process-wide and work-packet perf events separately * Conditionally compile Linux specific code * Differentiate different perf event options * Fix Options type * Fix compilation errors * Cargo fmt * Fix unit tests * cargo fmt
- Loading branch information
Showing
10 changed files
with
121 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use super::Diffable; | ||
use pfm::{PerfEvent, PerfEventValue}; | ||
|
||
/// A [`Diffable`] helper type for measuring overall perf events for mutators | ||
/// and GC | ||
/// This is the process-wide counterpart of [`crate::scheduler::work_counter::WorkPerfEvent`]. | ||
pub struct PerfEventDiffable { | ||
pe: PerfEvent, | ||
} | ||
|
||
impl PerfEventDiffable { | ||
pub fn new(name: &str) -> Self { | ||
let mut pe = PerfEvent::new(name, true) | ||
.unwrap_or_else(|_| panic!("Failed to create perf event {}", name)); | ||
// measures the calling thread (and all child threads) on all CPUs | ||
pe.open(0, -1) | ||
.unwrap_or_else(|_| panic!("Failed to open perf event {}", name)); | ||
PerfEventDiffable { pe } | ||
} | ||
} | ||
|
||
impl Diffable for PerfEventDiffable { | ||
type Val = PerfEventValue; | ||
|
||
fn current_value(&mut self) -> Self::Val { | ||
let val = self.pe.read().unwrap(); | ||
self.pe.enable(); | ||
self.pe.reset(); | ||
val | ||
} | ||
|
||
fn diff(current: &Self::Val, _earlier: &Self::Val) -> u64 { | ||
// earlier value is not used as the counter is reset after each use | ||
assert_eq!(current.time_enabled, current.time_running); | ||
current.value as u64 | ||
} | ||
|
||
fn print_diff(val: u64) { | ||
print!("{}", val); | ||
} | ||
} |
This file contains 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