Skip to content

Commit 38a056a

Browse files
committed
diskio: clarify dependency on I/O thread count
1 parent b4b9502 commit 38a056a

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/diskio/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ use std::{fmt::Debug, fs::OpenOptions};
6666

6767
use anyhow::Result;
6868

69-
use crate::process::Process;
70-
7169
/// Carries the implementation specific data for complete file transfers into the executor.
7270
#[derive(Debug)]
7371
pub(crate) enum FileBuffer {
@@ -443,11 +441,11 @@ pub(crate) fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
443441
/// Get the executor for disk IO.
444442
pub(crate) fn get_executor<'a>(
445443
ram_budget: usize,
446-
process: &Process,
447-
) -> Result<Box<dyn Executor + 'a>> {
444+
io_thread_count: usize,
445+
) -> Box<dyn Executor + 'a> {
448446
// If this gets lots of use, consider exposing via the config file.
449-
Ok(match process.io_thread_count()? {
447+
match io_thread_count {
450448
0 | 1 => Box::new(immediate::ImmediateUnpacker::new()),
451449
n => Box::new(threaded::Threaded::new(n, ram_budget)),
452-
})
450+
}
453451
}

src/diskio/test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
2424

2525
let mut written = 0;
2626
let mut file_finished = false;
27-
let mut io_executor: Box<dyn Executor> = get_executor(32 * 1024 * 1024, &tp.process)?;
27+
let mut io_executor: Box<dyn Executor> =
28+
get_executor(32 * 1024 * 1024, tp.process.io_thread_count()?);
2829
let (item, mut sender) = Item::write_file_segmented(
2930
work_dir.path().join("scratch"),
3031
0o666,
@@ -90,7 +91,8 @@ fn test_complete_file(io_threads: &str) -> Result<()> {
9091
vars.insert("RUSTUP_IO_THREADS".to_string(), io_threads.to_string());
9192
let tp = TestProcess::with_vars(vars);
9293

93-
let mut io_executor: Box<dyn Executor> = get_executor(32 * 1024 * 1024, &tp.process)?;
94+
let mut io_executor: Box<dyn Executor> =
95+
get_executor(32 * 1024 * 1024, tp.process.io_thread_count()?);
9496
let mut chunk = io_executor.get_buffer(10);
9597
chunk.extend(b"0123456789");
9698
assert_eq!(chunk.len(), 10);

src/dist/component/package.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fn unpack_without_first_dir<R: Read>(
285285
}
286286
};
287287
let unpack_ram = unpack_ram(IO_CHUNK_SIZE, effective_max_ram, dl_cfg);
288-
let mut io_executor: Box<dyn Executor> = get_executor(unpack_ram, dl_cfg.process)?;
288+
let mut io_executor = get_executor(unpack_ram, dl_cfg.process.io_thread_count()?);
289289

290290
let mut directories: HashMap<PathBuf, DirStatus> = HashMap::new();
291291
// Path is presumed to exist. Call it a precondition.

0 commit comments

Comments
 (0)