Skip to content

Commit 41d9cfc

Browse files
committed
Set the parallelism automatically
Use `available_parallelism()` to run linters in parallel. This doesn't always work perfectly so in future we'll probably need an explicit command line flag, or maybe environment variable. Fixes #9
1 parent d5ebcdd commit 41d9cfc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/engine.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,15 @@ pub async fn run_single_linter(
152152
async move { run_linter_command(top_level, &full_args, engine, component).await }
153153
});
154154

155-
// TODO (1.0): Use a smarter strategy than just hardcoding 4.
156-
let max_parallelism = if metadata.require_serial { 1 } else { 4 };
155+
// TODO (2.0): Add an option to explicitly set the parallelism, since
156+
// this doesn't always work perfectly (see the docs for available_parallelism()).
157+
let max_parallelism = if metadata.require_serial {
158+
1
159+
} else {
160+
std::thread::available_parallelism()
161+
.map(|n| n.get())
162+
.unwrap_or(4)
163+
};
157164

158165
// We have to run all of the tasks even of an early one fails so they
159166
// can fix files and find all errors.

0 commit comments

Comments
 (0)