mirror of
https://github.com/servo/servo.git
synced 2025-06-15 11:54:28 +00:00
Rename lots of profiling-related things.
------------------------------------------------------------------------ BEFORE AFTER ------------------------------------------------------------------------ util::memory util::mem - heap_size_of - heap_size_of (unchanged) - SizeOf - HeapSizeOf - size_of_excluding_self - heap_size_of_children prof::mem prof::mem - MemoryProfilerChan - ProfilerChan - MemoryReport - Report - MemoryReportsChan - ReportsChan - MemoryReporter - Reporter - MemoryProfilerMsg - ProfilerMsg - {R,UnR}egisterMemoryReporter - {R,UnR}egisterReporter - MemoryProfiler - Prof - ReportsForest - ReportsForest (unchanged) - ReportsTree - ReportsTree (unchanged) - SystemMemoryReporter - SystemReporter prof::time prof::time - TimeProfilerChan - ProfilerChan - TimerMetadata - TimerMetadata (unchanged) - Formatable - Formattable [spelling!] - TimeProfilerMsg - ProfilerMsg - TimeProfilerCategory - ProfilerCategory - TimeProfilerBuckets - ProfilerBuckets - TimeProfiler - Profiler - TimerMetadataFrameType - TimerMetadataFrameType (unchanged) - TimerMetadataReflowType - TimerMetadataReflowType (unchanged) - ProfilerMetadata - ProfilerMetadata (unchanged) In a few places both prof::time and prof::mem are used, and so module-qualification is needed to avoid overlap, e.g. time::Profiler and mem::Profiler. Likewise with std::mem and prof::mem. This is not a big deal.
This commit is contained in:
parent
7f587f6cb5
commit
ce36e574f4
19 changed files with 322 additions and 331 deletions
|
@ -34,9 +34,7 @@ use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||||
use msg::constellation_msg::{PipelineId, WindowSizeData};
|
use msg::constellation_msg::{PipelineId, WindowSizeData};
|
||||||
use profile::mem;
|
use profile::mem;
|
||||||
use profile::mem::{MemoryProfilerChan};
|
use profile::time::{self, ProfilerCategory, profile};
|
||||||
use profile::time;
|
|
||||||
use profile::time::{TimeProfilerCategory, profile, TimeProfilerChan};
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
|
@ -119,10 +117,10 @@ pub struct IOCompositor<Window: WindowMethods> {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the time profiler.
|
/// The channel on which messages can be sent to the time profiler.
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the memory profiler.
|
/// The channel on which messages can be sent to the memory profiler.
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
|
||||||
/// Pending scroll to fragment event, if any
|
/// Pending scroll to fragment event, if any
|
||||||
fragment_point: Option<Point2D<f32>>,
|
fragment_point: Option<Point2D<f32>>,
|
||||||
|
@ -184,8 +182,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
sender: Box<CompositorProxy+Send>,
|
sender: Box<CompositorProxy+Send>,
|
||||||
receiver: Box<CompositorReceiver>,
|
receiver: Box<CompositorReceiver>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan)
|
mem_profiler_chan: mem::ProfilerChan)
|
||||||
-> IOCompositor<Window> {
|
-> IOCompositor<Window> {
|
||||||
// Create an initial layer tree.
|
// Create an initial layer tree.
|
||||||
//
|
//
|
||||||
|
@ -217,7 +215,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
got_set_frame_tree_message: false,
|
got_set_frame_tree_message: false,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
memory_profiler_chan: memory_profiler_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
fragment_point: None,
|
fragment_point: None,
|
||||||
outstanding_paint_msgs: 0,
|
outstanding_paint_msgs: 0,
|
||||||
last_composite_time: 0,
|
last_composite_time: 0,
|
||||||
|
@ -229,15 +227,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
sender: Box<CompositorProxy+Send>,
|
sender: Box<CompositorProxy+Send>,
|
||||||
receiver: Box<CompositorReceiver>,
|
receiver: Box<CompositorReceiver>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan)
|
mem_profiler_chan: mem::ProfilerChan)
|
||||||
-> IOCompositor<Window> {
|
-> IOCompositor<Window> {
|
||||||
let mut compositor = IOCompositor::new(window,
|
let mut compositor = IOCompositor::new(window,
|
||||||
sender,
|
sender,
|
||||||
receiver,
|
receiver,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
mem_profiler_chan);
|
||||||
|
|
||||||
// Set the size of the root layer.
|
// Set the size of the root layer.
|
||||||
compositor.update_zoom_transform();
|
compositor.update_zoom_transform();
|
||||||
|
@ -1109,7 +1107,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
gl::bind_texture(gl::TEXTURE_2D, 0);
|
gl::bind_texture(gl::TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
profile(TimeProfilerCategory::Compositing, None, self.time_profiler_chan.clone(), || {
|
profile(ProfilerCategory::Compositing, None, self.time_profiler_chan.clone(), || {
|
||||||
debug!("compositor: compositing");
|
debug!("compositor: compositing");
|
||||||
// Adjust the layer dimensions as necessary to correspond to the size of the window.
|
// Adjust the layer dimensions as necessary to correspond to the size of the window.
|
||||||
self.scene.viewport = Rect {
|
self.scene.viewport = Rect {
|
||||||
|
@ -1356,8 +1354,8 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
|
||||||
while self.port.try_recv_compositor_msg().is_some() {}
|
while self.port.try_recv_compositor_msg().is_some() {}
|
||||||
|
|
||||||
// Tell the profiler, memory profiler, and scrolling timer to shut down.
|
// Tell the profiler, memory profiler, and scrolling timer to shut down.
|
||||||
self.time_profiler_chan.send(time::TimeProfilerMsg::Exit);
|
self.time_profiler_chan.send(time::ProfilerMsg::Exit);
|
||||||
self.memory_profiler_chan.send(mem::MemoryProfilerMsg::Exit);
|
self.mem_profiler_chan.send(mem::ProfilerMsg::Exit);
|
||||||
self.scrolling_timer.shutdown();
|
self.scrolling_timer.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ use msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
||||||
use msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
|
use msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy};
|
||||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||||
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
|
||||||
use profile::mem::MemoryProfilerChan;
|
use profile::mem;
|
||||||
use profile::time::TimeProfilerChan;
|
use profile::time;
|
||||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||||
use std::fmt::{Error, Formatter, Debug};
|
use std::fmt::{Error, Formatter, Debug};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -265,8 +265,8 @@ impl CompositorTask {
|
||||||
sender: Box<CompositorProxy+Send>,
|
sender: Box<CompositorProxy+Send>,
|
||||||
receiver: Box<CompositorReceiver>,
|
receiver: Box<CompositorReceiver>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan)
|
mem_profiler_chan: mem::ProfilerChan)
|
||||||
-> Box<CompositorEventListener + 'static>
|
-> Box<CompositorEventListener + 'static>
|
||||||
where Window: WindowMethods + 'static {
|
where Window: WindowMethods + 'static {
|
||||||
match window {
|
match window {
|
||||||
|
@ -276,14 +276,14 @@ impl CompositorTask {
|
||||||
receiver,
|
receiver,
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan)
|
mem_profiler_chan)
|
||||||
as Box<CompositorEventListener>
|
as Box<CompositorEventListener>
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
box headless::NullCompositor::create(receiver,
|
box headless::NullCompositor::create(receiver,
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan)
|
mem_profiler_chan)
|
||||||
as Box<CompositorEventListener>
|
as Box<CompositorEventListener>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
use net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
||||||
use net::resource_task::{self, ResourceTask};
|
use net::resource_task::{self, ResourceTask};
|
||||||
use net::storage_task::{StorageTask, StorageTaskMsg};
|
use net::storage_task::{StorageTask, StorageTaskMsg};
|
||||||
use profile::mem::MemoryProfilerChan;
|
use profile::mem;
|
||||||
use profile::time::TimeProfilerChan;
|
use profile::time;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::PagePx;
|
use util::geometry::PagePx;
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
@ -91,10 +91,10 @@ pub struct Constellation<LTF, STF> {
|
||||||
pending_frames: Vec<FrameChange>,
|
pending_frames: Vec<FrameChange>,
|
||||||
|
|
||||||
/// A channel through which messages can be sent to the time profiler.
|
/// A channel through which messages can be sent to the time profiler.
|
||||||
pub time_profiler_chan: TimeProfilerChan,
|
pub time_profiler_chan: time::ProfilerChan,
|
||||||
|
|
||||||
/// A channel through which messages can be sent to the memory profiler.
|
/// A channel through which messages can be sent to the memory profiler.
|
||||||
pub memory_profiler_chan: MemoryProfilerChan,
|
pub mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
|
||||||
phantom: PhantomData<(LTF, STF)>,
|
phantom: PhantomData<(LTF, STF)>,
|
||||||
|
|
||||||
|
@ -173,8 +173,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
devtools_chan: Option<DevtoolsControlChan>,
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
storage_task: StorageTask)
|
storage_task: StorageTask)
|
||||||
-> ConstellationChan {
|
-> ConstellationChan {
|
||||||
|
@ -199,7 +199,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
root_frame_id: None,
|
root_frame_id: None,
|
||||||
next_frame_id: FrameId(0),
|
next_frame_id: FrameId(0),
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
memory_profiler_chan: memory_profiler_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
window_size: WindowSizeData {
|
window_size: WindowSizeData {
|
||||||
visible_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0),
|
visible_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0),
|
||||||
initial_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0),
|
initial_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0),
|
||||||
|
@ -242,7 +242,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.storage_task.clone(),
|
self.storage_task.clone(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.memory_profiler_chan.clone(),
|
self.mem_profiler_chan.clone(),
|
||||||
initial_window_rect,
|
initial_window_rect,
|
||||||
script_channel,
|
script_channel,
|
||||||
load_data,
|
load_data,
|
||||||
|
|
|
@ -10,9 +10,7 @@ use geom::size::TypedSize2D;
|
||||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use msg::constellation_msg::{ConstellationChan, WindowSizeData};
|
use msg::constellation_msg::{ConstellationChan, WindowSizeData};
|
||||||
use profile::mem;
|
use profile::mem;
|
||||||
use profile::mem::MemoryProfilerChan;
|
|
||||||
use profile::time;
|
use profile::time;
|
||||||
use profile::time::TimeProfilerChan;
|
|
||||||
|
|
||||||
/// Starts the compositor, which listens for messages on the specified port.
|
/// Starts the compositor, which listens for messages on the specified port.
|
||||||
///
|
///
|
||||||
|
@ -24,34 +22,34 @@ pub struct NullCompositor {
|
||||||
/// A channel to the constellation.
|
/// A channel to the constellation.
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
/// A channel to the time profiler.
|
/// A channel to the time profiler.
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
/// A channel to the memory profiler.
|
/// A channel to the memory profiler.
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NullCompositor {
|
impl NullCompositor {
|
||||||
fn new(port: Box<CompositorReceiver>,
|
fn new(port: Box<CompositorReceiver>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan)
|
mem_profiler_chan: mem::ProfilerChan)
|
||||||
-> NullCompositor {
|
-> NullCompositor {
|
||||||
NullCompositor {
|
NullCompositor {
|
||||||
port: port,
|
port: port,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
memory_profiler_chan: memory_profiler_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(port: Box<CompositorReceiver>,
|
pub fn create(port: Box<CompositorReceiver>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan)
|
mem_profiler_chan: mem::ProfilerChan)
|
||||||
-> NullCompositor {
|
-> NullCompositor {
|
||||||
let compositor = NullCompositor::new(port,
|
let compositor = NullCompositor::new(port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
mem_profiler_chan);
|
||||||
|
|
||||||
// Tell the constellation about the initial fake size.
|
// Tell the constellation about the initial fake size.
|
||||||
{
|
{
|
||||||
|
@ -120,8 +118,8 @@ impl CompositorEventListener for NullCompositor {
|
||||||
// another task from finishing (i.e. SetIds)
|
// another task from finishing (i.e. SetIds)
|
||||||
while self.port.try_recv_compositor_msg().is_some() {}
|
while self.port.try_recv_compositor_msg().is_some() {}
|
||||||
|
|
||||||
self.time_profiler_chan.send(time::TimeProfilerMsg::Exit);
|
self.time_profiler_chan.send(time::ProfilerMsg::Exit);
|
||||||
self.memory_profiler_chan.send(mem::MemoryProfilerMsg::Exit);
|
self.mem_profiler_chan.send(mem::ProfilerMsg::Exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pinch_zoom_level(&self) -> f32 {
|
fn pinch_zoom_level(&self) -> f32 {
|
||||||
|
|
|
@ -19,8 +19,8 @@ use msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType};
|
||||||
use net::image_cache_task::ImageCacheTask;
|
use net::image_cache_task::ImageCacheTask;
|
||||||
use net::resource_task::ResourceTask;
|
use net::resource_task::ResourceTask;
|
||||||
use net::storage_task::StorageTask;
|
use net::storage_task::StorageTask;
|
||||||
use profile::mem::MemoryProfilerChan;
|
use profile::mem;
|
||||||
use profile::time::TimeProfilerChan;
|
use profile::time;
|
||||||
use std::sync::mpsc::{Receiver, channel};
|
use std::sync::mpsc::{Receiver, channel};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::geometry::{PagePx, ViewportPx};
|
use util::geometry::{PagePx, ViewportPx};
|
||||||
|
@ -64,8 +64,8 @@ impl Pipeline {
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
window_rect: Option<TypedRect<PagePx, f32>>,
|
window_rect: Option<TypedRect<PagePx, f32>>,
|
||||||
script_chan: Option<ScriptControlChan>,
|
script_chan: Option<ScriptControlChan>,
|
||||||
load_data: LoadData,
|
load_data: LoadData,
|
||||||
|
@ -150,7 +150,7 @@ impl Pipeline {
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan,
|
mem_profiler_chan,
|
||||||
layout_shutdown_chan);
|
layout_shutdown_chan);
|
||||||
|
|
||||||
Pipeline::new(id,
|
Pipeline::new(id,
|
||||||
|
|
|
@ -37,7 +37,7 @@ use net::image::base::Image;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::linked_list::prepend_from;
|
use util::linked_list::prepend_from;
|
||||||
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
|
use util::geometry::{self, Au, MAX_RECT, ZERO_RECT};
|
||||||
use util::memory::SizeOf;
|
use util::mem::HeapSizeOf;
|
||||||
use util::range::Range;
|
use util::range::Range;
|
||||||
use util::smallvec::{SmallVec, SmallVec8};
|
use util::smallvec::{SmallVec, SmallVec8};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -197,14 +197,14 @@ impl DisplayList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for DisplayList {
|
impl HeapSizeOf for DisplayList {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.background_and_borders.size_of_excluding_self() +
|
self.background_and_borders.heap_size_of_children() +
|
||||||
self.block_backgrounds_and_borders.size_of_excluding_self() +
|
self.block_backgrounds_and_borders.heap_size_of_children() +
|
||||||
self.floats.size_of_excluding_self() +
|
self.floats.heap_size_of_children() +
|
||||||
self.content.size_of_excluding_self() +
|
self.content.heap_size_of_children() +
|
||||||
self.outlines.size_of_excluding_self() +
|
self.outlines.heap_size_of_children() +
|
||||||
self.children.size_of_excluding_self()
|
self.children.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,9 +530,9 @@ impl StackingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for StackingContext {
|
impl HeapSizeOf for StackingContext {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.display_list.size_of_excluding_self()
|
self.display_list.heap_size_of_children()
|
||||||
|
|
||||||
// FIXME(njn): other fields may be measured later, esp. `layer`
|
// FIXME(njn): other fields may be measured later, esp. `layer`
|
||||||
}
|
}
|
||||||
|
@ -593,10 +593,10 @@ impl BaseDisplayItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for BaseDisplayItem {
|
impl HeapSizeOf for BaseDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.metadata.size_of_excluding_self() +
|
self.metadata.heap_size_of_children() +
|
||||||
self.clip.size_of_excluding_self()
|
self.clip.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,14 +725,14 @@ impl ClippingRegion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for ClippingRegion {
|
impl HeapSizeOf for ClippingRegion {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.complex.size_of_excluding_self()
|
self.complex.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for ComplexClippingRegion {
|
impl HeapSizeOf for ComplexClippingRegion {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -768,8 +768,8 @@ impl DisplayItemMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for DisplayItemMetadata {
|
impl HeapSizeOf for DisplayItemMetadata {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -784,9 +784,9 @@ pub struct SolidColorDisplayItem {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for SolidColorDisplayItem {
|
impl HeapSizeOf for SolidColorDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.base.size_of_excluding_self()
|
self.base.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,9 +815,9 @@ pub struct TextDisplayItem {
|
||||||
pub blur_radius: Au,
|
pub blur_radius: Au,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for TextDisplayItem {
|
impl HeapSizeOf for TextDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.base.size_of_excluding_self()
|
self.base.heap_size_of_children()
|
||||||
// We exclude `text_run` because it is non-owning.
|
// We exclude `text_run` because it is non-owning.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,9 +845,9 @@ pub struct ImageDisplayItem {
|
||||||
pub image_rendering: image_rendering::T,
|
pub image_rendering: image_rendering::T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for ImageDisplayItem {
|
impl HeapSizeOf for ImageDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.base.size_of_excluding_self()
|
self.base.heap_size_of_children()
|
||||||
// We exclude `image` here because it is non-owning.
|
// We exclude `image` here because it is non-owning.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,15 +868,15 @@ pub struct GradientDisplayItem {
|
||||||
pub stops: Vec<GradientStop>,
|
pub stops: Vec<GradientStop>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for GradientDisplayItem {
|
impl HeapSizeOf for GradientDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use util::memory::heap_size_of;
|
use util::mem::heap_size_of;
|
||||||
|
|
||||||
// We can't measure `stops` via Vec's SizeOf implementation because GradientStop isn't
|
// We can't measure `stops` via Vec's HeapSizeOf implementation because GradientStop isn't
|
||||||
// defined in this module, and we don't want to import GradientStop into util::memory where
|
// defined in this module, and we don't want to import GradientStop into util::mem where
|
||||||
// the SizeOf trait is defined. So we measure the elements directly.
|
// the HeapSizeOf trait is defined. So we measure the elements directly.
|
||||||
self.base.size_of_excluding_self() +
|
self.base.heap_size_of_children() +
|
||||||
heap_size_of(self.stops.as_ptr() as *const c_void)
|
heap_size_of(self.stops.as_ptr() as *const c_void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,9 +903,9 @@ pub struct BorderDisplayItem {
|
||||||
pub radius: BorderRadii<Au>,
|
pub radius: BorderRadii<Au>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for BorderDisplayItem {
|
impl HeapSizeOf for BorderDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.base.size_of_excluding_self()
|
self.base.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,9 +953,9 @@ pub struct LineDisplayItem {
|
||||||
pub style: border_style::T
|
pub style: border_style::T
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for LineDisplayItem {
|
impl HeapSizeOf for LineDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.base.size_of_excluding_self()
|
self.base.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,9 +984,9 @@ pub struct BoxShadowDisplayItem {
|
||||||
pub clip_mode: BoxShadowClipMode,
|
pub clip_mode: BoxShadowClipMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for BoxShadowDisplayItem {
|
impl HeapSizeOf for BoxShadowDisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.base.size_of_excluding_self()
|
self.base.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1152,16 +1152,16 @@ impl fmt::Debug for DisplayItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for DisplayItem {
|
impl HeapSizeOf for DisplayItem {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
SolidColorClass(ref item) => item.size_of_excluding_self(),
|
SolidColorClass(ref item) => item.heap_size_of_children(),
|
||||||
TextClass(ref item) => item.size_of_excluding_self(),
|
TextClass(ref item) => item.heap_size_of_children(),
|
||||||
ImageClass(ref item) => item.size_of_excluding_self(),
|
ImageClass(ref item) => item.heap_size_of_children(),
|
||||||
BorderClass(ref item) => item.size_of_excluding_self(),
|
BorderClass(ref item) => item.heap_size_of_children(),
|
||||||
GradientClass(ref item) => item.size_of_excluding_self(),
|
GradientClass(ref item) => item.heap_size_of_children(),
|
||||||
LineClass(ref item) => item.size_of_excluding_self(),
|
LineClass(ref item) => item.heap_size_of_children(),
|
||||||
BoxShadowClass(ref item) => item.size_of_excluding_self(),
|
BoxShadowClass(ref item) => item.heap_size_of_children(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use msg::compositor_msg::{LayerMetadata, PaintListener, ScrollPolicy};
|
||||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
|
||||||
use msg::constellation_msg::PipelineExitType;
|
use msg::constellation_msg::PipelineExitType;
|
||||||
use profile::time::{TimeProfilerChan, TimeProfilerCategory, profile};
|
use profile::time::{self, profile};
|
||||||
use skia::SkiaGrGLNativeContextRef;
|
use skia::SkiaGrGLNativeContextRef;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::thread::Builder;
|
use std::thread::Builder;
|
||||||
|
@ -101,7 +101,7 @@ pub struct PaintTask<C> {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
/// A channel to the time profiler.
|
/// A channel to the time profiler.
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
|
|
||||||
/// The native graphics context.
|
/// The native graphics context.
|
||||||
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
||||||
|
@ -141,7 +141,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
failure_msg: Failure,
|
failure_msg: Failure,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
shutdown_chan: Sender<()>) {
|
shutdown_chan: Sender<()>) {
|
||||||
let ConstellationChan(c) = constellation_chan.clone();
|
let ConstellationChan(c) = constellation_chan.clone();
|
||||||
spawn_named_with_send_on_failure("PaintTask", task_state::PAINT, move || {
|
spawn_named_with_send_on_failure("PaintTask", task_state::PAINT, move || {
|
||||||
|
@ -336,7 +336,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
mut tiles: Vec<BufferRequest>,
|
mut tiles: Vec<BufferRequest>,
|
||||||
scale: f32,
|
scale: f32,
|
||||||
layer_id: LayerId) {
|
layer_id: LayerId) {
|
||||||
profile(TimeProfilerCategory::Painting, None, self.time_profiler_chan.clone(), || {
|
profile(time::ProfilerCategory::Painting, None, self.time_profiler_chan.clone(), || {
|
||||||
// Bail out if there is no appropriate stacking context.
|
// Bail out if there is no appropriate stacking context.
|
||||||
let stacking_context = if let Some(ref stacking_context) = self.root_stacking_context {
|
let stacking_context = if let Some(ref stacking_context) = self.root_stacking_context {
|
||||||
match display_list::find_stacking_context_with_layer_id(stacking_context,
|
match display_list::find_stacking_context_with_layer_id(stacking_context,
|
||||||
|
@ -419,7 +419,7 @@ struct WorkerThreadProxy {
|
||||||
impl WorkerThreadProxy {
|
impl WorkerThreadProxy {
|
||||||
fn spawn(native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
fn spawn(native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: TimeProfilerChan)
|
time_profiler_chan: time::ProfilerChan)
|
||||||
-> Vec<WorkerThreadProxy> {
|
-> Vec<WorkerThreadProxy> {
|
||||||
let thread_count = if opts::get().gpu_painting {
|
let thread_count = if opts::get().gpu_painting {
|
||||||
1
|
1
|
||||||
|
@ -472,7 +472,7 @@ struct WorkerThread {
|
||||||
receiver: Receiver<MsgToWorkerThread>,
|
receiver: Receiver<MsgToWorkerThread>,
|
||||||
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
native_graphics_context: Option<NativePaintingGraphicsContext>,
|
||||||
font_context: Box<FontContext>,
|
font_context: Box<FontContext>,
|
||||||
time_profiler_sender: TimeProfilerChan,
|
time_profiler_sender: time::ProfilerChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkerThread {
|
impl WorkerThread {
|
||||||
|
@ -480,7 +480,7 @@ impl WorkerThread {
|
||||||
receiver: Receiver<MsgToWorkerThread>,
|
receiver: Receiver<MsgToWorkerThread>,
|
||||||
native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
native_graphics_metadata: Option<NativeGraphicsMetadata>,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_sender: TimeProfilerChan)
|
time_profiler_sender: time::ProfilerChan)
|
||||||
-> WorkerThread {
|
-> WorkerThread {
|
||||||
WorkerThread {
|
WorkerThread {
|
||||||
sender: sender,
|
sender: sender,
|
||||||
|
@ -559,7 +559,7 @@ impl WorkerThread {
|
||||||
paint_context.clear();
|
paint_context.clear();
|
||||||
|
|
||||||
// Draw the display list.
|
// Draw the display list.
|
||||||
profile(TimeProfilerCategory::PaintingPerTile, None,
|
profile(time::ProfilerCategory::PaintingPerTile, None,
|
||||||
self.time_profiler_sender.clone(), || {
|
self.time_profiler_sender.clone(), || {
|
||||||
stacking_context.optimize_and_draw_into_context(&mut paint_context,
|
stacking_context.optimize_and_draw_into_context(&mut paint_context,
|
||||||
&tile_bounds,
|
&tile_bounds,
|
||||||
|
|
|
@ -43,9 +43,9 @@ use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, Pipel
|
||||||
use net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
|
use net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
|
||||||
use net::local_image_cache::{ImageResponder, LocalImageCache};
|
use net::local_image_cache::{ImageResponder, LocalImageCache};
|
||||||
use net::resource_task::{ResourceTask, load_bytes_iter};
|
use net::resource_task::{ResourceTask, load_bytes_iter};
|
||||||
use profile::mem::{MemoryProfilerChan, MemoryProfilerMsg, MemoryReport, MemoryReportsChan};
|
use profile::mem::{self, Report, ReportsChan};
|
||||||
use profile::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan};
|
use profile::time::{self, ProfilerCategory, ProfilerMetadata, profile};
|
||||||
use profile::time::{TimerMetadataFrameType, TimerMetadataReflowType, profile};
|
use profile::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||||
use script::dom::bindings::js::LayoutJS;
|
use script::dom::bindings::js::LayoutJS;
|
||||||
use script::dom::element::ElementTypeId;
|
use script::dom::element::ElementTypeId;
|
||||||
use script::dom::htmlelement::HTMLElementTypeId;
|
use script::dom::htmlelement::HTMLElementTypeId;
|
||||||
|
@ -59,7 +59,7 @@ use script_traits::{ConstellationControlMsg, CompositorEvent, OpaqueScriptLayout
|
||||||
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::mem;
|
use std::mem::transmute;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::mpsc::{channel, Sender, Receiver, Select};
|
use std::sync::mpsc::{channel, Sender, Receiver, Select};
|
||||||
|
@ -73,7 +73,7 @@ use url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::Au;
|
use util::geometry::Au;
|
||||||
use util::logical_geometry::LogicalPoint;
|
use util::logical_geometry::LogicalPoint;
|
||||||
use util::memory::{SizeOf};
|
use util::mem::HeapSizeOf;
|
||||||
use util::opts;
|
use util::opts;
|
||||||
use util::smallvec::{SmallVec, SmallVec1, VecLike};
|
use util::smallvec::{SmallVec, SmallVec1, VecLike};
|
||||||
use util::task::spawn_named_with_send_on_failure;
|
use util::task::spawn_named_with_send_on_failure;
|
||||||
|
@ -143,13 +143,13 @@ pub struct LayoutTask {
|
||||||
pub paint_chan: PaintChan,
|
pub paint_chan: PaintChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the time profiler.
|
/// The channel on which messages can be sent to the time profiler.
|
||||||
pub time_profiler_chan: TimeProfilerChan,
|
pub time_profiler_chan: time::ProfilerChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the memory profiler.
|
/// The channel on which messages can be sent to the memory profiler.
|
||||||
pub memory_profiler_chan: MemoryProfilerChan,
|
pub mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
|
||||||
/// The name used for the task's memory reporter.
|
/// The name used for the task's memory reporter.
|
||||||
pub memory_reporter_name: String,
|
pub reporter_name: String,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the resource task.
|
/// The channel on which messages can be sent to the resource task.
|
||||||
pub resource_task: ResourceTask,
|
pub resource_task: ResourceTask,
|
||||||
|
@ -204,8 +204,8 @@ impl LayoutTaskFactory for LayoutTask {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
img_cache_task: ImageCacheTask,
|
img_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
shutdown_chan: Sender<()>) {
|
shutdown_chan: Sender<()>) {
|
||||||
let ConstellationChan(con_chan) = constellation_chan.clone();
|
let ConstellationChan(con_chan) = constellation_chan.clone();
|
||||||
spawn_named_with_send_on_failure("LayoutTask", task_state::LAYOUT, move || {
|
spawn_named_with_send_on_failure("LayoutTask", task_state::LAYOUT, move || {
|
||||||
|
@ -225,7 +225,7 @@ impl LayoutTaskFactory for LayoutTask {
|
||||||
img_cache_task,
|
img_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
mem_profiler_chan);
|
||||||
layout.start();
|
layout.start();
|
||||||
}
|
}
|
||||||
shutdown_chan.send(()).unwrap();
|
shutdown_chan.send(()).unwrap();
|
||||||
|
@ -276,8 +276,8 @@ impl LayoutTask {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan)
|
mem_profiler_chan: mem::ProfilerChan)
|
||||||
-> LayoutTask {
|
-> LayoutTask {
|
||||||
let local_image_cache =
|
let local_image_cache =
|
||||||
Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone())));
|
Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone())));
|
||||||
|
@ -296,8 +296,7 @@ impl LayoutTask {
|
||||||
// Register this thread as a memory reporter, via its own channel.
|
// Register this thread as a memory reporter, via its own channel.
|
||||||
let reporter = Box::new(chan.clone());
|
let reporter = Box::new(chan.clone());
|
||||||
let reporter_name = format!("layout-reporter-{}", id.0);
|
let reporter_name = format!("layout-reporter-{}", id.0);
|
||||||
memory_profiler_chan.send(MemoryProfilerMsg::RegisterMemoryReporter(reporter_name.clone(),
|
mem_profiler_chan.send(mem::ProfilerMsg::RegisterReporter(reporter_name.clone(), reporter));
|
||||||
reporter));
|
|
||||||
|
|
||||||
LayoutTask {
|
LayoutTask {
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -309,8 +308,8 @@ impl LayoutTask {
|
||||||
constellation_chan: constellation_chan.clone(),
|
constellation_chan: constellation_chan.clone(),
|
||||||
paint_chan: paint_chan,
|
paint_chan: paint_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
memory_profiler_chan: memory_profiler_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
memory_reporter_name: reporter_name,
|
reporter_name: reporter_name,
|
||||||
resource_task: resource_task,
|
resource_task: resource_task,
|
||||||
image_cache_task: image_cache_task.clone(),
|
image_cache_task: image_cache_task.clone(),
|
||||||
font_cache_task: font_cache_task,
|
font_cache_task: font_cache_task,
|
||||||
|
@ -444,7 +443,7 @@ impl LayoutTask {
|
||||||
Box<LayoutRPC + Send>).unwrap();
|
Box<LayoutRPC + Send>).unwrap();
|
||||||
},
|
},
|
||||||
Msg::Reflow(data) => {
|
Msg::Reflow(data) => {
|
||||||
profile(TimeProfilerCategory::LayoutPerform,
|
profile(time::ProfilerCategory::LayoutPerform,
|
||||||
self.profiler_metadata(&*data),
|
self.profiler_metadata(&*data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
||||||
|
@ -454,8 +453,8 @@ impl LayoutTask {
|
||||||
self.handle_reap_layout_data(dead_layout_data)
|
self.handle_reap_layout_data(dead_layout_data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Msg::CollectMemoryReports(reports_chan) => {
|
Msg::CollectReports(reports_chan) => {
|
||||||
self.collect_memory_reports(reports_chan, possibly_locked_rw_data);
|
self.collect_reports(reports_chan, possibly_locked_rw_data);
|
||||||
},
|
},
|
||||||
Msg::PrepareToExit(response_chan) => {
|
Msg::PrepareToExit(response_chan) => {
|
||||||
debug!("layout: PrepareToExitMsg received");
|
debug!("layout: PrepareToExitMsg received");
|
||||||
|
@ -472,18 +471,17 @@ impl LayoutTask {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_memory_reports<'a>(&'a self,
|
fn collect_reports<'a>(&'a self,
|
||||||
reports_chan: MemoryReportsChan,
|
reports_chan: ReportsChan,
|
||||||
possibly_locked_rw_data:
|
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
||||||
&mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
|
||||||
let mut reports = vec![];
|
let mut reports = vec![];
|
||||||
|
|
||||||
// FIXME(njn): Just measuring the display tree for now.
|
// FIXME(njn): Just measuring the display tree for now.
|
||||||
let rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
let rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
||||||
let stacking_context = rw_data.stacking_context.as_ref();
|
let stacking_context = rw_data.stacking_context.as_ref();
|
||||||
reports.push(MemoryReport {
|
reports.push(Report {
|
||||||
path: path!["pages", format!("url({})", self.url), "display-list"],
|
path: path!["pages", format!("url({})", self.url), "display-list"],
|
||||||
size: stacking_context.map_or(0, |sc| sc.size_of_excluding_self() as u64),
|
size: stacking_context.map_or(0, |sc| sc.heap_size_of_children() as u64),
|
||||||
});
|
});
|
||||||
|
|
||||||
reports_chan.send(reports);
|
reports_chan.send(reports);
|
||||||
|
@ -532,9 +530,8 @@ impl LayoutTask {
|
||||||
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
let unregister_msg =
|
let msg = mem::ProfilerMsg::UnregisterReporter(self.reporter_name.clone());
|
||||||
MemoryProfilerMsg::UnregisterMemoryReporter(self.memory_reporter_name.clone());
|
self.mem_profiler_chan.send(msg);
|
||||||
self.memory_profiler_chan.send(unregister_msg);
|
|
||||||
|
|
||||||
self.paint_chan.send(PaintMsg::Exit(Some(response_chan), exit_type));
|
self.paint_chan.send(PaintMsg::Exit(Some(response_chan), exit_type));
|
||||||
response_port.recv().unwrap()
|
response_port.recv().unwrap()
|
||||||
|
@ -705,7 +702,7 @@ impl LayoutTask {
|
||||||
shared_layout_context: &mut SharedLayoutContext,
|
shared_layout_context: &mut SharedLayoutContext,
|
||||||
rw_data: &mut RWGuard<'a>) {
|
rw_data: &mut RWGuard<'a>) {
|
||||||
let writing_mode = flow::base(&**layout_root).writing_mode;
|
let writing_mode = flow::base(&**layout_root).writing_mode;
|
||||||
profile(TimeProfilerCategory::LayoutDispListBuild,
|
profile(time::ProfilerCategory::LayoutDispListBuild,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
|
@ -814,7 +811,7 @@ impl LayoutTask {
|
||||||
LayoutJS::from_trusted_node_address(data.document_root)
|
LayoutJS::from_trusted_node_address(data.document_root)
|
||||||
};
|
};
|
||||||
let node: &mut LayoutNode = unsafe {
|
let node: &mut LayoutNode = unsafe {
|
||||||
mem::transmute(&mut node)
|
transmute(&mut node)
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("layout: received layout request for: {}", data.url.serialize());
|
debug!("layout: received layout request for: {}", data.url.serialize());
|
||||||
|
@ -874,7 +871,7 @@ impl LayoutTask {
|
||||||
node,
|
node,
|
||||||
&data.url);
|
&data.url);
|
||||||
|
|
||||||
let mut layout_root = profile(TimeProfilerCategory::LayoutStyleRecalc,
|
let mut layout_root = profile(time::ProfilerCategory::LayoutStyleRecalc,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
|
@ -892,7 +889,7 @@ impl LayoutTask {
|
||||||
self.get_layout_root((*node).clone())
|
self.get_layout_root((*node).clone())
|
||||||
});
|
});
|
||||||
|
|
||||||
profile(TimeProfilerCategory::LayoutRestyleDamagePropagation,
|
profile(time::ProfilerCategory::LayoutRestyleDamagePropagation,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
|
@ -912,7 +909,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve generated content.
|
// Resolve generated content.
|
||||||
profile(TimeProfilerCategory::LayoutGeneratedContent,
|
profile(time::ProfilerCategory::LayoutGeneratedContent,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
|
@ -921,7 +918,7 @@ impl LayoutTask {
|
||||||
|
|
||||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||||
// the boxes.
|
// the boxes.
|
||||||
profile(TimeProfilerCategory::LayoutMain,
|
profile(time::ProfilerCategory::LayoutMain,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(data),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
|
@ -1024,7 +1021,7 @@ impl LayoutTask {
|
||||||
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
|
||||||
/// because the struct type is transmuted to a different type on the script side.
|
/// because the struct type is transmuted to a different type on the script side.
|
||||||
unsafe fn handle_reap_layout_data(&self, layout_data: LayoutData) {
|
unsafe fn handle_reap_layout_data(&self, layout_data: LayoutData) {
|
||||||
let layout_data_wrapper: LayoutDataWrapper = mem::transmute(layout_data);
|
let layout_data_wrapper: LayoutDataWrapper = transmute(layout_data);
|
||||||
layout_data_wrapper.remove_compositor_layers(self.constellation_chan.clone());
|
layout_data_wrapper.remove_compositor_layers(self.constellation_chan.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe_layout_
|
||||||
use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode};
|
use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode};
|
||||||
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
||||||
|
|
||||||
use profile::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan, profile};
|
use profile::time::{self, ProfilerCategory, ProfilerMetadata, profile};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
|
@ -430,7 +430,7 @@ pub fn traverse_dom_preorder(root: LayoutNode,
|
||||||
|
|
||||||
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
profiler_metadata: ProfilerMetadata,
|
profiler_metadata: ProfilerMetadata,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<SharedLayoutContextWrapper,UnsafeFlow>) {
|
queue: &mut WorkQueue<SharedLayoutContextWrapper,UnsafeFlow>) {
|
||||||
if opts::get().bubble_inline_sizes_separately {
|
if opts::get().bubble_inline_sizes_separately {
|
||||||
|
@ -441,7 +441,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _);
|
queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _);
|
||||||
|
|
||||||
profile(TimeProfilerCategory::LayoutParallelWarmup, profiler_metadata,
|
profile(time::ProfilerCategory::LayoutParallelWarmup, profiler_metadata,
|
||||||
time_profiler_chan, || {
|
time_profiler_chan, || {
|
||||||
queue.push(WorkUnit {
|
queue.push(WorkUnit {
|
||||||
fun: assign_inline_sizes,
|
fun: assign_inline_sizes,
|
||||||
|
@ -456,12 +456,12 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
||||||
profiler_metadata: ProfilerMetadata,
|
profiler_metadata: ProfilerMetadata,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<SharedLayoutContextWrapper,UnsafeFlow>) {
|
queue: &mut WorkQueue<SharedLayoutContextWrapper,UnsafeFlow>) {
|
||||||
queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _);
|
queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _);
|
||||||
|
|
||||||
profile(TimeProfilerCategory::LayoutParallelWarmup, profiler_metadata,
|
profile(time::ProfilerCategory::LayoutParallelWarmup, profiler_metadata,
|
||||||
time_profiler_chan, || {
|
time_profiler_chan, || {
|
||||||
queue.push(WorkUnit {
|
queue.push(WorkUnit {
|
||||||
fun: compute_absolute_positions,
|
fun: compute_absolute_positions,
|
||||||
|
|
|
@ -20,8 +20,8 @@ use gfx::paint_task::PaintChan;
|
||||||
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, PipelineExitType};
|
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, PipelineExitType};
|
||||||
use net::image_cache_task::ImageCacheTask;
|
use net::image_cache_task::ImageCacheTask;
|
||||||
use net::resource_task::ResourceTask;
|
use net::resource_task::ResourceTask;
|
||||||
use profile::mem::MemoryProfilerChan;
|
use profile::mem;
|
||||||
use profile::time::TimeProfilerChan;
|
use profile::time;
|
||||||
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel};
|
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel};
|
||||||
use std::sync::mpsc::{Sender, Receiver};
|
use std::sync::mpsc::{Sender, Receiver};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -50,7 +50,7 @@ pub trait LayoutTaskFactory {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
img_cache_task: ImageCacheTask,
|
img_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
shutdown_chan: Sender<()>);
|
shutdown_chan: Sender<()>);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use resource_task;
|
||||||
use resource_task::{LoadData, ResourceTask};
|
use resource_task::{LoadData, ResourceTask};
|
||||||
use resource_task::ProgressMsg::{Payload, Done};
|
use resource_task::ProgressMsg::{Payload, Done};
|
||||||
|
|
||||||
use profile::time::{self, profile, TimeProfilerChan};
|
use profile::time::{self, profile};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
|
@ -75,7 +75,7 @@ pub struct ImageCacheTask {
|
||||||
|
|
||||||
impl ImageCacheTask {
|
impl ImageCacheTask {
|
||||||
pub fn new(resource_task: ResourceTask, task_pool: TaskPool,
|
pub fn new(resource_task: ResourceTask, task_pool: TaskPool,
|
||||||
time_profiler_chan: TimeProfilerChan) -> ImageCacheTask {
|
time_profiler_chan: time::ProfilerChan) -> ImageCacheTask {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
let chan_clone = chan.clone();
|
let chan_clone = chan.clone();
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ impl ImageCacheTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_sync(resource_task: ResourceTask, task_pool: TaskPool,
|
pub fn new_sync(resource_task: ResourceTask, task_pool: TaskPool,
|
||||||
time_profiler_chan: TimeProfilerChan) -> ImageCacheTask {
|
time_profiler_chan: time::ProfilerChan) -> ImageCacheTask {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
|
|
||||||
spawn_named("ImageCacheTask (sync)".to_owned(), move || {
|
spawn_named("ImageCacheTask (sync)".to_owned(), move || {
|
||||||
|
@ -141,7 +141,7 @@ struct ImageCache {
|
||||||
wait_map: HashMap<Url, Arc<Mutex<Vec<Sender<ImageResponseMsg>>>>>,
|
wait_map: HashMap<Url, Arc<Mutex<Vec<Sender<ImageResponseMsg>>>>>,
|
||||||
need_exit: Option<Sender<()>>,
|
need_exit: Option<Sender<()>>,
|
||||||
task_pool: TaskPool,
|
task_pool: TaskPool,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -314,7 +314,7 @@ impl ImageCache {
|
||||||
self.task_pool.execute(move || {
|
self.task_pool.execute(move || {
|
||||||
let url = url_clone;
|
let url = url_clone;
|
||||||
debug!("image_cache_task: started image decode for {}", url.serialize());
|
debug!("image_cache_task: started image decode for {}", url.serialize());
|
||||||
let image = profile(time::TimeProfilerCategory::ImageDecoding,
|
let image = profile(time::ProfilerCategory::ImageDecoding,
|
||||||
None, time_profiler_chan, || {
|
None, time_profiler_chan, || {
|
||||||
load_from_memory(&data)
|
load_from_memory(&data)
|
||||||
});
|
});
|
||||||
|
@ -495,7 +495,7 @@ mod tests {
|
||||||
use resource_task::ProgressMsg::{Payload, Done};
|
use resource_task::ProgressMsg::{Payload, Done};
|
||||||
use sniffer_task;
|
use sniffer_task;
|
||||||
use image::base::test_image_bin;
|
use image::base::test_image_bin;
|
||||||
use profile::time::{TimeProfiler, TimeProfilerChan};
|
use profile::time;
|
||||||
use std::sync::mpsc::{Sender, channel, Receiver};
|
use std::sync::mpsc::{Sender, channel, Receiver};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::taskpool::TaskPool;
|
use util::taskpool::TaskPool;
|
||||||
|
@ -587,8 +587,8 @@ mod tests {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn profiler() -> TimeProfilerChan {
|
fn profiler() -> time::ProfilerChan {
|
||||||
TimeProfiler::create(None)
|
time::Profiler::create(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//! Memory profiling functions.
|
//! Memory profiling functions.
|
||||||
|
|
||||||
use self::system_reporter::SystemMemoryReporter;
|
use self::system_reporter::SystemReporter;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -14,11 +14,11 @@ use std::time::duration::Duration;
|
||||||
use util::task::spawn_named;
|
use util::task::spawn_named;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MemoryProfilerChan(pub Sender<MemoryProfilerMsg>);
|
pub struct ProfilerChan(pub Sender<ProfilerMsg>);
|
||||||
|
|
||||||
impl MemoryProfilerChan {
|
impl ProfilerChan {
|
||||||
pub fn send(&self, msg: MemoryProfilerMsg) {
|
pub fn send(&self, msg: ProfilerMsg) {
|
||||||
let MemoryProfilerChan(ref c) = *self;
|
let ProfilerChan(ref c) = *self;
|
||||||
c.send(msg).unwrap();
|
c.send(msg).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ macro_rules! path {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MemoryReport {
|
pub struct Report {
|
||||||
/// The identifying path for this report.
|
/// The identifying path for this report.
|
||||||
pub path: Vec<String>,
|
pub path: Vec<String>,
|
||||||
|
|
||||||
|
@ -42,36 +42,36 @@ pub struct MemoryReport {
|
||||||
|
|
||||||
/// A channel through which memory reports can be sent.
|
/// A channel through which memory reports can be sent.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MemoryReportsChan(pub Sender<Vec<MemoryReport>>);
|
pub struct ReportsChan(pub Sender<Vec<Report>>);
|
||||||
|
|
||||||
impl MemoryReportsChan {
|
impl ReportsChan {
|
||||||
pub fn send(&self, report: Vec<MemoryReport>) {
|
pub fn send(&self, report: Vec<Report>) {
|
||||||
let MemoryReportsChan(ref c) = *self;
|
let ReportsChan(ref c) = *self;
|
||||||
c.send(report).unwrap();
|
c.send(report).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A memory reporter is capable of measuring some data structure of interest. Because it needs
|
/// A memory reporter is capable of measuring some data structure of interest. Because it needs
|
||||||
/// to be passed to and registered with the MemoryProfiler, it's typically a "small" (i.e. easily
|
/// to be passed to and registered with the Profiler, it's typically a "small" (i.e. easily
|
||||||
/// cloneable) value that provides access to a "large" data structure, e.g. a channel that can
|
/// cloneable) value that provides access to a "large" data structure, e.g. a channel that can
|
||||||
/// inject a request for measurements into the event queue associated with the "large" data
|
/// inject a request for measurements into the event queue associated with the "large" data
|
||||||
/// structure.
|
/// structure.
|
||||||
pub trait MemoryReporter {
|
pub trait Reporter {
|
||||||
/// Collect one or more memory reports. Returns true on success, and false on failure.
|
/// Collect one or more memory reports. Returns true on success, and false on failure.
|
||||||
fn collect_reports(&self, reports_chan: MemoryReportsChan) -> bool;
|
fn collect_reports(&self, reports_chan: ReportsChan) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Messages that can be sent to the memory profiler thread.
|
/// Messages that can be sent to the memory profiler thread.
|
||||||
pub enum MemoryProfilerMsg {
|
pub enum ProfilerMsg {
|
||||||
/// Register a MemoryReporter with the memory profiler. The String is only used to identify the
|
/// Register a Reporter with the memory profiler. The String is only used to identify the
|
||||||
/// reporter so it can be unregistered later. The String must be distinct from that used by any
|
/// reporter so it can be unregistered later. The String must be distinct from that used by any
|
||||||
/// other registered reporter otherwise a panic will occur.
|
/// other registered reporter otherwise a panic will occur.
|
||||||
RegisterMemoryReporter(String, Box<MemoryReporter + Send>),
|
RegisterReporter(String, Box<Reporter + Send>),
|
||||||
|
|
||||||
/// Unregister a MemoryReporter with the memory profiler. The String must match the name given
|
/// Unregister a Reporter with the memory profiler. The String must match the name given when
|
||||||
/// when the reporter was registered. If the String does not match the name of a registered
|
/// the reporter was registered. If the String does not match the name of a registered reporter
|
||||||
/// reporter a panic will occur.
|
/// a panic will occur.
|
||||||
UnregisterMemoryReporter(String),
|
UnregisterReporter(String),
|
||||||
|
|
||||||
/// Triggers printing of the memory profiling metrics.
|
/// Triggers printing of the memory profiling metrics.
|
||||||
Print,
|
Print,
|
||||||
|
@ -80,16 +80,16 @@ pub enum MemoryProfilerMsg {
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MemoryProfiler {
|
pub struct Profiler {
|
||||||
/// The port through which messages are received.
|
/// The port through which messages are received.
|
||||||
pub port: Receiver<MemoryProfilerMsg>,
|
pub port: Receiver<ProfilerMsg>,
|
||||||
|
|
||||||
/// Registered memory reporters.
|
/// Registered memory reporters.
|
||||||
reporters: HashMap<String, Box<MemoryReporter + Send>>,
|
reporters: HashMap<String, Box<Reporter + Send>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MemoryProfiler {
|
impl Profiler {
|
||||||
pub fn create(period: Option<f64>) -> MemoryProfilerChan {
|
pub fn create(period: Option<f64>) -> ProfilerChan {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
|
|
||||||
// Create the timer thread if a period was provided.
|
// Create the timer thread if a period was provided.
|
||||||
|
@ -99,7 +99,7 @@ impl MemoryProfiler {
|
||||||
spawn_named("Memory profiler timer".to_owned(), move || {
|
spawn_named("Memory profiler timer".to_owned(), move || {
|
||||||
loop {
|
loop {
|
||||||
sleep(period_ms);
|
sleep(period_ms);
|
||||||
if chan.send(MemoryProfilerMsg::Print).is_err() {
|
if chan.send(ProfilerMsg::Print).is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,24 +109,23 @@ impl MemoryProfiler {
|
||||||
// Always spawn the memory profiler. If there is no timer thread it won't receive regular
|
// Always spawn the memory profiler. If there is no timer thread it won't receive regular
|
||||||
// `Print` events, but it will still receive the other events.
|
// `Print` events, but it will still receive the other events.
|
||||||
spawn_named("Memory profiler".to_owned(), move || {
|
spawn_named("Memory profiler".to_owned(), move || {
|
||||||
let mut memory_profiler = MemoryProfiler::new(port);
|
let mut mem_profiler = Profiler::new(port);
|
||||||
memory_profiler.start();
|
mem_profiler.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
let memory_profiler_chan = MemoryProfilerChan(chan);
|
let mem_profiler_chan = ProfilerChan(chan);
|
||||||
|
|
||||||
// Register the system memory reporter, which will run on the memory profiler's own thread.
|
// Register the system memory reporter, which will run on the memory profiler's own thread.
|
||||||
// It never needs to be unregistered, because as long as the memory profiler is running the
|
// It never needs to be unregistered, because as long as the memory profiler is running the
|
||||||
// system memory reporter can make measurements.
|
// system memory reporter can make measurements.
|
||||||
let system_reporter = Box::new(SystemMemoryReporter);
|
let system_reporter = Box::new(SystemReporter);
|
||||||
memory_profiler_chan.send(MemoryProfilerMsg::RegisterMemoryReporter("system".to_owned(),
|
mem_profiler_chan.send(ProfilerMsg::RegisterReporter("system".to_owned(), system_reporter));
|
||||||
system_reporter));
|
|
||||||
|
|
||||||
memory_profiler_chan
|
mem_profiler_chan
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(port: Receiver<MemoryProfilerMsg>) -> MemoryProfiler {
|
pub fn new(port: Receiver<ProfilerMsg>) -> Profiler {
|
||||||
MemoryProfiler {
|
Profiler {
|
||||||
port: port,
|
port: port,
|
||||||
reporters: HashMap::new(),
|
reporters: HashMap::new(),
|
||||||
}
|
}
|
||||||
|
@ -145,34 +144,33 @@ impl MemoryProfiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(&mut self, msg: MemoryProfilerMsg) -> bool {
|
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
||||||
match msg {
|
match msg {
|
||||||
MemoryProfilerMsg::RegisterMemoryReporter(name, reporter) => {
|
ProfilerMsg::RegisterReporter(name, reporter) => {
|
||||||
// Panic if it has already been registered.
|
// Panic if it has already been registered.
|
||||||
let name_clone = name.clone();
|
let name_clone = name.clone();
|
||||||
match self.reporters.insert(name, reporter) {
|
match self.reporters.insert(name, reporter) {
|
||||||
None => true,
|
None => true,
|
||||||
Some(_) =>
|
Some(_) => panic!(format!("RegisterReporter: '{}' name is already in use",
|
||||||
panic!(format!("RegisterMemoryReporter: '{}' name is already in use",
|
name_clone)),
|
||||||
name_clone)),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
MemoryProfilerMsg::UnregisterMemoryReporter(name) => {
|
ProfilerMsg::UnregisterReporter(name) => {
|
||||||
// Panic if it hasn't previously been registered.
|
// Panic if it hasn't previously been registered.
|
||||||
match self.reporters.remove(&name) {
|
match self.reporters.remove(&name) {
|
||||||
Some(_) => true,
|
Some(_) => true,
|
||||||
None =>
|
None =>
|
||||||
panic!(format!("UnregisterMemoryReporter: '{}' name is unknown", &name)),
|
panic!(format!("UnregisterReporter: '{}' name is unknown", &name)),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
MemoryProfilerMsg::Print => {
|
ProfilerMsg::Print => {
|
||||||
self.handle_print_msg();
|
self.handle_print_msg();
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
|
|
||||||
MemoryProfilerMsg::Exit => false
|
ProfilerMsg::Exit => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +187,7 @@ impl MemoryProfiler {
|
||||||
let mut forest = ReportsForest::new();
|
let mut forest = ReportsForest::new();
|
||||||
for reporter in self.reporters.values() {
|
for reporter in self.reporters.values() {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
if reporter.collect_reports(MemoryReportsChan(chan)) {
|
if reporter.collect_reports(ReportsChan(chan)) {
|
||||||
if let Ok(reports) = port.recv() {
|
if let Ok(reports) = port.recv() {
|
||||||
for report in reports.iter() {
|
for report in reports.iter() {
|
||||||
forest.insert(&report.path, report.size);
|
forest.insert(&report.path, report.size);
|
||||||
|
@ -368,20 +366,20 @@ mod system_reporter {
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
use super::{MemoryReport, MemoryReporter, MemoryReportsChan};
|
use super::{Report, Reporter, ReportsChan};
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
use task_info::task_basic_info::{virtual_size, resident_size};
|
use task_info::task_basic_info::{virtual_size, resident_size};
|
||||||
|
|
||||||
/// Collects global measurements from the OS and heap allocators.
|
/// Collects global measurements from the OS and heap allocators.
|
||||||
pub struct SystemMemoryReporter;
|
pub struct SystemReporter;
|
||||||
|
|
||||||
impl MemoryReporter for SystemMemoryReporter {
|
impl Reporter for SystemReporter {
|
||||||
fn collect_reports(&self, reports_chan: MemoryReportsChan) -> bool {
|
fn collect_reports(&self, reports_chan: ReportsChan) -> bool {
|
||||||
let mut reports = vec![];
|
let mut reports = vec![];
|
||||||
{
|
{
|
||||||
let mut report = |path, size| {
|
let mut report = |path, size| {
|
||||||
if let Some(size) = size {
|
if let Some(size) = size {
|
||||||
reports.push(MemoryReport { path: path, size: size });
|
reports.push(Report { path: path, size: size });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@ use util::task::spawn_named;
|
||||||
|
|
||||||
// front-end representation of the profiler used to communicate with the profiler
|
// front-end representation of the profiler used to communicate with the profiler
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct TimeProfilerChan(pub Sender<TimeProfilerMsg>);
|
pub struct ProfilerChan(pub Sender<ProfilerMsg>);
|
||||||
|
|
||||||
impl TimeProfilerChan {
|
impl ProfilerChan {
|
||||||
pub fn send(&self, msg: TimeProfilerMsg) {
|
pub fn send(&self, msg: ProfilerMsg) {
|
||||||
let TimeProfilerChan(ref c) = *self;
|
let ProfilerChan(ref c) = *self;
|
||||||
c.send(msg).unwrap();
|
c.send(msg).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,11 @@ pub struct TimerMetadata {
|
||||||
incremental: bool,
|
incremental: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Formatable {
|
pub trait Formattable {
|
||||||
fn format(&self) -> String;
|
fn format(&self) -> String;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Formatable for Option<TimerMetadata> {
|
impl Formattable for Option<TimerMetadata> {
|
||||||
fn format(&self) -> String {
|
fn format(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
// TODO(cgaebel): Center-align in the format strings as soon as rustc supports it.
|
// TODO(cgaebel): Center-align in the format strings as soon as rustc supports it.
|
||||||
|
@ -61,9 +61,9 @@ impl Formatable for Option<TimerMetadata> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum TimeProfilerMsg {
|
pub enum ProfilerMsg {
|
||||||
/// Normal message used for reporting time
|
/// Normal message used for reporting time
|
||||||
Time((TimeProfilerCategory, Option<TimerMetadata>), f64),
|
Time((ProfilerCategory, Option<TimerMetadata>), f64),
|
||||||
/// Message used to force print the profiling metrics
|
/// Message used to force print the profiling metrics
|
||||||
Print,
|
Print,
|
||||||
/// Tells the profiler to shut down.
|
/// Tells the profiler to shut down.
|
||||||
|
@ -72,7 +72,7 @@ pub enum TimeProfilerMsg {
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord)]
|
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord)]
|
||||||
pub enum TimeProfilerCategory {
|
pub enum ProfilerCategory {
|
||||||
Compositing,
|
Compositing,
|
||||||
LayoutPerform,
|
LayoutPerform,
|
||||||
LayoutStyleRecalc,
|
LayoutStyleRecalc,
|
||||||
|
@ -92,60 +92,60 @@ pub enum TimeProfilerCategory {
|
||||||
ImageDecoding,
|
ImageDecoding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Formatable for TimeProfilerCategory {
|
impl Formattable for ProfilerCategory {
|
||||||
// some categories are subcategories of LayoutPerformCategory
|
// some categories are subcategories of LayoutPerformCategory
|
||||||
// and should be printed to indicate this
|
// and should be printed to indicate this
|
||||||
fn format(&self) -> String {
|
fn format(&self) -> String {
|
||||||
let padding = match *self {
|
let padding = match *self {
|
||||||
TimeProfilerCategory::LayoutStyleRecalc |
|
ProfilerCategory::LayoutStyleRecalc |
|
||||||
TimeProfilerCategory::LayoutRestyleDamagePropagation |
|
ProfilerCategory::LayoutRestyleDamagePropagation |
|
||||||
TimeProfilerCategory::LayoutNonIncrementalReset |
|
ProfilerCategory::LayoutNonIncrementalReset |
|
||||||
TimeProfilerCategory::LayoutGeneratedContent |
|
ProfilerCategory::LayoutGeneratedContent |
|
||||||
TimeProfilerCategory::LayoutMain |
|
ProfilerCategory::LayoutMain |
|
||||||
TimeProfilerCategory::LayoutDispListBuild |
|
ProfilerCategory::LayoutDispListBuild |
|
||||||
TimeProfilerCategory::LayoutShaping |
|
ProfilerCategory::LayoutShaping |
|
||||||
TimeProfilerCategory::LayoutDamagePropagate |
|
ProfilerCategory::LayoutDamagePropagate |
|
||||||
TimeProfilerCategory::PaintingPerTile |
|
ProfilerCategory::PaintingPerTile |
|
||||||
TimeProfilerCategory::PaintingPrepBuff => "+ ",
|
ProfilerCategory::PaintingPrepBuff => "+ ",
|
||||||
TimeProfilerCategory::LayoutParallelWarmup |
|
ProfilerCategory::LayoutParallelWarmup |
|
||||||
TimeProfilerCategory::LayoutSelectorMatch |
|
ProfilerCategory::LayoutSelectorMatch |
|
||||||
TimeProfilerCategory::LayoutTreeBuilder => "| + ",
|
ProfilerCategory::LayoutTreeBuilder => "| + ",
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
let name = match *self {
|
let name = match *self {
|
||||||
TimeProfilerCategory::Compositing => "Compositing",
|
ProfilerCategory::Compositing => "Compositing",
|
||||||
TimeProfilerCategory::LayoutPerform => "Layout",
|
ProfilerCategory::LayoutPerform => "Layout",
|
||||||
TimeProfilerCategory::LayoutStyleRecalc => "Style Recalc",
|
ProfilerCategory::LayoutStyleRecalc => "Style Recalc",
|
||||||
TimeProfilerCategory::LayoutRestyleDamagePropagation => "Restyle Damage Propagation",
|
ProfilerCategory::LayoutRestyleDamagePropagation => "Restyle Damage Propagation",
|
||||||
TimeProfilerCategory::LayoutNonIncrementalReset => "Non-incremental reset (temporary)",
|
ProfilerCategory::LayoutNonIncrementalReset => "Non-incremental reset (temporary)",
|
||||||
TimeProfilerCategory::LayoutSelectorMatch => "Selector Matching",
|
ProfilerCategory::LayoutSelectorMatch => "Selector Matching",
|
||||||
TimeProfilerCategory::LayoutTreeBuilder => "Tree Building",
|
ProfilerCategory::LayoutTreeBuilder => "Tree Building",
|
||||||
TimeProfilerCategory::LayoutDamagePropagate => "Damage Propagation",
|
ProfilerCategory::LayoutDamagePropagate => "Damage Propagation",
|
||||||
TimeProfilerCategory::LayoutGeneratedContent => "Generated Content Resolution",
|
ProfilerCategory::LayoutGeneratedContent => "Generated Content Resolution",
|
||||||
TimeProfilerCategory::LayoutMain => "Primary Layout Pass",
|
ProfilerCategory::LayoutMain => "Primary Layout Pass",
|
||||||
TimeProfilerCategory::LayoutParallelWarmup => "Parallel Warmup",
|
ProfilerCategory::LayoutParallelWarmup => "Parallel Warmup",
|
||||||
TimeProfilerCategory::LayoutShaping => "Shaping",
|
ProfilerCategory::LayoutShaping => "Shaping",
|
||||||
TimeProfilerCategory::LayoutDispListBuild => "Display List Construction",
|
ProfilerCategory::LayoutDispListBuild => "Display List Construction",
|
||||||
TimeProfilerCategory::PaintingPerTile => "Painting Per Tile",
|
ProfilerCategory::PaintingPerTile => "Painting Per Tile",
|
||||||
TimeProfilerCategory::PaintingPrepBuff => "Buffer Prep",
|
ProfilerCategory::PaintingPrepBuff => "Buffer Prep",
|
||||||
TimeProfilerCategory::Painting => "Painting",
|
ProfilerCategory::Painting => "Painting",
|
||||||
TimeProfilerCategory::ImageDecoding => "Image Decoding",
|
ProfilerCategory::ImageDecoding => "Image Decoding",
|
||||||
};
|
};
|
||||||
format!("{}{}", padding, name)
|
format!("{}{}", padding, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeProfilerBuckets = BTreeMap<(TimeProfilerCategory, Option<TimerMetadata>), Vec<f64>>;
|
type ProfilerBuckets = BTreeMap<(ProfilerCategory, Option<TimerMetadata>), Vec<f64>>;
|
||||||
|
|
||||||
// back end of the profiler that handles data aggregation and performance metrics
|
// back end of the profiler that handles data aggregation and performance metrics
|
||||||
pub struct TimeProfiler {
|
pub struct Profiler {
|
||||||
pub port: Receiver<TimeProfilerMsg>,
|
pub port: Receiver<ProfilerMsg>,
|
||||||
buckets: TimeProfilerBuckets,
|
buckets: ProfilerBuckets,
|
||||||
pub last_msg: Option<TimeProfilerMsg>,
|
pub last_msg: Option<ProfilerMsg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TimeProfiler {
|
impl Profiler {
|
||||||
pub fn create(period: Option<f64>) -> TimeProfilerChan {
|
pub fn create(period: Option<f64>) -> ProfilerChan {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
match period {
|
match period {
|
||||||
Some(period) => {
|
Some(period) => {
|
||||||
|
@ -154,14 +154,14 @@ impl TimeProfiler {
|
||||||
spawn_named("Time profiler timer".to_owned(), move || {
|
spawn_named("Time profiler timer".to_owned(), move || {
|
||||||
loop {
|
loop {
|
||||||
sleep(period);
|
sleep(period);
|
||||||
if chan.send(TimeProfilerMsg::Print).is_err() {
|
if chan.send(ProfilerMsg::Print).is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Spawn the time profiler.
|
// Spawn the time profiler.
|
||||||
spawn_named("Time profiler".to_owned(), move || {
|
spawn_named("Time profiler".to_owned(), move || {
|
||||||
let mut profiler = TimeProfiler::new(port);
|
let mut profiler = Profiler::new(port);
|
||||||
profiler.start();
|
profiler.start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ impl TimeProfiler {
|
||||||
spawn_named("Time profiler".to_owned(), move || {
|
spawn_named("Time profiler".to_owned(), move || {
|
||||||
loop {
|
loop {
|
||||||
match port.recv() {
|
match port.recv() {
|
||||||
Err(_) | Ok(TimeProfilerMsg::Exit) => break,
|
Err(_) | Ok(ProfilerMsg::Exit) => break,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,11 +178,11 @@ impl TimeProfiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeProfilerChan(chan)
|
ProfilerChan(chan)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(port: Receiver<TimeProfilerMsg>) -> TimeProfiler {
|
pub fn new(port: Receiver<ProfilerMsg>) -> Profiler {
|
||||||
TimeProfiler {
|
Profiler {
|
||||||
port: port,
|
port: port,
|
||||||
buckets: BTreeMap::new(),
|
buckets: BTreeMap::new(),
|
||||||
last_msg: None,
|
last_msg: None,
|
||||||
|
@ -203,7 +203,7 @@ impl TimeProfiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_or_insert(&mut self, k: (TimeProfilerCategory, Option<TimerMetadata>), t: f64) {
|
fn find_or_insert(&mut self, k: (ProfilerCategory, Option<TimerMetadata>), t: f64) {
|
||||||
match self.buckets.get_mut(&k) {
|
match self.buckets.get_mut(&k) {
|
||||||
None => {},
|
None => {},
|
||||||
Some(v) => { v.push(t); return; },
|
Some(v) => { v.push(t); return; },
|
||||||
|
@ -212,15 +212,15 @@ impl TimeProfiler {
|
||||||
self.buckets.insert(k, vec!(t));
|
self.buckets.insert(k, vec!(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(&mut self, msg: TimeProfilerMsg) -> bool {
|
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
||||||
match msg.clone() {
|
match msg.clone() {
|
||||||
TimeProfilerMsg::Time(k, t) => self.find_or_insert(k, t),
|
ProfilerMsg::Time(k, t) => self.find_or_insert(k, t),
|
||||||
TimeProfilerMsg::Print => match self.last_msg {
|
ProfilerMsg::Print => match self.last_msg {
|
||||||
// only print if more data has arrived since the last printout
|
// only print if more data has arrived since the last printout
|
||||||
Some(TimeProfilerMsg::Time(..)) => self.print_buckets(),
|
Some(ProfilerMsg::Time(..)) => self.print_buckets(),
|
||||||
_ => ()
|
_ => ()
|
||||||
},
|
},
|
||||||
TimeProfilerMsg::Exit => return false,
|
ProfilerMsg::Exit => return false,
|
||||||
};
|
};
|
||||||
self.last_msg = Some(msg);
|
self.last_msg = Some(msg);
|
||||||
true
|
true
|
||||||
|
@ -268,9 +268,9 @@ pub enum TimerMetadataReflowType {
|
||||||
|
|
||||||
pub type ProfilerMetadata<'a> = Option<(&'a Url, TimerMetadataFrameType, TimerMetadataReflowType)>;
|
pub type ProfilerMetadata<'a> = Option<(&'a Url, TimerMetadataFrameType, TimerMetadataReflowType)>;
|
||||||
|
|
||||||
pub fn profile<T, F>(category: TimeProfilerCategory,
|
pub fn profile<T, F>(category: ProfilerCategory,
|
||||||
meta: ProfilerMetadata,
|
meta: ProfilerMetadata,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
profiler_chan: ProfilerChan,
|
||||||
callback: F)
|
callback: F)
|
||||||
-> T
|
-> T
|
||||||
where F: FnOnce() -> T
|
where F: FnOnce() -> T
|
||||||
|
@ -285,7 +285,7 @@ pub fn profile<T, F>(category: TimeProfilerCategory,
|
||||||
iframe: iframe == TimerMetadataFrameType::IFrame,
|
iframe: iframe == TimerMetadataFrameType::IFrame,
|
||||||
incremental: reflow_type == TimerMetadataReflowType::Incremental,
|
incremental: reflow_type == TimerMetadataReflowType::Incremental,
|
||||||
});
|
});
|
||||||
time_profiler_chan.send(TimeProfilerMsg::Time((category, meta), ms));
|
profiler_chan.send(ProfilerMsg::Time((category, meta), ms));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use dom::node::LayoutData;
|
||||||
use geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
use msg::constellation_msg::{PipelineExitType, WindowSizeData};
|
use msg::constellation_msg::{PipelineExitType, WindowSizeData};
|
||||||
use profile::mem::{MemoryReporter, MemoryReportsChan};
|
use profile::mem::{Reporter, ReportsChan};
|
||||||
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress};
|
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
|
@ -47,7 +47,7 @@ pub enum Msg {
|
||||||
|
|
||||||
/// Requests that the layout task measure its memory usage. The resulting reports are sent back
|
/// Requests that the layout task measure its memory usage. The resulting reports are sent back
|
||||||
/// via the supplied channel.
|
/// via the supplied channel.
|
||||||
CollectMemoryReports(MemoryReportsChan),
|
CollectReports(ReportsChan),
|
||||||
|
|
||||||
/// Requests that the layout task enter a quiescent state in which no more messages are
|
/// Requests that the layout task enter a quiescent state in which no more messages are
|
||||||
/// accepted except `ExitMsg`. A response message will be sent on the supplied channel when
|
/// accepted except `ExitMsg`. A response message will be sent on the supplied channel when
|
||||||
|
@ -66,7 +66,7 @@ pub enum Msg {
|
||||||
///
|
///
|
||||||
/// 1) read-only with respect to LayoutTaskData,
|
/// 1) read-only with respect to LayoutTaskData,
|
||||||
/// 2) small,
|
/// 2) small,
|
||||||
// 3) and really needs to be fast.
|
/// 3) and really needs to be fast.
|
||||||
pub trait LayoutRPC {
|
pub trait LayoutRPC {
|
||||||
/// Requests the dimensions of the content box, as in the `getBoundingClientRect()` call.
|
/// Requests the dimensions of the content box, as in the `getBoundingClientRect()` call.
|
||||||
fn content_box(&self) -> ContentBoxResponse;
|
fn content_box(&self) -> ContentBoxResponse;
|
||||||
|
@ -133,11 +133,11 @@ impl LayoutChan {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MemoryReporter for LayoutChan {
|
impl Reporter for LayoutChan {
|
||||||
// Just injects an appropriate event into the layout task's queue.
|
// Just injects an appropriate event into the layout task's queue.
|
||||||
fn collect_reports(&self, reports_chan: MemoryReportsChan) -> bool {
|
fn collect_reports(&self, reports_chan: ReportsChan) -> bool {
|
||||||
let LayoutChan(ref c) = *self;
|
let LayoutChan(ref c) = *self;
|
||||||
c.send(Msg::CollectMemoryReports(reports_chan)).is_ok()
|
c.send(Msg::CollectReports(reports_chan)).is_ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ use net::storage_task::{StorageTaskFactory, StorageTask};
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use gfx::font_cache_task::FontCacheTask;
|
use gfx::font_cache_task::FontCacheTask;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use profile::mem::MemoryProfiler;
|
use profile::mem;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use profile::time::TimeProfiler;
|
use profile::time;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use util::opts;
|
use util::opts;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
|
@ -70,8 +70,8 @@ impl Browser {
|
||||||
|
|
||||||
let (compositor_proxy, compositor_receiver) =
|
let (compositor_proxy, compositor_receiver) =
|
||||||
WindowMethods::create_compositor_channel(&window);
|
WindowMethods::create_compositor_channel(&window);
|
||||||
let time_profiler_chan = TimeProfiler::create(opts.time_profiler_period);
|
let time_profiler_chan = time::Profiler::create(opts.time_profiler_period);
|
||||||
let memory_profiler_chan = MemoryProfiler::create(opts.memory_profiler_period);
|
let mem_profiler_chan = mem::Profiler::create(opts.mem_profiler_period);
|
||||||
let devtools_chan = opts.devtools_port.map(|port| {
|
let devtools_chan = opts.devtools_port.map(|port| {
|
||||||
devtools::start_server(port)
|
devtools::start_server(port)
|
||||||
});
|
});
|
||||||
|
@ -100,7 +100,7 @@ impl Browser {
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
time_profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
memory_profiler_chan.clone(),
|
mem_profiler_chan.clone(),
|
||||||
devtools_chan,
|
devtools_chan,
|
||||||
storage_task);
|
storage_task);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ impl Browser {
|
||||||
compositor_receiver,
|
compositor_receiver,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
mem_profiler_chan);
|
||||||
|
|
||||||
Browser {
|
Browser {
|
||||||
compositor: compositor,
|
compositor: compositor,
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub mod linked_list;
|
||||||
pub mod fnv;
|
pub mod fnv;
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
pub mod logical_geometry;
|
pub mod logical_geometry;
|
||||||
pub mod memory;
|
pub mod mem;
|
||||||
pub mod namespace;
|
pub mod namespace;
|
||||||
pub mod opts;
|
pub mod opts;
|
||||||
pub mod persistent_list;
|
pub mod persistent_list;
|
||||||
|
|
|
@ -38,11 +38,11 @@ pub fn heap_size_of(ptr: *const c_void) -> usize {
|
||||||
// FIXME(njn): it would be nice to be able to derive this trait automatically, given that
|
// FIXME(njn): it would be nice to be able to derive this trait automatically, given that
|
||||||
// implementations are mostly repetitive and mechanical.
|
// implementations are mostly repetitive and mechanical.
|
||||||
//
|
//
|
||||||
pub trait SizeOf {
|
pub trait HeapSizeOf {
|
||||||
/// Measure the size of any heap-allocated structures that hang off this value, but not the
|
/// Measure the size of any heap-allocated structures that hang off this value, but not the
|
||||||
/// space taken up by the value itself (i.e. what size_of::<T> measures, more or less); that
|
/// space taken up by the value itself (i.e. what size_of::<T> measures, more or less); that
|
||||||
/// space is handled by the implementation of SizeOf for Box<T> below.
|
/// space is handled by the implementation of HeapSizeOf for Box<T> below.
|
||||||
fn size_of_excluding_self(&self) -> usize;
|
fn heap_size_of_children(&self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are two possible ways to measure the size of `self` when it's on the heap: compute it
|
// There are two possible ways to measure the size of `self` when it's on the heap: compute it
|
||||||
|
@ -60,49 +60,49 @@ pub trait SizeOf {
|
||||||
//
|
//
|
||||||
// However, in the best case, the two approaches should give the same results.
|
// However, in the best case, the two approaches should give the same results.
|
||||||
//
|
//
|
||||||
impl<T: SizeOf> SizeOf for Box<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for Box<T> {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
// Measure size of `self`.
|
// Measure size of `self`.
|
||||||
heap_size_of(&**self as *const T as *const c_void) + (**self).size_of_excluding_self()
|
heap_size_of(&**self as *const T as *const c_void) + (**self).heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SizeOf for String {
|
impl HeapSizeOf for String {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
heap_size_of(self.as_ptr() as *const c_void)
|
heap_size_of(self.as_ptr() as *const c_void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SizeOf> SizeOf for Option<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for Option<T> {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
None => 0,
|
None => 0,
|
||||||
Some(ref x) => x.size_of_excluding_self()
|
Some(ref x) => x.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SizeOf> SizeOf for Arc<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for Arc<T> {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
(**self).size_of_excluding_self()
|
(**self).heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SizeOf> SizeOf for Vec<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for Vec<T> {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
heap_size_of(self.as_ptr() as *const c_void) +
|
heap_size_of(self.as_ptr() as *const c_void) +
|
||||||
self.iter().fold(0, |n, elem| n + elem.size_of_excluding_self())
|
self.iter().fold(0, |n, elem| n + elem.heap_size_of_children())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(njn): We can't implement SizeOf accurately for LinkedList because it requires access to the
|
// FIXME(njn): We can't implement HeapSizeOf accurately for LinkedList because it requires access
|
||||||
// private Node type. Eventually we'll want to add SizeOf (or equivalent) to Rust itself. In the
|
// to the private Node type. Eventually we'll want to add HeapSizeOf (or equivalent) to Rust
|
||||||
// meantime, we use the dirty hack of transmuting LinkedList into an identical type (LinkedList2) and
|
// itself. In the meantime, we use the dirty hack of transmuting LinkedList into an identical type
|
||||||
// measuring that.
|
// (LinkedList2) and measuring that.
|
||||||
impl<T: SizeOf> SizeOf for LinkedList<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for LinkedList<T> {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
let list2: &LinkedList2<T> = unsafe { transmute(self) };
|
let list2: &LinkedList2<T> = unsafe { transmute(self) };
|
||||||
list2.size_of_excluding_self()
|
list2.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,21 +124,21 @@ struct Node<T> {
|
||||||
value: T,
|
value: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SizeOf> SizeOf for Node<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for Node<T> {
|
||||||
// Unlike most size_of_excluding_self() functions, this one does *not* measure descendents.
|
// Unlike most heap_size_of_children() functions, this one does *not* measure descendents.
|
||||||
// Instead, LinkedList2<T>::size_of_excluding_self() handles that, so that it can use iteration
|
// Instead, LinkedList2<T>::heap_size_of_children() handles that, so that it can use iteration
|
||||||
// instead of recursion, which avoids potentially blowing the stack.
|
// instead of recursion, which avoids potentially blowing the stack.
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
self.value.size_of_excluding_self()
|
self.value.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SizeOf> SizeOf for LinkedList2<T> {
|
impl<T: HeapSizeOf> HeapSizeOf for LinkedList2<T> {
|
||||||
fn size_of_excluding_self(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
let mut size = 0;
|
let mut size = 0;
|
||||||
let mut curr: &Link<T> = &self.list_head;
|
let mut curr: &Link<T> = &self.list_head;
|
||||||
while curr.is_some() {
|
while curr.is_some() {
|
||||||
size += (*curr).size_of_excluding_self();
|
size += (*curr).heap_size_of_children();
|
||||||
curr = &curr.as_ref().unwrap().next;
|
curr = &curr.as_ref().unwrap().next;
|
||||||
}
|
}
|
||||||
size
|
size
|
|
@ -47,7 +47,7 @@ pub struct Opts {
|
||||||
|
|
||||||
/// `None` to disable the memory profiler or `Some` with an interval in seconds to enable it
|
/// `None` to disable the memory profiler or `Some` with an interval in seconds to enable it
|
||||||
/// and cause it to produce output on that interval (`-m`).
|
/// and cause it to produce output on that interval (`-m`).
|
||||||
pub memory_profiler_period: Option<f64>,
|
pub mem_profiler_period: Option<f64>,
|
||||||
|
|
||||||
/// Enable experimental web features (`-e`).
|
/// Enable experimental web features (`-e`).
|
||||||
pub enable_experimental: bool,
|
pub enable_experimental: bool,
|
||||||
|
@ -176,7 +176,7 @@ pub fn default_opts() -> Opts {
|
||||||
tile_size: 512,
|
tile_size: 512,
|
||||||
device_pixels_per_px: None,
|
device_pixels_per_px: None,
|
||||||
time_profiler_period: None,
|
time_profiler_period: None,
|
||||||
memory_profiler_period: None,
|
mem_profiler_period: None,
|
||||||
enable_experimental: false,
|
enable_experimental: false,
|
||||||
layout_threads: 1,
|
layout_threads: 1,
|
||||||
nonincremental_layout: false,
|
nonincremental_layout: false,
|
||||||
|
@ -286,7 +286,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
let time_profiler_period = opt_match.opt_default("p", "5").map(|period| {
|
let time_profiler_period = opt_match.opt_default("p", "5").map(|period| {
|
||||||
period.parse().unwrap()
|
period.parse().unwrap()
|
||||||
});
|
});
|
||||||
let memory_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
let mem_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
||||||
period.parse().unwrap()
|
period.parse().unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
tile_size: tile_size,
|
tile_size: tile_size,
|
||||||
device_pixels_per_px: device_pixels_per_px,
|
device_pixels_per_px: device_pixels_per_px,
|
||||||
time_profiler_period: time_profiler_period,
|
time_profiler_period: time_profiler_period,
|
||||||
memory_profiler_period: memory_profiler_period,
|
mem_profiler_period: mem_profiler_period,
|
||||||
enable_experimental: opt_match.opt_present("e"),
|
enable_experimental: opt_match.opt_present("e"),
|
||||||
layout_threads: layout_threads,
|
layout_threads: layout_threads,
|
||||||
nonincremental_layout: nonincremental_layout,
|
nonincremental_layout: nonincremental_layout,
|
||||||
|
|
|
@ -46,9 +46,9 @@ use net::resource_task::new_resource_task;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use gfx::font_cache_task::FontCacheTask;
|
use gfx::font_cache_task::FontCacheTask;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use profile::mem::MemoryProfiler;
|
use profile::mem;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use profile::time::TimeProfiler;
|
use profile::time;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use util::opts;
|
use util::opts;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
|
@ -79,15 +79,15 @@ impl Browser {
|
||||||
|
|
||||||
let (compositor_proxy, compositor_receiver) =
|
let (compositor_proxy, compositor_receiver) =
|
||||||
WindowMethods::create_compositor_channel(&window);
|
WindowMethods::create_compositor_channel(&window);
|
||||||
let time_profiler_chan = TimeProfiler::create(opts.time_profiler_period);
|
let time_profiler_chan = time::Profiler::create(opts.time_profiler_period);
|
||||||
let memory_profiler_chan = MemoryProfiler::create(opts.memory_profiler_period);
|
let mem_profiler_chan = mem::Profiler::create(opts.mem_profiler_period);
|
||||||
let devtools_chan = opts.devtools_port.map(|port| {
|
let devtools_chan = opts.devtools_port.map(|port| {
|
||||||
devtools::start_server(port)
|
devtools::start_server(port)
|
||||||
});
|
});
|
||||||
|
|
||||||
let opts_clone = opts.clone();
|
let opts_clone = opts.clone();
|
||||||
let time_profiler_chan_clone = time_profiler_chan.clone();
|
let time_profiler_chan_clone = time_profiler_chan.clone();
|
||||||
let memory_profiler_chan_clone = memory_profiler_chan.clone();
|
let mem_profiler_chan_clone = mem_profiler_chan.clone();
|
||||||
|
|
||||||
let (result_chan, result_port) = channel();
|
let (result_chan, result_port) = channel();
|
||||||
let compositor_proxy_for_constellation = compositor_proxy.clone_compositor_proxy();
|
let compositor_proxy_for_constellation = compositor_proxy.clone_compositor_proxy();
|
||||||
|
@ -115,7 +115,7 @@ impl Browser {
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
time_profiler_chan_clone,
|
time_profiler_chan_clone,
|
||||||
memory_profiler_chan_clone,
|
mem_profiler_chan_clone,
|
||||||
devtools_chan,
|
devtools_chan,
|
||||||
storage_task);
|
storage_task);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ impl Browser {
|
||||||
compositor_receiver,
|
compositor_receiver,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
mem_profiler_chan);
|
||||||
|
|
||||||
Browser {
|
Browser {
|
||||||
compositor: compositor,
|
compositor: compositor,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue