Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Remove in-agent tracking of child process perf stats #1608

Merged
merged 4 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 1 addition & 60 deletions src/agent/onefuzz-agent/src/tasks/fuzz/libfuzzer_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,21 @@ use onefuzz::{
libfuzzer::{LibFuzzer, LibFuzzerLine},
process::ExitStatus,
syncdir::{continuous_sync, SyncOperation::Pull, SyncedDir},
system,
};
use onefuzz_telemetry::{
Event::{new_coverage, new_result, process_stats, runtime_stats},
Event::{new_coverage, new_result, runtime_stats},
EventData,
};
use serde::Deserialize;
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use tempfile::{tempdir_in, TempDir};
use tokio::{
io::{AsyncBufReadExt, BufReader},
select,
sync::{mpsc, Notify},
task,
time::{sleep, Duration, Instant},
};
use uuid::Uuid;

// Delay to allow for observation of CPU usage when reporting proc info.
const PROC_INFO_COLLECTION_DELAY: Duration = Duration::from_secs(1);

// Period of reporting proc info about running processes.
const PROC_INFO_PERIOD: Duration = Duration::from_secs(30);

// Period of reporting fuzzer-generated runtime stats.
const RUNTIME_STATS_PERIOD: Duration = Duration::from_secs(60);

Expand Down Expand Up @@ -223,14 +214,7 @@ impl LibFuzzerFuzzTask {
&self.config.common.setup_dir,
);
let mut running = fuzzer.fuzz(crash_dir.path(), local_inputs, &inputs).await?;
let running_id = running.id();
let notify = Arc::new(Notify::new());
let sys_info = task::spawn(report_fuzzer_sys_info(
worker_id,
run_id,
running_id.unwrap_or_default(),
notify.clone(),
));

// Splitting borrow.
let stderr = running
Expand All @@ -257,7 +241,6 @@ impl LibFuzzerFuzzTask {

let exit_status = running.wait().await;
notify.notify_one();
let _ = sys_info.await;

let exit_status: ExitStatus = exit_status?.into();

Expand Down Expand Up @@ -338,48 +321,6 @@ fn try_report_iter_update(
Ok(())
}

async fn report_fuzzer_sys_info(
worker_id: usize,
run_id: Uuid,
fuzzer_pid: u32,
cancellation: Arc<Notify>,
) -> Result<()> {
// Allow for sampling CPU usage.
let mut period = tokio::time::interval_at(
Instant::now() + PROC_INFO_COLLECTION_DELAY,
PROC_INFO_PERIOD,
);
loop {
select! {
() = cancellation.notified() => break,
_ = period.tick() => (),
}

// 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,
EventData::RunId = run_id,
EventData::Name = proc_info.name,
EventData::Pid = proc_info.pid,
EventData::ProcessStatus = proc_info.status,
EventData::CpuUsage = proc_info.cpu_usage,
EventData::PhysicalMemory = proc_info.memory_kb,
EventData::VirtualMemory = proc_info.virtual_memory_kb
);
} else {
// The process no longer exists.
break;
}
}

Ok(())
}

#[derive(Clone, Debug)]
pub struct RuntimeStats {
worker_id: usize,
Expand Down
2 changes: 0 additions & 2 deletions src/agent/onefuzz-telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ pub enum Event {
new_result,
new_coverage,
runtime_stats,
process_stats,
new_report,
new_unique_report,
new_unable_to_reproduce,
Expand All @@ -110,7 +109,6 @@ impl Event {
Self::new_coverage => "new_coverage",
Self::new_result => "new_result",
Self::runtime_stats => "runtime_stats",
Self::process_stats => "process_stats",
Self::new_report => "new_report",
Self::new_unique_report => "new_unique_report",
Self::new_unable_to_reproduce => "new_unable_to_reproduce",
Expand Down
1 change: 0 additions & 1 deletion src/agent/onefuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ serde = "1.0"
serde_json = "1.0"
rand = "0.8"
serde_derive = "1.0"
sysinfo = "0.21"
tokio = { version = "1.15", features = ["full"] }
tokio-stream = { version = "0.1", features = ["fs", "time", "tokio-util"] }
tokio-util = { version = "0.6", features = ["full"] }
Expand Down
4 changes: 0 additions & 4 deletions src/agent/onefuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#[macro_use]
extern crate anyhow;

#[macro_use]
extern crate lazy_static;

#[macro_use]
extern crate onefuzz_telemetry;

Expand All @@ -27,7 +24,6 @@ pub mod monitor;
pub mod process;
pub mod sha256;
pub mod syncdir;
pub mod system;
pub mod utils;

#[cfg(target_os = "linux")]
Expand Down
143 changes: 0 additions & 143 deletions src/agent/onefuzz/src/system.rs

This file was deleted.