don't refresh system stats when only reporting process stats (#784)

This commit is contained in:
bmc-msft
2021-04-09 14:12:13 -04:00
committed by GitHub
parent 4086e7695e
commit 4f6432bdc3
2 changed files with 16 additions and 4 deletions

View File

@ -301,12 +301,15 @@ fn try_report_iter_update(
}
async fn report_fuzzer_sys_info(worker_id: usize, run_id: Uuid, fuzzer_pid: u32) -> Result<()> {
loop {
system::refresh()?;
// Allow for sampling CPU usage.
time::delay_for(PROC_INFO_COLLECTION_DELAY).await;
loop {
// process doesn't exist
if !system::refresh_process(fuzzer_pid)? {
break;
}
if let Some(proc_info) = system::proc_info(fuzzer_pid)? {
event!(process_stats;
EventData::WorkerId = worker_id,

View File

@ -22,6 +22,11 @@ pub fn proc_info(pid: u32) -> Result<Option<ProcInfo>> {
Ok(s.proc_info(pid))
}
pub fn refresh_process(pid: u32) -> Result<bool> {
let mut s = SYSTEM.write().map_err(|e| format_err!("{}", e))?;
Ok(s.refresh_process(pid))
}
lazy_static! {
static ref SYSTEM: RwLock<System> = {
let mut s = System::new();
@ -56,6 +61,10 @@ impl System {
self.system.refresh_all();
}
pub fn refresh_process(&mut self, pid: u32) -> bool {
self.system.refresh_process(pid as Pid)
}
pub fn system_info(&self) -> SystemInfo {
let system = &self.system;