mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Make the memory reporting multi-process aware (#35863)
So far the memory reporter aggregates reports from all processes, and runs the system reporter only in the main process. Instead it is desirable to have per-process reports. We do so by: - creating a ProcessReports struct that holds includes the pid in addition to the reports themselves. - running the system memory reporter also in content processes. - updating the about:memory page to create one report per process, and add useful information like the pid and the urls loaded in a given process. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors  Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
76edcff202
commit
aef8537d75
15 changed files with 551 additions and 424 deletions
|
@ -6,6 +6,7 @@ use std::process::Child;
|
|||
|
||||
use crossbeam_channel::{Receiver, Select};
|
||||
use log::{debug, warn};
|
||||
use profile_traits::mem::{ProfilerChan, ProfilerMsg};
|
||||
|
||||
pub enum Process {
|
||||
Unsandboxed(Child),
|
||||
|
@ -37,11 +38,15 @@ type ProcessReceiver = Receiver<Result<(), ipc_channel::Error>>;
|
|||
|
||||
pub(crate) struct ProcessManager {
|
||||
processes: Vec<(Process, ProcessReceiver)>,
|
||||
mem_profiler_chan: ProfilerChan,
|
||||
}
|
||||
|
||||
impl ProcessManager {
|
||||
pub fn new() -> Self {
|
||||
Self { processes: vec![] }
|
||||
pub fn new(mem_profiler_chan: ProfilerChan) -> Self {
|
||||
Self {
|
||||
processes: vec![],
|
||||
mem_profiler_chan,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add(&mut self, receiver: ProcessReceiver, process: Process) {
|
||||
|
@ -63,6 +68,12 @@ impl ProcessManager {
|
|||
pub fn remove(&mut self, index: usize) {
|
||||
let (mut process, _) = self.processes.swap_remove(index);
|
||||
debug!("Removing process pid={}", process.pid());
|
||||
// Unregister this process system memory profiler
|
||||
self.mem_profiler_chan
|
||||
.send(ProfilerMsg::UnregisterReporter(format!(
|
||||
"system-content-{}",
|
||||
process.pid()
|
||||
)));
|
||||
process.wait();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue