diff options
author | webbeef <me@webbeef.org> | 2025-03-06 21:25:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-07 05:25:08 +0000 |
commit | 139774e6b55c297bc94f7fcb8c9bf5bb8c6a7474 (patch) | |
tree | 70f425d369998013ca8ed559a6719a6c280f7378 /components/shared/profile/mem.rs | |
parent | 1864ebfb357cdf4ac6f97d53c5f74f989f08b2ec (diff) | |
download | servo-139774e6b55c297bc94f7fcb8c9bf5bb8c6a7474.tar.gz servo-139774e6b55c297bc94f7fcb8c9bf5bb8c6a7474.zip |
Add an about:memory page (#35728)
This patch exposes a servo internal DOM API that is only made available to about:
pages on the navigator object to request memory reports. The about:memory page itself is
loaded like other html resources (eg. bad cert, net error) and makes use of this new API.
On the implementation side, notable changes:
- components/script/routed_promise.rs abstracts the setup used to fulfill a promise when the
work needs to be routed through the constellation. The goal is to migrate other similar
promise APIs in followup (eg. dom/webgpu/gpu.rs, bluetooth.rs).
- a new message is added to request a report from the memory reporter, and the memory reporter
creates a json representation of the set of memory reports.
- the post-processing of memory reports is done in Javascript in the about-memory.html page,
providing the same results as the current Rust code that outputs to stdout. We can decide
later if we want to remove the current output.
Signed-off-by: webbeef <me@webbeef.org>
Diffstat (limited to 'components/shared/profile/mem.rs')
-rw-r--r-- | components/shared/profile/mem.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/components/shared/profile/mem.rs b/components/shared/profile/mem.rs index 5b92d2eee17..f2d67dec43b 100644 --- a/components/shared/profile/mem.rs +++ b/components/shared/profile/mem.rs @@ -190,6 +190,13 @@ macro_rules! path { }} } +/// The results produced by the memory reporter. +#[derive(Debug, Deserialize, Serialize)] +pub struct MemoryReportResult { + /// The stringified output. + pub content: String, +} + /// Messages that can be sent to the memory profiler thread. #[derive(Debug, Deserialize, Serialize)] pub enum ProfilerMsg { @@ -208,4 +215,7 @@ pub enum ProfilerMsg { /// Tells the memory profiler to shut down. Exit, + + /// Triggers sending back the memory profiling metrics, + Report(IpcSender<MemoryReportResult>), } |