mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Remove support for energy profiling
This commit is contained in:
parent
d4f1f4641d
commit
0abe90647f
15 changed files with 8 additions and 215 deletions
|
@ -62,31 +62,3 @@ Time is measured in nanoseconds and energy is measured in microjoules.
|
|||
`Work`, `Time`, and `Energy` also have `Global` and `Window` values which are the summed over the entire runtime and sliding window period, respectively.
|
||||
|
||||
`Perf` (performance) and `Pwr` (power) have `Global`, `Window`, and `Instant` values as described above.
|
||||
|
||||
|
||||
# Energy Profiling
|
||||
|
||||
Energy monitoring is hardware and platform-specific, so it is only enabled with the `energy-profiling` feature.
|
||||
|
||||
To use energy profiling, you must have a compatible `energymon-default` implementation installed to your system as `energymon-default-static` when building Servo.
|
||||
Otherwise a default dummy implementation is used.
|
||||
The library is linked through a chain of dependencies:
|
||||
|
||||
* servo::profile_traits
|
||||
* energymon - Rust abstractions
|
||||
* energymon-default-sys - Rust bindings to `energymon-default.h`
|
||||
* energymon-default-static: A statically linked C library installed to the system that implements `energymon.h` and `energymon-default.h`
|
||||
|
||||
For instructions on building existing native libraries, visit the [energymon project source](https://github.com/energymon/energymon).
|
||||
You may also write your own implementation of `energymon.h` and `energymon-default.h` and install it as `energymon-default-static` where pkg-config can find it.
|
||||
|
||||
Once you install the proper library, you will need to rebuild the `energymon-default-sys` crate.
|
||||
The most straightforward way to do this is to do a clean build of Servo.
|
||||
|
||||
To build Servo with the `energy-profiling` feature enabled, pass `--features "energy-profiling"` to the `mach` command, e.g.:
|
||||
|
||||
```sh
|
||||
./mach build -r --features "energy-profiling"
|
||||
```
|
||||
|
||||
When running Servo, you will want to enable the desired Heartbeats to record the results.
|
||||
|
|
|
@ -7,14 +7,12 @@
|
|||
use crate::heartbeats;
|
||||
use crate::trace_dump::TraceDump;
|
||||
use ipc_channel::ipc::{self, IpcReceiver};
|
||||
use profile_traits::energy::{energy_interval_ms, read_energy_uj};
|
||||
use profile_traits::time::{
|
||||
ProfilerCategory, ProfilerChan, ProfilerData, ProfilerMsg, TimerMetadata,
|
||||
};
|
||||
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||
use servo_config::opts::OutputOptions;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::fs::File;
|
||||
use std::io::{self, Write};
|
||||
|
@ -253,22 +251,15 @@ impl Profiler {
|
|||
};
|
||||
if run_ap_thread() {
|
||||
let profiler_chan = profiler_chan.clone();
|
||||
// min of 1 heartbeat/sec, max of 20 should provide accurate enough power/energy readings
|
||||
// min of 1 heartbeat/sec, max of 20 should provide accurate enough readings
|
||||
// waking up more frequently allows the thread to end faster on exit
|
||||
const SLEEP_MS: u32 = 10;
|
||||
const MIN_ENERGY_INTERVAL_MS: u32 = 50;
|
||||
const MAX_ENERGY_INTERVAL_MS: u32 = 1000;
|
||||
let interval_ms = enforce_range(
|
||||
MIN_ENERGY_INTERVAL_MS,
|
||||
MAX_ENERGY_INTERVAL_MS,
|
||||
energy_interval_ms(),
|
||||
);
|
||||
let interval_ms = 200;
|
||||
let loop_count: u32 = (interval_ms as f32 / SLEEP_MS as f32).ceil() as u32;
|
||||
thread::Builder::new()
|
||||
.name("Application heartbeat profiler".to_owned())
|
||||
.spawn(move || {
|
||||
let mut start_time = precise_time_ns();
|
||||
let mut start_energy = read_energy_uj();
|
||||
loop {
|
||||
for _ in 0..loop_count {
|
||||
if run_ap_thread() {
|
||||
|
@ -278,7 +269,6 @@ impl Profiler {
|
|||
}
|
||||
}
|
||||
let end_time = precise_time_ns();
|
||||
let end_energy = read_energy_uj();
|
||||
// send using the inner channel
|
||||
// (using ProfilerChan.send() forces an unwrap
|
||||
// and sometimes panics for this background profiler)
|
||||
|
@ -286,12 +276,10 @@ impl Profiler {
|
|||
if let Err(_) = c.send(ProfilerMsg::Time(
|
||||
(ProfilerCategory::ApplicationHeartbeat, None),
|
||||
(start_time, end_time),
|
||||
(start_energy, end_energy),
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
start_time = end_time;
|
||||
start_energy = end_energy;
|
||||
}
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
|
@ -331,10 +319,10 @@ impl Profiler {
|
|||
|
||||
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
||||
match msg.clone() {
|
||||
ProfilerMsg::Time(k, t, e) => {
|
||||
heartbeats::maybe_heartbeat(&k.0, t.0, t.1, e.0, e.1, self.profile_heartbeats);
|
||||
ProfilerMsg::Time(k, t) => {
|
||||
heartbeats::maybe_heartbeat(&k.0, t.0, t.1, 0, 0, self.profile_heartbeats);
|
||||
if let Some(ref mut trace) = self.trace {
|
||||
trace.write_one(&k, t, e);
|
||||
trace.write_one(&k, t);
|
||||
}
|
||||
let ms = (t.1 - t.0) as f64 / 1000000f64;
|
||||
self.find_or_insert(k, ms);
|
||||
|
@ -475,20 +463,6 @@ impl Profiler {
|
|||
}
|
||||
}
|
||||
|
||||
fn enforce_range<T>(min: T, max: T, value: T) -> T
|
||||
where
|
||||
T: Ord,
|
||||
{
|
||||
assert!(min <= max);
|
||||
match value.cmp(&max) {
|
||||
Ordering::Equal | Ordering::Greater => max,
|
||||
Ordering::Less => match value.cmp(&min) {
|
||||
Ordering::Equal | Ordering::Less => min,
|
||||
Ordering::Greater => value,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn duration_from_seconds(secs: f64) -> Duration {
|
||||
pub const NANOS_PER_SEC: u32 = 1_000_000_000;
|
||||
|
||||
|
|
|
@ -25,12 +25,6 @@ struct TraceEntry {
|
|||
|
||||
#[serde(rename = "endTime")]
|
||||
end_time: u64,
|
||||
|
||||
#[serde(rename = "startEnergy")]
|
||||
start_energy: u64,
|
||||
|
||||
#[serde(rename = "endEnergy")]
|
||||
end_energy: u64,
|
||||
}
|
||||
|
||||
impl TraceDump {
|
||||
|
@ -50,15 +44,12 @@ impl TraceDump {
|
|||
&mut self,
|
||||
category: &(ProfilerCategory, Option<TimerMetadata>),
|
||||
time: (u64, u64),
|
||||
energy: (u64, u64),
|
||||
) {
|
||||
let entry = TraceEntry {
|
||||
category: category.0,
|
||||
metadata: category.1.clone(),
|
||||
start_time: time.0,
|
||||
end_time: time.1,
|
||||
start_energy: energy.0,
|
||||
end_energy: energy.1,
|
||||
};
|
||||
serde_json::to_writer(&mut self.file, &entry).unwrap();
|
||||
writeln!(&mut self.file, ",").unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue