Skip to content

Commit c8d8585

Browse files
committed
utils: express io_thread_count() in a simpler way
1 parent 792598c commit c8d8585

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/utils/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ pub mod raw;
2828
pub(crate) mod units;
2929

3030
pub fn io_thread_count() -> usize {
31-
// Don't spawn more than this many I/O threads unless the user tells us to.
32-
// Feel free to increase this value if it improves performance.
33-
const DEFAULT_IO_THREAD_LIMIT: usize = 8;
34-
35-
thread::available_parallelism()
36-
.map_or(1, |p| p.get())
37-
.min(DEFAULT_IO_THREAD_LIMIT)
31+
match thread::available_parallelism() {
32+
// Don't spawn more than 8 I/O threads unless the user tells us to.
33+
// Feel free to increase this value if it improves performance.
34+
Ok(threads) => Ord::min(threads.get(), 8),
35+
// Unknown for target platform or no permission to query.
36+
Err(_) => 1,
37+
}
3838
}
3939

4040
#[must_use]

0 commit comments

Comments
 (0)