Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hkctkuy committed Nov 2, 2023
1 parent cbccef9 commit 95eca0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
27 changes: 7 additions & 20 deletions casr/src/bin/casr-cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ fn stacktrace(path: &Path) -> Result<Stacktrace> {
}
}

/// Extract crashline from casr report
///
/// # Arguments
///
/// * `path` - path to the casrep
///
/// # Return value
///
/// Crashlie as a String
fn crashline(path: &Path) -> Result<String> {
Ok(util::report_from_file(path)?.crashline)
}

/// Perform the clustering of casreps
///
/// # Arguments
Expand Down Expand Up @@ -93,14 +80,14 @@ fn make_clusters(inpath: &Path, outpath: Option<&Path>, jobs: usize, dedup: bool
let mut badreports: RwLock<Vec<PathBuf>> = RwLock::new(Vec::new());
custom_pool.install(|| {
(0..len).into_par_iter().for_each(|i| {
if let Ok(trace) = stacktrace(casreps[i].as_path()) {
traces.write().unwrap().push(trace);
filtered_casreps.write().unwrap().push(casreps[i].clone());
if let Ok(report) = util::report_from_file(casreps[i].as_path()) {
if let Ok(trace) = report.filtered_stacktrace() {
traces.write().unwrap().push(trace);
filtered_casreps.write().unwrap().push(casreps[i].clone());
}
// TODO: Try to avoid of checking same cond
if dedup {
if let Ok(crashline) = crashline(casreps[i].as_path()) {
crashlines.write().unwrap().push(crashline);
}
crashlines.write().unwrap().push(report.crashline);
}
} else {
badreports.write().unwrap().push(casreps[i].clone());
Expand Down Expand Up @@ -141,7 +128,7 @@ fn make_clusters(inpath: &Path, outpath: Option<&Path>, jobs: usize, dedup: bool

// Get clusters with crashline deduplication
if dedup {
clusters = dedup_crashlines(&crashlines, clusters, cluster_cnt)?;
clusters = dedup_crashlines(&crashlines, clusters)?;
}

for i in 0..clusters.len() {
Expand Down
8 changes: 3 additions & 5 deletions libcasr/src/stacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,11 @@ pub fn cluster_stacktraces(stacktraces: &[Stacktrace]) -> Result<Vec<usize>> {
/// An vector of the same length as `crashlines`.
/// Vec\[i\] is the flat cluster number to which original casrep i belongs,
/// if Vec\[i\] is 0, casrep crashline is duplicate of some other
pub fn dedup_crashlines(
crashlines: &[String],
clusters: Vec<usize>,
cluster_num: usize,
) -> Result<Vec<usize>> {
pub fn dedup_crashlines(crashlines: &[String], clusters: Vec<usize>) -> Result<Vec<usize>> {
// Init cluster vec with crashline dedup
let mut dedup_clusters = vec![0; crashlines.len()];
// Count number of clusters
let cluster_num: usize = *clusters.iter().max().unwrap();
// Init dedup crashline list for each cluster
let mut unique_crashlines: Vec<HashSet<String>> = vec![HashSet::new(); cluster_num];

Expand Down

0 comments on commit 95eca0b

Please sign in to comment.