aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_interface.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2015-03-10 21:01:05 -0700
committerNicholas Nethercote <nnethercote@mozilla.com>2015-03-16 18:12:26 -0700
commitece2711185cffa8ade21b0ab9538bc1be79cadb9 (patch)
tree5870d8186ce791809ad1afcf65886767ea871a6b /components/script/layout_interface.rs
parent5865d5f71776336d8f55dcb326d1fb24279bbf63 (diff)
downloadservo-ece2711185cffa8ade21b0ab9538bc1be79cadb9.tar.gz
servo-ece2711185cffa8ade21b0ab9538bc1be79cadb9.zip
Add memory reporting infrastructure and use it to measure the display list.
This changeset implements the beginnings of fine-grained measurement of Servo's data structures. - It adds a new `SizeOf` trait, which is used to measure the memory used by heap data structures, and implements it for some std types: Box, String, Option, Arc, Vec, and DList. - It adds a new `MemoryReporter` trait which is used to report memory measurements from other threads to the memory profiler. Reporters are registered and unregistered with the memory profiler, and the memory profiler makes measurement requests of reporters when necessary. - It plumbs a MemoryProfilerChan through to the layout task so it can register a memory reporter. - It implements the `SizeOf` trait for `DisplayList` and associated types, and adds a memory reporter that uses it. The display list hits 14.77 MiB when viewing tests/html/perf-rainbow.html, and 2.51 MiB when viewing the Guardians of the Galaxy Wikipedia page from servo-static-suite. Example output: 0.29: display-list::http://www.reddit.com/ 0.00: display-list::http://static.adzerk.net/reddit/ads.html?sr=-reddit.com,loggedout&bust2#http://www.reddit.com 0.00: display-list::http://www.reddit.com/static/createadframe.html There are a number of FIXME comments indicating sub-optimal things. This is a big enough change for now that doing them as follow-ups seems best.
Diffstat (limited to 'components/script/layout_interface.rs')
-rw-r--r--components/script/layout_interface.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs
index e6e448dd800..52b5aed1b43 100644
--- a/components/script/layout_interface.rs
+++ b/components/script/layout_interface.rs
@@ -13,6 +13,7 @@ use geom::rect::Rect;
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress};
use msg::constellation_msg::{PipelineExitType, WindowSizeData};
use util::geometry::Au;
+use util::memory::{MemoryReporter, MemoryReportsChan};
use std::any::Any;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::boxed::BoxAny;
@@ -44,6 +45,10 @@ pub enum Msg {
/// TODO(pcwalton): Maybe think about batching to avoid message traffic.
ReapLayoutData(LayoutData),
+ /// Requests that the layout task measure its memory usage. The resulting reports are sent back
+ /// via the supplied channel.
+ CollectMemoryReports(MemoryReportsChan),
+
/// 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
/// this happens.
@@ -128,6 +133,14 @@ impl LayoutChan {
}
}
+impl MemoryReporter for LayoutChan {
+ // Just injects an appropriate event into the layout task's queue.
+ fn collect_reports(&self, reports_chan: MemoryReportsChan) -> bool {
+ let LayoutChan(ref c) = *self;
+ c.send(Msg::CollectMemoryReports(reports_chan)).is_ok()
+ }
+}
+
/// A trait to manage opaque references to script<->layout channels without needing
/// to expose the message type to crates that don't need to know about them.
pub trait ScriptLayoutChan {