Clean up samplig_rate, add docs (#2228)
* Clean up samplig_rate, add docs * clippy
This commit is contained in:
parent
aa47a5c5e6
commit
123f508fcc
@ -290,8 +290,7 @@ where
|
|||||||
scheduler: CS,
|
scheduler: CS,
|
||||||
feedback: F,
|
feedback: F,
|
||||||
objective: OF,
|
objective: OF,
|
||||||
num_testcases: u64,
|
testcase_sampling_rate: Option<u32>,
|
||||||
testcase_sampling_rate: Option<u64>,
|
|
||||||
phantom: PhantomData<OT>,
|
phantom: PhantomData<OT>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +449,7 @@ where
|
|||||||
exec_res: &ExecuteInputResult,
|
exec_res: &ExecuteInputResult,
|
||||||
observers: &OT,
|
observers: &OT,
|
||||||
exit_kind: &ExitKind,
|
exit_kind: &ExitKind,
|
||||||
send_events: bool,
|
mut send_events: bool,
|
||||||
) -> Result<Option<CorpusId>, Error>
|
) -> Result<Option<CorpusId>, Error>
|
||||||
where
|
where
|
||||||
EM: EventFirer<State = Self::State>,
|
EM: EventFirer<State = Self::State>,
|
||||||
@ -472,12 +471,11 @@ where
|
|||||||
let idx = state.corpus_mut().add(testcase)?;
|
let idx = state.corpus_mut().add(testcase)?;
|
||||||
self.scheduler_mut().on_add(state, idx)?;
|
self.scheduler_mut().on_add(state, idx)?;
|
||||||
|
|
||||||
self.num_testcases += 1;
|
let corpus_count = state.corpus().count();
|
||||||
let send_events = if let Some(sampling_rate) = self.testcase_sampling_rate {
|
|
||||||
send_events && self.num_testcases % sampling_rate == 0
|
if let Some(sampling_rate) = self.testcase_sampling_rate {
|
||||||
} else {
|
send_events &= corpus_count % usize::try_from(sampling_rate).unwrap() == 0;
|
||||||
send_events
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if send_events {
|
if send_events {
|
||||||
// TODO set None for fast targets
|
// TODO set None for fast targets
|
||||||
@ -779,24 +777,26 @@ where
|
|||||||
scheduler,
|
scheduler,
|
||||||
feedback,
|
feedback,
|
||||||
objective,
|
objective,
|
||||||
num_testcases: 0,
|
|
||||||
testcase_sampling_rate: None,
|
testcase_sampling_rate: None,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new `StdFuzzer` with a specified `TestCase` sampling rate
|
/// Create a new `StdFuzzer` with a specified `TestCase` sampling rate
|
||||||
|
/// Only every nth testcase will be forwarded to via the event manager.
|
||||||
|
/// This method is useful if you scale to a very large amount of cores
|
||||||
|
/// and a the central broker cannot keep up with the pressure,
|
||||||
|
/// or if you specifically want to have cores explore different branches.
|
||||||
pub fn with_sampling_rate(
|
pub fn with_sampling_rate(
|
||||||
scheduler: CS,
|
scheduler: CS,
|
||||||
feedback: F,
|
feedback: F,
|
||||||
objective: OF,
|
objective: OF,
|
||||||
sampling_rate: u64,
|
sampling_rate: u32,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
scheduler,
|
scheduler,
|
||||||
feedback,
|
feedback,
|
||||||
objective,
|
objective,
|
||||||
num_testcases: 0,
|
|
||||||
testcase_sampling_rate: Some(sampling_rate),
|
testcase_sampling_rate: Some(sampling_rate),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user