fix trace seection when no instance was found, comments++

This commit is contained in:
Alwin Berger 2024-10-09 16:16:04 +02:00
parent 66a87835be
commit d4ee679d0e

View File

@ -268,7 +268,8 @@ pub type GraphMaximizerCorpusScheduler<CS, O> =
MinimizerScheduler<CS, MaxTimeFavFactor<<CS as UsesState>::State>,STGNodeMetadata,O>; MinimizerScheduler<CS, MaxTimeFavFactor<<CS as UsesState>::State>,STGNodeMetadata,O>;
// AI generated, human verified // AI generated, human verified
fn count_occurrences<T>(vec: &Vec<T>) -> HashMap<&T, usize> /// Count the occurrences of each element in a vector, assumes the vector is sorted
fn count_occurrences_sorted<T>(vec: &Vec<T>) -> HashMap<&T, usize>
where where
T: PartialEq + Eq + Hash + Clone, T: PartialEq + Eq + Hash + Clone,
{ {
@ -550,7 +551,11 @@ where
let t = observer.last_trace.iter().filter(|x| x.start_tick < worst_instance.1 && x.end_tick > worst_instance.0 ).cloned().collect(); let t = observer.last_trace.iter().filter(|x| x.start_tick < worst_instance.1 && x.end_tick > worst_instance.0 ).cloned().collect();
StgFeedback::abbs_in_exec_order(&t) StgFeedback::abbs_in_exec_order(&t)
} else { } else {
StgFeedback::abbs_in_exec_order(&observer.last_trace) if observer.select_task.is_none() { // if nothing was selected, just take the whole trace, otherwise there is nothing interesting here
StgFeedback::abbs_in_exec_order(&observer.last_trace)
} else {
Vec::new()
}
} }
}; };
if INTEREST_AGGREGATE || INTEREST_ABBPATH { if INTEREST_AGGREGATE || INTEREST_ABBPATH {
@ -572,8 +577,8 @@ where
if INTEREST_AGGREGATE { if INTEREST_AGGREGATE {
// aggegation by sorting, order of states is not relevant // aggegation by sorting, order of states is not relevant
let mut _tmp = tmp.clone(); let mut _tmp = tmp.clone();
_tmp.sort(); _tmp.sort(); // use sort+count, because we need the sorted trace anyways
let counts = count_occurrences(&_tmp); let counts = count_occurrences_sorted(&_tmp);
let mut top_indices = Vec::new(); let mut top_indices = Vec::new();
for (k,c) in counts { for (k,c) in counts {
if let Some(reference) = feedbackstate.worst_abb_exec_count.get_mut(k) { if let Some(reference) = feedbackstate.worst_abb_exec_count.get_mut(k) {