Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #7581 - connorimes:power-profiling, r=larsbergstrom
Add energy monitoring and characterization scripts Add the energy-profiling feature. Users can compile the proper (or their own) version of energymon libraries to capture power/energy data at runtime. The results are accessed through heartbeats. Additionally, there are a couple of python scripts to enable heartbeats for profiler categories and process the results into some visualizations to help understand how time and energy is being spent in Servo. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7581) <!-- Reviewable:end -->
- Loading branch information
Showing
11 changed files
with
834 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
|
||
#[cfg(feature = "energy-profiling")] | ||
pub fn read_energy_uj() -> u64 { | ||
energymon::read_energy_uj() | ||
} | ||
|
||
#[cfg(not(feature = "energy-profiling"))] | ||
pub fn read_energy_uj() -> u64 { | ||
0 | ||
} | ||
|
||
#[cfg(feature = "energy-profiling")] | ||
pub fn energy_interval_ms() -> u32 { | ||
energymon::get_min_interval_ms() | ||
} | ||
|
||
#[cfg(not(feature = "energy-profiling"))] | ||
pub fn energy_interval_ms() -> u32 { | ||
1000 | ||
} | ||
|
||
#[cfg(feature = "energy-profiling")] | ||
mod energymon { | ||
extern crate energymon; | ||
extern crate energy_monitor; | ||
|
||
use self::energy_monitor::EnergyMonitor; | ||
use self::energymon::EnergyMon; | ||
use std::mem; | ||
use std::sync::{Once, ONCE_INIT}; | ||
|
||
|
||
static mut EM: Option<*mut EnergyMon> = None; | ||
|
||
/// Read energy from the energy monitor, otherwise return 0. | ||
pub fn read_energy_uj() -> u64 { | ||
static ONCE: Once = ONCE_INIT; | ||
ONCE.call_once(|| { | ||
if let Ok(em) = EnergyMon::new() { | ||
println!("Started energy monitoring from: {}", em.source()); | ||
unsafe { | ||
EM = Some(mem::transmute(Box::new(em))); | ||
} | ||
} | ||
}); | ||
|
||
unsafe { | ||
// EnergyMon implementations of EnergyMonitor always return a value | ||
EM.map_or(0, |em| (*em).read_uj().unwrap()) | ||
} | ||
} | ||
|
||
pub fn get_min_interval_ms() -> u32 { | ||
unsafe { | ||
EM.map_or(0, |em| ((*em).interval_us() as f64 / 1000.0).ceil() as u32) | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
extern crate ipc_channel; | ||
extern crate serde; | ||
|
||
pub mod energy; | ||
pub mod mem; | ||
pub mod time; | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.