Skip to content

Commit e298346

Browse files
fix(server): isolate process table from snapshot CPU baseline
1 parent 5070ec1 commit e298346

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎native/resource-monitor/src/main.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,16 @@ impl Collector {
374374
self.cpu_baseline_refreshed_at = Some(Instant::now());
375375
}
376376

377-
fn process_table(&mut self) -> Vec<ProcessTableEntry> {
378-
self.system.refresh_processes_specifics(
377+
fn process_table(&self) -> Vec<ProcessTableEntry> {
378+
// Use a dedicated System so this refresh cannot reset the CPU
379+
// baseline tracked by self.system for snapshots.
380+
let mut process_table_system = System::new();
381+
process_table_system.refresh_processes_specifics(
379382
ProcessesToUpdate::All,
380383
true,
381384
ProcessRefreshKind::nothing().without_tasks(),
382385
);
383-
let mut processes = self
384-
.system
386+
let mut processes = process_table_system
385387
.processes()
386388
.iter()
387389
.filter_map(|(pid, process)| {

0 commit comments

Comments
 (0)