mirror of
https://github.com/servo/servo.git
synced 2025-08-29 17:18:23 +01:00
Add scroll tree measurement in IOCompositor (#38922)
Adds a new memory report that aggregates the size of all scroll trees from within all pipelines for each web view. Testing: Acessing `about:memory` Fixes: #38726 --------- Signed-off-by: criskell <96352451+criskell@users.noreply.github.com>
This commit is contained in:
parent
55be274777
commit
7339e2b421
5 changed files with 38 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1409,6 +1409,7 @@ dependencies = [
|
||||||
"servo_allocator",
|
"servo_allocator",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
"servo_geometry",
|
"servo_geometry",
|
||||||
|
"servo_malloc_size_of",
|
||||||
"stylo_traits",
|
"stylo_traits",
|
||||||
"surfman",
|
"surfman",
|
||||||
"timers",
|
"timers",
|
||||||
|
|
|
@ -35,6 +35,7 @@ gleam = { workspace = true }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
|
malloc_size_of = { workspace = true }
|
||||||
pixels = { path = "../pixels" }
|
pixels = { path = "../pixels" }
|
||||||
profile_traits = { workspace = true }
|
profile_traits = { workspace = true }
|
||||||
servo_allocator = { path = "../allocator" }
|
servo_allocator = { path = "../allocator" }
|
||||||
|
|
|
@ -29,7 +29,9 @@ use euclid::{Point2D, Rect, Scale, Size2D, Transform3D};
|
||||||
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
|
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
|
||||||
use log::{debug, info, trace, warn};
|
use log::{debug, info, trace, warn};
|
||||||
use pixels::{CorsStatus, ImageFrame, ImageMetadata, PixelFormat, RasterImage};
|
use pixels::{CorsStatus, ImageFrame, ImageMetadata, PixelFormat, RasterImage};
|
||||||
use profile_traits::mem::{ProcessReports, ProfilerRegistration, Report, ReportKind};
|
use profile_traits::mem::{
|
||||||
|
ProcessReports, ProfilerRegistration, Report, ReportKind, perform_memory_report,
|
||||||
|
};
|
||||||
use profile_traits::time::{self as profile_time, ProfilerCategory};
|
use profile_traits::time::{self as profile_time, ProfilerCategory};
|
||||||
use profile_traits::{path, time_profile};
|
use profile_traits::{path, time_profile};
|
||||||
use servo_config::{opts, pref};
|
use servo_config::{opts, pref};
|
||||||
|
@ -421,7 +423,7 @@ impl IOCompositor {
|
||||||
let ops =
|
let ops =
|
||||||
wr_malloc_size_of::MallocSizeOfOps::new(servo_allocator::usable_size, None);
|
wr_malloc_size_of::MallocSizeOfOps::new(servo_allocator::usable_size, None);
|
||||||
let report = self.global.borrow().webrender_api.report_memory(ops);
|
let report = self.global.borrow().webrender_api.report_memory(ops);
|
||||||
let reports = vec![
|
let mut reports = vec![
|
||||||
Report {
|
Report {
|
||||||
path: path!["webrender", "fonts"],
|
path: path!["webrender", "fonts"],
|
||||||
kind: ReportKind::ExplicitJemallocHeapSize,
|
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||||
|
@ -438,6 +440,15 @@ impl IOCompositor {
|
||||||
size: report.display_list,
|
size: report.display_list,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
perform_memory_report(|ops| {
|
||||||
|
reports.push(Report {
|
||||||
|
path: path!["compositor", "scroll-tree"],
|
||||||
|
kind: ReportKind::ExplicitJemallocHeapSize,
|
||||||
|
size: self.webview_renderers.scroll_trees_memory_usage(ops),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
sender.send(ProcessReports::new(reports));
|
sender.send(ProcessReports::new(reports));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::collections::hash_map::{Entry, Values, ValuesMut};
|
||||||
|
|
||||||
use base::id::WebViewId;
|
use base::id::WebViewId;
|
||||||
|
|
||||||
use crate::webview_renderer::UnknownWebView;
|
use crate::webview_renderer::{UnknownWebView, WebViewRenderer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WebViewManager<WebView> {
|
pub struct WebViewManager<WebView> {
|
||||||
|
@ -109,6 +109,17 @@ impl<WebView> WebViewManager<WebView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl WebViewManager<WebViewRenderer> {
|
||||||
|
pub(crate) fn scroll_trees_memory_usage(
|
||||||
|
&self,
|
||||||
|
ops: &mut malloc_size_of::MallocSizeOfOps,
|
||||||
|
) -> usize {
|
||||||
|
self.iter()
|
||||||
|
.map(|renderer| renderer.scroll_trees_memory_usage(ops))
|
||||||
|
.sum::<usize>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use base::id::{BrowsingContextId, Index, PipelineNamespace, PipelineNamespaceId, WebViewId};
|
use base::id::{BrowsingContextId, Index, PipelineNamespace, PipelineNamespaceId, WebViewId};
|
||||||
|
|
|
@ -22,6 +22,7 @@ use embedder_traits::{
|
||||||
use euclid::{Point2D, Scale, Vector2D};
|
use euclid::{Point2D, Scale, Vector2D};
|
||||||
use fnv::FnvHashSet;
|
use fnv::FnvHashSet;
|
||||||
use log::{debug, warn};
|
use log::{debug, warn};
|
||||||
|
use malloc_size_of::MallocSizeOf;
|
||||||
use servo_geometry::DeviceIndependentPixel;
|
use servo_geometry::DeviceIndependentPixel;
|
||||||
use style_traits::{CSSPixel, PinchZoomFactor};
|
use style_traits::{CSSPixel, PinchZoomFactor};
|
||||||
use webrender_api::units::{DeviceIntPoint, DevicePixel, DevicePoint, DeviceRect, LayoutVector2D};
|
use webrender_api::units::{DeviceIntPoint, DevicePixel, DevicePoint, DeviceRect, LayoutVector2D};
|
||||||
|
@ -1001,6 +1002,16 @@ impl WebViewRenderer {
|
||||||
));
|
));
|
||||||
self.viewport_description = Some(viewport_description);
|
self.viewport_description = Some(viewport_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn scroll_trees_memory_usage(
|
||||||
|
&self,
|
||||||
|
ops: &mut malloc_size_of::MallocSizeOfOps,
|
||||||
|
) -> usize {
|
||||||
|
self.pipelines
|
||||||
|
.values()
|
||||||
|
.map(|pipeline| pipeline.scroll_tree.size_of(ops))
|
||||||
|
.sum::<usize>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue