Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rayon dependency of cranelift-isle #5101

Merged
merged 1 commit into from
Oct 23, 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
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion cranelift/isle/isle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ version = "0.90.0"
[dependencies]
log = { workspace = true, optional = true }
miette = { version = "5.1.0", optional = true }
rayon = "^1.5"

[dev-dependencies]
tempfile = "3"
Expand Down
19 changes: 2 additions & 17 deletions cranelift/isle/isle/src/overlap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Overlap detection for rules in ISLE.

use rayon::prelude::*;
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};

Expand Down Expand Up @@ -30,17 +29,6 @@ struct Errors {
}

impl Errors {
/// Merge together two Error graphs.
fn union(mut self, other: Self) -> Self {
for (id, edges) in other.nodes {
match self.nodes.entry(id) {
Entry::Occupied(entry) => entry.into_mut().extend(edges),
Entry::Vacant(entry) => _ = entry.insert(edges),
}
}
self
}

/// Condense the overlap information down into individual errors. We iteratively remove the
/// nodes from the graph with the highest degree, reporting errors for them and their direct
/// connections. The goal with reporting errors this way is to prefer reporting rules that
Expand Down Expand Up @@ -145,19 +133,16 @@ fn check_overlaps(env: &TermEnv) -> Errors {
}
}

// Process rule pairs in parallel. Rayon makes this easy and we have independent bite-sized
// chunks of work, so we might as well take advantage of multiple CPUs if they're available.
pairs
.into_par_iter()
.fold(Errors::default, |mut errs, (left, right)| {
.into_iter()
.fold(Errors::default(), |mut errs, (left, right)| {
if left.rule.prio == right.rule.prio {
if check_overlap_pair(&left.pats, &right.pats) {
errs.add_edge(left.rule.id, right.rule.id);
}
}
errs
})
.reduce(Errors::default, Errors::union)
}

/// Check if two rules overlap in the inputs they accept.
Expand Down