Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decouple script from compositor, route through layout #517

Merged
merged 5 commits into from Jun 17, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

profiler refactor to print every period if new data has arrived

  • Loading branch information
Tim Kuehn
Tim Kuehn committed Jun 15, 2013
commit 496069dad4beb0b8e395f36ee78c177af5429d6b
@@ -19,7 +19,7 @@ use script::script_task;
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use servo_net::resource_task::ResourceTask;
use servo_net::resource_task;
use servo_util::time::{ProfilerChan, ForcePrintMsg};
use servo_util::time::{ProfilerChan};

pub struct Engine {
request_port: Port<Msg>,
@@ -34,7 +34,7 @@ pub struct Engine {

impl Drop for Engine {
fn finalize(&self) {
self.profiler_chan.send(ForcePrintMsg);
//self.profiler_chan.send(ForcePrintMsg);
}
}

@@ -40,7 +40,8 @@ use script::engine_interface::{ExitMsg, LoadUrlMsg};
use gfx::opts;
use servo_net::image_cache_task::ImageCacheTask;
use servo_net::resource_task::ResourceTask;
use servo_util::time::{Profiler, ProfilerChan};
use servo_util::time::{Profiler, ProfilerChan, PrintMsg};
use std::uv_global_loop;

pub use gfx::opts::Opts;
pub use gfx::text;
@@ -92,7 +93,18 @@ fn run(opts: &Opts) {
// Create the profiler channel.
let (profiler_port, profiler_chan) = comm::stream();
let profiler_chan = ProfilerChan::new(profiler_chan);
Profiler::create_profiler(profiler_port, opts.profiler_period);
Profiler::create_profiler(profiler_port);
do opts.profiler_period.map |period| {
let profiler_chan = profiler_chan.clone();
let period = *period;
do spawn {
loop {
std::timer::sleep(&uv_global_loop::get(),
(period * 1000f64) as uint);
profiler_chan.send(PrintMsg);
}
}
};

// Create the compositor.
let (compositor_port, compositor_chan) = comm::stream();
@@ -50,16 +50,14 @@ pub enum ProfilerMsg {
// Normal message used for reporting time
TimeMsg(ProfilerCategory, f64),
// Message used to force print the profiling metrics
ForcePrintMsg,
PrintMsg,
}

// back end of the profiler that handles data aggregation and performance metrics
pub struct Profiler {
port: Port<ProfilerMsg>,
buckets: ~[(ProfilerCategory, ~[f64])],
verbose: bool,
period: f64,
last_print: f64,
last_msg: Option<ProfilerMsg>,
}

impl ProfilerCategory {
@@ -112,25 +110,19 @@ impl ProfilerCategory {
}

impl Profiler {
pub fn create_profiler(port: Port<ProfilerMsg>, period: Option<f64>) {
pub fn create_profiler(port: Port<ProfilerMsg>) {
let port = Cell(port);
do spawn {
let mut profiler = Profiler::new(port.take(), period);
let mut profiler = Profiler::new(port.take());
profiler.start();
}
}

pub fn new(port: Port<ProfilerMsg>, period: Option<f64>) -> Profiler {
let (verbose, period) = match period {
Some(period) => (true, period),
None => (false, 0f64)
};
pub fn new(port: Port<ProfilerMsg>) -> Profiler {
Profiler {
port: port,
buckets: ProfilerCategory::empty_buckets(),
verbose: verbose,
period: period,
last_print: 0f64,
last_msg: None,
}
}

@@ -143,25 +135,19 @@ impl Profiler {

priv fn handle_msg(&mut self, msg: ProfilerMsg) {
match msg {
TimeMsg(category, t) => {
TimeMsg(category, t) => match self.buckets[category as uint] {
// FIXME(#3874): this should be a let (cat, ref mut bucket) = ...,
// not a match
match self.buckets[category as uint] {
(_, ref mut data) => {
data.push(t);
}
}

if self.verbose {
let cur_time = precise_time_ns() as f64 / 1000000000f64;
if cur_time - self.last_print > self.period {
self.last_print = cur_time;
self.print_buckets();
}
(_, ref mut data) => {
data.push(t);
}
}
ForcePrintMsg => self.print_buckets(),
},
PrintMsg => match self.last_msg {
Some(TimeMsg(*)) => self.print_buckets(),
_ => {}
},
};
self.last_msg = Some(msg);
}

priv fn print_buckets(&mut self) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.