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

perf(linter): use parallel iterator directly instead of iter and parallel bridge #8831

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
7 changes: 3 additions & 4 deletions crates/oxc_linter/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
sync::Arc,
};

use rayon::{iter::ParallelBridge, prelude::ParallelIterator};
use rayon::prelude::ParallelIterator;
use runtime::Runtime;

use oxc_diagnostics::DiagnosticSender;
Expand Down Expand Up @@ -91,8 +91,7 @@ impl LintService {
/// # Panics
pub fn run(&self, tx_error: &DiagnosticSender) {
self.runtime
.iter_paths()
.par_bridge()
.par_iter_paths()
.for_each_with(&self.runtime, |runtime, path| runtime.process_path(path, tx_error));
tx_error.send(None).unwrap();
}
Expand All @@ -107,7 +106,7 @@ impl LintService {
tx_error: &DiagnosticSender,
) -> Vec<crate::Message<'a>> {
self.runtime
.iter_paths()
.par_iter_paths()
.flat_map(|path| {
let source_type = oxc_span::SourceType::from_path(path).unwrap();
self.runtime.init_cache_state(path);
Expand Down
9 changes: 6 additions & 3 deletions crates/oxc_linter/src/service/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use std::{
sync::Arc,
};

use rayon::{iter::ParallelBridge, prelude::ParallelIterator};
use rayon::{
iter::{IntoParallelRefIterator, ParallelBridge},
prelude::ParallelIterator,
};
use rustc_hash::FxHashSet;

use oxc_allocator::Allocator;
Expand Down Expand Up @@ -288,7 +291,7 @@ impl Runtime {
self.modules.len() - self.paths.len()
}

pub(super) fn iter_paths(&self) -> impl Iterator<Item = &Box<Path>> + '_ {
self.paths.iter()
pub(super) fn par_iter_paths(&self) -> impl ParallelIterator<Item = &Box<Path>> {
self.paths.par_iter()
}
}