Skip to content

Commit 3abd15f

Browse files
committed
Remove rayon dependency of cranelift-isle
Using rayon adds a lot of dependencies to Cranelift. The total unparallelized time the code that uses rayon takes is less than half a second and it runs at compile time, so there is pretty much no benefit to parallelizing it.
1 parent 5a4adde commit 3abd15f

3 files changed

Lines changed: 2 additions & 19 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cranelift/isle/isle/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ version = "0.90.0"
1111
[dependencies]
1212
log = { workspace = true, optional = true }
1313
miette = { version = "5.1.0", optional = true }
14-
rayon = "^1.5"
1514

1615
[dev-dependencies]
1716
tempfile = "3"

cranelift/isle/isle/src/overlap.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Overlap detection for rules in ISLE.
22
3-
use rayon::prelude::*;
43
use std::collections::hash_map::Entry;
54
use std::collections::{HashMap, HashSet};
65

@@ -30,17 +29,6 @@ struct Errors {
3029
}
3130

3231
impl Errors {
33-
/// Merge together two Error graphs.
34-
fn union(mut self, other: Self) -> Self {
35-
for (id, edges) in other.nodes {
36-
match self.nodes.entry(id) {
37-
Entry::Occupied(entry) => entry.into_mut().extend(edges),
38-
Entry::Vacant(entry) => _ = entry.insert(edges),
39-
}
40-
}
41-
self
42-
}
43-
4432
/// Condense the overlap information down into individual errors. We iteratively remove the
4533
/// nodes from the graph with the highest degree, reporting errors for them and their direct
4634
/// connections. The goal with reporting errors this way is to prefer reporting rules that
@@ -145,19 +133,16 @@ fn check_overlaps(env: &TermEnv) -> Errors {
145133
}
146134
}
147135

148-
// Process rule pairs in parallel. Rayon makes this easy and we have independent bite-sized
149-
// chunks of work, so we might as well take advantage of multiple CPUs if they're available.
150136
pairs
151-
.into_par_iter()
152-
.fold(Errors::default, |mut errs, (left, right)| {
137+
.into_iter()
138+
.fold(Errors::default(), |mut errs, (left, right)| {
153139
if left.rule.prio == right.rule.prio {
154140
if check_overlap_pair(&left.pats, &right.pats) {
155141
errs.add_edge(left.rule.id, right.rule.id);
156142
}
157143
}
158144
errs
159145
})
160-
.reduce(Errors::default, Errors::union)
161146
}
162147

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

0 commit comments

Comments
 (0)