Auto merge of #26788 - servo:energy, r=jdm

Remove support for energy and heartbeats profiling

Both are disabled by default (energy at compile-time, heartbeats with a run-time option). Neither is tested of CI. Neither has been used in a long time. They might have Undefined Behavior: https://github.com/servo/servo/issues/26550#issuecomment-634238098. They each depend on a mostly-unmaintained C library. The thread-safety expectation of those libraries are unknown.
This commit is contained in:
bors-servo 2020-06-04 19:29:46 -04:00 committed by GitHub
commit 98fe360390
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 12 additions and 1369 deletions

View file

@ -109,9 +109,6 @@ pub struct Opts {
/// Periodically print out on which events script threads spend their processing time.
pub profile_script_events: bool,
/// Enable all heartbeats for profiling.
pub profile_heartbeats: bool,
/// `None` to disable debugger or `Some` with a port number to start a server to listen to
/// remote Firefox debugger connections.
pub debugger_port: Option<u16>,
@ -264,9 +261,6 @@ pub struct DebugOptions {
/// Profile which events script threads spend their time on.
pub profile_script_events: bool,
/// Enable all heartbeats for profiling.
pub profile_heartbeats: bool,
/// Paint borders along fragment boundaries.
pub show_fragment_borders: bool,
@ -333,7 +327,6 @@ impl DebugOptions {
"dump-display-list-json" => self.dump_display_list_json = true,
"relayout-event" => self.relayout_event = true,
"profile-script-events" => self.profile_script_events = true,
"profile-heartbeats" => self.profile_heartbeats = true,
"show-fragment-borders" => self.show_fragment_borders = true,
"show-parallel-layout" => self.show_parallel_layout = true,
"trace-layout" => self.trace_layout = true,
@ -397,10 +390,6 @@ fn print_debug_usage(app: &str) -> ! {
"profile-script-events",
"Enable profiling of script-related events.",
);
print_option(
"profile-heartbeats",
"Enable heartbeats for all thread categories.",
);
print_option(
"show-fragment-borders",
"Paint borders along fragment boundaries.",
@ -509,7 +498,6 @@ pub fn default_opts() -> Opts {
dump_display_list_json: false,
relayout_event: false,
profile_script_events: false,
profile_heartbeats: false,
disable_share_style_cache: false,
style_sharing_stats: false,
convert_mouse_to_touch: false,
@ -896,7 +884,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR
hard_fail: opt_match.opt_present("f") && !opt_match.opt_present("F"),
bubble_inline_sizes_separately: bubble_inline_sizes_separately,
profile_script_events: debug_options.profile_script_events,
profile_heartbeats: debug_options.profile_heartbeats,
trace_layout: debug_options.trace_layout,
debugger_port: debugger_port,
devtools_port: devtools_port,

View file

@ -1456,8 +1456,6 @@ impl LayoutThread {
&self.time_profiler_chan,
0,
text_shaping_time as u64,
0,
0,
);
// Retrieve the (possibly rebuilt) root flow.

View file

@ -81,8 +81,6 @@ fn set_metric<U: ProgressiveWebMetric>(
&pwm.get_time_profiler_chan(),
time,
time,
0,
0,
);
// Print the metric to console if the print-pwm option was given.

View file

@ -11,14 +11,11 @@ name = "profile"
path = "lib.rs"
[dependencies]
heartbeats-simple = "0.4"
ipc-channel = "0.14"
log = "0.4"
profile_traits = { path = "../profile_traits" }
serde = "1.0"
serde_json = "1.0"
servo_config = { path = "../config" }
time_crate = { package = "time", version = "0.1.12" }
[target.'cfg(target_os = "macos")'.dependencies]
task_info = { path = "../../support/rust-task_info" }

View file

@ -1,92 +0,0 @@
This crate hosts the Servo profiler.
Its APIs can be found in the `profile_traits` crate.
# Heartbeats
Heartbeats allow fine-grained timing and energy profiling of Servo tasks specified in the `ProfilerCategory` enum (see the `profile_traits::time` module).
When enabled, a heartbeat is issued for each profiler category event.
They also compute the average performance and power for three levels of granularity:
* Global: the entire runtime.
* Window: the category's last `N` events, where `N` is the size of a sliding window.
* Instant: the category's most recent event.
## Enabling
Heartbeats are enabled for categories by setting proper environment variables prior to launching Servo.
For each desired category, set the `SERVO_HEARTBEAT_ENABLE_MyCategory` environment variable to any value (an empty string will do) where `MyCategory` is the `ProfilerCategory` name exactly as it appears in the enum.
For example:
```
SERVO_HEARTBEAT_ENABLE_LayoutPerform=""
```
Then set the `SERVO_HEARTBEAT_LOG_MyCategory` environment variable so Servo knows where to write the results.
For example:
```
SERVO_HEARTBEAT_LOG_LayoutPerform="/tmp/heartbeat-LayoutPerform.log"
```
The target directory must already exist and be writeable.
Results are written to the log file every `N` heartbeats and when the profiler shuts down.
You can optionally specify the size of the sliding window by setting `SERVO_HEARTBEAT_WINDOW_MyCategory` to a positive integer value.
The default value is `20`.
For example:
```
SERVO_HEARTBEAT_WINDOW_LayoutPerform=20
```
The window size is also how many heartbeats will be stored in memory.
## Log Files
Log files are whitespace-delimited.
`HB` is the heartbeat number, ordered by when they are registered (not necessarily start or end time!).
The count starts at `0`.
`Tag` is a client-specified identifier for each heartbeat.
Servo does not use this, so the value is always `0`.
`Work` is the amount of work completed for a particular heartbeat and is used in computing performance.
At this time, Servo simply specifies `1` unit of work for each heartbeat.
`Time` and `Energy` have `Start` and `End` values as captured during runtime.
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.

View file

@ -1,181 +0,0 @@
/* 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 https://mozilla.org/MPL/2.0/. */
use self::synchronized_heartbeat::{heartbeat_window_callback, lock_and_work};
use heartbeats_simple::HeartbeatPow as Heartbeat;
use profile_traits::time::ProfilerCategory;
use std::collections::HashMap;
use std::env::var_os;
use std::fs::File;
use std::path::Path;
/// Initialize heartbeats
pub fn init(profile_heartbeats: bool) {
lock_and_work(|hbs_opt| {
if hbs_opt.is_none() {
let mut hbs: Box<HashMap<ProfilerCategory, Heartbeat>> = Box::new(HashMap::new());
maybe_create_heartbeat(
&mut hbs,
ProfilerCategory::ApplicationHeartbeat,
profile_heartbeats,
);
*hbs_opt = Some(Box::into_raw(hbs))
}
});
}
/// Log regmaining buffer data and cleanup heartbeats
pub fn cleanup() {
let hbs_opt_box: Option<Box<HashMap<ProfilerCategory, Heartbeat>>> = lock_and_work(|hbs_opt| {
hbs_opt
.take()
.map(|hbs_ptr| unsafe { Box::from_raw(hbs_ptr) })
});
if let Some(mut hbs) = hbs_opt_box {
for (_, v) in hbs.iter_mut() {
// log any remaining heartbeat records before dropping
log_heartbeat_records(v);
}
hbs.clear();
}
}
/// Check if a heartbeat exists for the given category
pub fn is_heartbeat_enabled(category: &ProfilerCategory, profile_heartbeats: bool) -> bool {
let is_enabled = lock_and_work(|hbs_opt| {
hbs_opt.map_or(false, |hbs_ptr| unsafe {
(*hbs_ptr).contains_key(category)
})
});
is_enabled || is_create_heartbeat(category, profile_heartbeats)
}
/// Issue a heartbeat (if one exists) for the given category
pub fn maybe_heartbeat(
category: &ProfilerCategory,
start_time: u64,
end_time: u64,
start_energy: u64,
end_energy: u64,
profile_heartbeats: bool,
) {
lock_and_work(|hbs_opt| {
if let Some(hbs_ptr) = *hbs_opt {
unsafe {
if !(*hbs_ptr).contains_key(category) {
maybe_create_heartbeat(&mut (*hbs_ptr), category.clone(), profile_heartbeats);
}
if let Some(h) = (*hbs_ptr).get_mut(category) {
(*h).heartbeat(0, 1, start_time, end_time, start_energy, end_energy);
}
}
}
});
}
// TODO(cimes): Android doesn't really do environment variables. Need a better way to configure dynamically.
fn is_create_heartbeat(category: &ProfilerCategory, profile_heartbeats: bool) -> bool {
profile_heartbeats || var_os(format!("SERVO_HEARTBEAT_ENABLE_{:?}", category)).is_some()
}
fn open_heartbeat_log<P: AsRef<Path>>(name: P) -> Option<File> {
match File::create(name) {
Ok(f) => Some(f),
Err(e) => {
warn!("Failed to open heartbeat log: {}", e);
None
},
}
}
#[cfg(target_os = "android")]
fn get_heartbeat_log(category: &ProfilerCategory) -> Option<File> {
open_heartbeat_log(format!("/sdcard/servo/heartbeat-{:?}.log", category))
}
#[cfg(not(target_os = "android"))]
fn get_heartbeat_log(category: &ProfilerCategory) -> Option<File> {
var_os(format!("SERVO_HEARTBEAT_LOG_{:?}", category)).and_then(|name| open_heartbeat_log(&name))
}
fn get_heartbeat_window_size(category: &ProfilerCategory) -> usize {
const WINDOW_SIZE_DEFAULT: usize = 1;
match var_os(format!("SERVO_HEARTBEAT_WINDOW_{:?}", category)) {
Some(w) => match w.into_string() {
Ok(s) => s.parse::<usize>().unwrap_or(WINDOW_SIZE_DEFAULT),
_ => WINDOW_SIZE_DEFAULT,
},
None => WINDOW_SIZE_DEFAULT,
}
}
/// Possibly create a heartbeat
fn maybe_create_heartbeat(
hbs: &mut HashMap<ProfilerCategory, Heartbeat>,
category: ProfilerCategory,
profile_heartbeats: bool,
) {
if is_create_heartbeat(&category, profile_heartbeats) {
// get optional log file
let logfile: Option<File> = get_heartbeat_log(&category);
// window size
let window_size: usize = get_heartbeat_window_size(&category);
// create the heartbeat
match Heartbeat::new(window_size, Some(heartbeat_window_callback), logfile) {
Ok(hb) => {
debug!("Created heartbeat for {:?}", category);
hbs.insert(category, hb);
},
Err(e) => warn!("Failed to create heartbeat for {:?}: {}", category, e),
}
};
}
/// Log heartbeat records up to the buffer index
fn log_heartbeat_records(hb: &mut Heartbeat) {
match hb.log_to_buffer_index() {
Ok(_) => (),
Err(e) => warn!("Failed to write heartbeat log: {}", e),
}
}
mod synchronized_heartbeat {
use super::log_heartbeat_records;
use heartbeats_simple::HeartbeatPow as Heartbeat;
use heartbeats_simple::HeartbeatPowContext as HeartbeatContext;
use profile_traits::time::ProfilerCategory;
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
static mut HBS: Option<*mut HashMap<ProfilerCategory, Heartbeat>> = None;
// unfortunately can't encompass the actual hashmap in a Mutex (Heartbeat isn't Send/Sync), so we'll use a spinlock
static HBS_SPINLOCK: AtomicBool = AtomicBool::new(false);
pub fn lock_and_work<F, R>(work: F) -> R
where
F: FnOnce(&mut Option<*mut HashMap<ProfilerCategory, Heartbeat>>) -> R,
{
while HBS_SPINLOCK.compare_and_swap(false, true, Ordering::SeqCst) {}
let result = unsafe { work(&mut HBS) };
HBS_SPINLOCK.store(false, Ordering::SeqCst);
result
}
/// Callback function used to log the window buffer.
/// When this is called from native C, the heartbeat is safely locked internally and the global lock is held.
/// If calling from this file, you must already hold the global lock!
pub extern "C" fn heartbeat_window_callback(hb: *const HeartbeatContext) {
unsafe {
if let Some(hbs_ptr) = HBS {
for (_, v) in (*hbs_ptr).iter_mut() {
if &v.hb as *const HeartbeatContext == hb {
log_heartbeat_records(v);
}
}
}
}
}
}

View file

@ -4,15 +4,11 @@
#![deny(unsafe_code)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate profile_traits;
#[macro_use]
extern crate serde;
#[allow(unsafe_code)]
mod heartbeats;
#[allow(unsafe_code)]
pub mod mem;
pub mod time;

View file

@ -4,24 +4,20 @@
//! Timing functions.
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};
use std::path::Path;
use std::time::Duration;
use std::{f64, thread, u32, u64};
use time_crate::precise_time_ns;
pub trait Formattable {
fn format(&self, output: &Option<OutputOptions>) -> String;
@ -153,7 +149,6 @@ impl Formattable for ProfilerCategory {
ProfilerCategory::TimeToInteractive => "Time to Interactive",
ProfilerCategory::IpcReceiver => "Blocked at IPC Receive",
ProfilerCategory::IpcBytesReceiver => "Blocked at IPC Bytes Receive",
ProfilerCategory::ApplicationHeartbeat => "Application Heartbeat",
};
format!("{}{}", padding, name)
}
@ -169,15 +164,10 @@ pub struct Profiler {
pub last_msg: Option<ProfilerMsg>,
trace: Option<TraceDump>,
blocked_layout_queries: HashMap<String, u32>,
profile_heartbeats: bool,
}
impl Profiler {
pub fn create(
output: &Option<OutputOptions>,
file_path: Option<String>,
profile_heartbeats: bool,
) -> ProfilerChan {
pub fn create(output: &Option<OutputOptions>, file_path: Option<String>) -> ProfilerChan {
let (chan, port) = ipc::channel().unwrap();
match *output {
Some(ref option) => {
@ -187,8 +177,7 @@ impl Profiler {
.name("Time profiler".to_owned())
.spawn(move || {
let trace = file_path.as_ref().and_then(|p| TraceDump::new(p).ok());
let mut profiler =
Profiler::new(port, trace, Some(outputoption), profile_heartbeats);
let mut profiler = Profiler::new(port, trace, Some(outputoption));
profiler.start();
})
.expect("Thread spawning failed");
@ -218,7 +207,7 @@ impl Profiler {
.name("Time profiler".to_owned())
.spawn(move || {
let trace = file_path.as_ref().and_then(|p| TraceDump::new(p).ok());
let mut profiler = Profiler::new(port, trace, None, profile_heartbeats);
let mut profiler = Profiler::new(port, trace, None);
profiler.start();
})
.expect("Thread spawning failed");
@ -241,70 +230,13 @@ impl Profiler {
},
}
heartbeats::init(profile_heartbeats);
let profiler_chan = ProfilerChan(chan);
// only spawn the application-level profiler thread if its heartbeat is enabled
let run_ap_thread = move || {
heartbeats::is_heartbeat_enabled(
&ProfilerCategory::ApplicationHeartbeat,
profile_heartbeats,
)
};
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
// 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 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() {
thread::sleep(Duration::from_millis(SLEEP_MS as u64))
} else {
return;
}
}
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)
let ProfilerChan(ref c) = profiler_chan;
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");
}
profiler_chan
ProfilerChan(chan)
}
pub fn new(
port: IpcReceiver<ProfilerMsg>,
trace: Option<TraceDump>,
output: Option<OutputOptions>,
profile_heartbeats: bool,
) -> Profiler {
Profiler {
port: port,
@ -313,7 +245,6 @@ impl Profiler {
last_msg: None,
trace: trace,
blocked_layout_queries: HashMap::new(),
profile_heartbeats,
}
}
@ -331,10 +262,9 @@ 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) => {
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);
@ -358,7 +288,6 @@ impl Profiler {
*self.blocked_layout_queries.entry(url).or_insert(0) += 1;
},
ProfilerMsg::Exit(chan) => {
heartbeats::cleanup();
self.print_buckets();
let _ = chan.send(());
return false;
@ -475,20 +404,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;

View file

@ -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();

View file

@ -10,13 +10,8 @@ publish = false
name = "profile_traits"
path = "lib.rs"
[features]
energy-profiling = ["energy-monitor", "energymon"]
[dependencies]
crossbeam-channel = "0.4"
energy-monitor = { version = "0.2.0", optional = true }
energymon = { git = "https://github.com/energymon/energymon-rust.git", optional = true }
ipc-channel = "0.14"
log = "0.4"
serde = "1.0"

View file

@ -1,62 +0,0 @@
/* 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 https://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 energy_monitor;
extern crate energymon;
use self::energy_monitor::EnergyMonitor;
use self::energymon::EnergyMon;
use std::sync::{Once, ONCE_INIT};
static mut EM: Option<*mut EnergyMon> = None;
fn init() {
// can't use lazy_static macro for EM (no Sync trait for EnergyMon)
static ONCE: Once = ONCE_INIT;
ONCE.call_once(|| {
if let Ok(em) = EnergyMon::new() {
println!("Started energy monitoring from: {}", em.source());
unsafe {
EM = Some(Box::into_raw(Box::new(em)));
}
}
});
}
/// Read energy from the energy monitor, otherwise return 0.
pub fn read_energy_uj() -> u64 {
init();
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 {
init();
unsafe { EM.map_or(0, |em| ((*em).interval_us() as f64 / 1000.0).ceil() as u32) }
}
}

View file

@ -13,8 +13,6 @@ extern crate log;
#[macro_use]
extern crate serde;
#[allow(unsafe_code)]
pub mod energy;
pub mod ipc;
pub mod mem;
pub mod time;

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::energy::read_energy_uj;
use ipc_channel::ipc::IpcSender;
use servo_config::opts;
use time::precise_time_ns;
@ -34,11 +33,7 @@ pub enum ProfilerData {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum ProfilerMsg {
/// Normal message used for reporting time
Time(
(ProfilerCategory, Option<TimerMetadata>),
(u64, u64),
(u64, u64),
),
Time((ProfilerCategory, Option<TimerMetadata>), (u64, u64)),
/// Message used to get time spend entries for a particular ProfilerBuckets (in nanoseconds)
Get(
(ProfilerCategory, Option<TimerMetadata>),
@ -115,7 +110,6 @@ pub enum ProfilerCategory {
TimeToInteractive = 0x82,
IpcReceiver = 0x83,
IpcBytesReceiver = 0x84,
ApplicationHeartbeat = 0x90,
}
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
@ -142,26 +136,16 @@ where
if opts::get().signpost {
signpost::start(category as u32, &[0, 0, 0, (category as usize) >> 4]);
}
let start_energy = read_energy_uj();
let start_time = precise_time_ns();
let val = callback();
let end_time = precise_time_ns();
let end_energy = read_energy_uj();
if opts::get().signpost {
signpost::end(category as u32, &[0, 0, 0, (category as usize) >> 4]);
}
send_profile_data(
category,
meta,
&profiler_chan,
start_time,
end_time,
start_energy,
end_energy,
);
send_profile_data(category, meta, &profiler_chan, start_time, end_time);
val
}
@ -171,12 +155,6 @@ pub fn send_profile_data(
profiler_chan: &ProfilerChan,
start_time: u64,
end_time: u64,
start_energy: u64,
end_energy: u64,
) {
profiler_chan.send(ProfilerMsg::Time(
(category, meta),
(start_time, end_time),
(start_energy, end_energy),
));
profiler_chan.send(ProfilerMsg::Time((category, meta), (start_time, end_time)));
}

View file

@ -14,7 +14,6 @@ crate-type = ["rlib"]
[features]
debugmozjs = ["script/debugmozjs"]
egl = ["mozangle/egl"]
energy-profiling = ["profile_traits/energy-profiling"]
googlevr = ["webxr/googlevr"]
jitspew = ["script/jitspew"]
js_backtrace = ["script/js_backtrace"]

View file

@ -386,7 +386,6 @@ where
let time_profiler_chan = profile_time::Profiler::create(
&opts.time_profiling,
opts.time_profiler_trace_path.clone(),
opts.profile_heartbeats,
);
let mem_profiler_chan = profile_mem::Profiler::create(opts.mem_profiler_period);