Introduce Rayon for parallel iteration and sorting
- Use `into_par_iter()` before setting out to calculate scores and then
filter by them
This represents a more efficient parallelism approach, with no mutex
or global state at top level.
ivy_files(kubernetes) time: [4.5800 ms 4.6121 ms 4.6467 ms]
change: [-55.056% -54.570% -54.133%] (p = 0.00 < 0.05)
Performance has improved.
ivy_match(file.lua) time: [1.1514 µs 1.1599 µs 1.1694 µs]
change: [+0.4116% +2.0753% +3.6710%] (p = 0.01 < 0.05)
Change within noise threshold.
This commit is contained in:
parent
cec8393770
commit
c5e8677a37
3 changed files with 4 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -274,6 +274,7 @@ dependencies = [
|
|||
"fuzzy-matcher",
|
||||
"ignore",
|
||||
"lazy_static",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ path = "rust/lib.rs"
|
|||
ignore = "0.4"
|
||||
fuzzy-matcher = "0.3.7"
|
||||
lazy_static = "1.4.0"
|
||||
rayon = "1.5.3"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.6"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
use super::matcher;
|
||||
use super::thread_pool;
|
||||
|
||||
use std::sync::mpsc;
|
||||
use std::sync::Arc;
|
||||
use rayon::prelude::*;
|
||||
|
||||
pub struct Match {
|
||||
pub score: i64,
|
||||
|
|
@ -27,7 +24,7 @@ pub fn sort_strings(options: Options, strings: Vec<String>) -> Vec<Match> {
|
|||
let matcher = matcher::Matcher::new(options.pattern);
|
||||
|
||||
let mut matches = strings
|
||||
.into_iter()
|
||||
.into_par_iter()
|
||||
.map(|candidate| Match {
|
||||
score: matcher.score(candidate.as_str()),
|
||||
content: candidate,
|
||||
|
|
|
|||
Loading…
Reference in a new issue