mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
compositing: Add memory reporter for WebRender. (#36557)
This adds a memory reporter for WebRender's memory usage. I seeded it with a couple entries that looked reasonable based on https://searchfox.org/mozilla-central/rev/2c71f1e9b5947612abdc16b64008162c58c1b9d3/gfx/thebes/gfxPlatform.cpp#722-738. Testing: Verified that new numbers appear in about:memory for servo.org. The new images category is surprisingly large (40mb). Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
afe98e9e1e
commit
af000d6c91
9 changed files with 98 additions and 8 deletions
|
@ -35,6 +35,7 @@ net = { path = "../net" }
|
|||
pixels = { path = "../pixels" }
|
||||
profile_traits = { workspace = true }
|
||||
script_traits = { workspace = true }
|
||||
servo_allocator = { path = "../allocator" }
|
||||
servo_config = { path = "../config" }
|
||||
servo_geometry = { path = "../geometry" }
|
||||
stylo_traits = { workspace = true }
|
||||
|
@ -42,6 +43,7 @@ tracing = { workspace = true, optional = true }
|
|||
webrender = { workspace = true }
|
||||
webrender_api = { workspace = true }
|
||||
webxr = { path = "../webxr", optional = true }
|
||||
wr_malloc_size_of = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
surfman = { workspace = true }
|
||||
|
|
|
@ -34,8 +34,9 @@ use ipc_channel::ipc::{self, IpcSharedMemory};
|
|||
use libc::c_void;
|
||||
use log::{debug, info, trace, warn};
|
||||
use pixels::{CorsStatus, Image, ImageFrame, PixelFormat};
|
||||
use profile_traits::mem::{ProcessReports, ProfilerRegistration, Report, ReportKind};
|
||||
use profile_traits::time::{self as profile_time, ProfilerCategory};
|
||||
use profile_traits::time_profile;
|
||||
use profile_traits::{path, time_profile};
|
||||
use servo_config::opts;
|
||||
use servo_geometry::DeviceIndependentPixel;
|
||||
use style_traits::CSSPixel;
|
||||
|
@ -147,6 +148,10 @@ pub struct IOCompositor {
|
|||
/// The [`Instant`] of the last animation tick, used to avoid flooding the Constellation and
|
||||
/// ScriptThread with a deluge of animation ticks.
|
||||
last_animation_tick: Instant,
|
||||
|
||||
/// A handle to the memory profiler which will automatically unregister
|
||||
/// when it's dropped.
|
||||
_mem_profiler_registration: ProfilerRegistration,
|
||||
}
|
||||
|
||||
/// Why we need to be repainted. This is used for debugging.
|
||||
|
@ -391,6 +396,11 @@ impl ServoRenderer {
|
|||
|
||||
impl IOCompositor {
|
||||
pub fn new(state: InitialCompositorState, convert_mouse_to_touch: bool) -> Self {
|
||||
let registration = state.mem_profiler_chan.prepare_memory_reporting(
|
||||
"compositor".into(),
|
||||
state.sender.clone(),
|
||||
CompositorMsg::CollectMemoryReport,
|
||||
);
|
||||
let compositor = IOCompositor {
|
||||
global: Rc::new(RefCell::new(ServoRenderer {
|
||||
shutdown_state: state.shutdown_state,
|
||||
|
@ -414,6 +424,7 @@ impl IOCompositor {
|
|||
rendering_context: state.rendering_context,
|
||||
pending_frames: 0,
|
||||
last_animation_tick: Instant::now(),
|
||||
_mem_profiler_registration: registration,
|
||||
};
|
||||
|
||||
{
|
||||
|
@ -496,6 +507,30 @@ impl IOCompositor {
|
|||
}
|
||||
|
||||
match msg {
|
||||
CompositorMsg::CollectMemoryReport(sender) => {
|
||||
let ops =
|
||||
wr_malloc_size_of::MallocSizeOfOps::new(servo_allocator::usable_size, None);
|
||||
let report = self.global.borrow().webrender_api.report_memory(ops);
|
||||
let reports = vec![
|
||||
Report {
|
||||
path: path!["webrender", "fonts"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: report.fonts,
|
||||
},
|
||||
Report {
|
||||
path: path!["webrender", "images"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: report.images,
|
||||
},
|
||||
Report {
|
||||
path: path!["webrender", "display-list"],
|
||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||
size: report.display_list,
|
||||
},
|
||||
];
|
||||
sender.send(ProcessReports::new(reports));
|
||||
},
|
||||
|
||||
CompositorMsg::ChangeRunningAnimationsState(
|
||||
webview_id,
|
||||
pipeline_id,
|
||||
|
|
|
@ -57,6 +57,7 @@ mod from_constellation {
|
|||
Self::GetClientWindowRect(..) => target!("GetClientWindowRect"),
|
||||
Self::GetScreenSize(..) => target!("GetScreenSize"),
|
||||
Self::GetAvailableScreenSize(..) => target!("GetAvailableScreenSize"),
|
||||
Self::CollectMemoryReport(..) => target!("CollectMemoryReport"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue