diff --git a/vortex-cuda/src/pooled_read_at/file.rs b/vortex-cuda/src/pooled_read_at/file.rs index 237a3bb91fc..49db6b6d31f 100644 --- a/vortex-cuda/src/pooled_read_at/file.rs +++ b/vortex-cuda/src/pooled_read_at/file.rs @@ -58,6 +58,10 @@ pub const DEFAULT_FILE_CONCURRENCY: usize = 32; // to limit blocking read sizes and start transfers before the whole segment is read. const FILE_READ_CHUNK_BYTES: usize = 8 << 20; +/// Mapped copies alternate filling a chunk's page tables with copying the previous chunk, so +/// smaller chunks start the device sooner, independently of the staged read size. +const MAPPED_COPY_CHUNK_BYTES: usize = 4 << 20; + /// Upper bound on blocks per mapped copy launch: a few per SM saturates host-memory reads. const MAPPED_COPY_BLOCKS_MAX: u64 = 1024; const MAPPED_COPY_THREADS: u32 = 256; @@ -386,8 +390,8 @@ impl MappedFile { // The guard records the queued copies as the output's write when this scope ends, // including on error, so frees and readers on other streams wait for them. let (base, write) = output.device_ptr_mut(&self.stream); - for chunk in (0..length).step_by(FILE_READ_CHUNK_BYTES) { - let size = (length - chunk).min(FILE_READ_CHUNK_BYTES); + for chunk in (0..length).step_by(MAPPED_COPY_CHUNK_BYTES) { + let size = (length - chunk).min(MAPPED_COPY_CHUNK_BYTES); #[cfg(target_os = "linux")] { let _fill = MAPPED_FILL.lock(); diff --git a/vortex-cuda/src/pooled_read_at/file/tests.rs b/vortex-cuda/src/pooled_read_at/file/tests.rs index d75440e6c5c..bd42dc2c911 100644 --- a/vortex-cuda/src/pooled_read_at/file/tests.rs +++ b/vortex-cuda/src/pooled_read_at/file/tests.rs @@ -316,7 +316,7 @@ async fn cancelled_reads_keep_slots_and_buffers_until_blocking_io_finishes() -> Ok(()) } -const MAPPED_FILE_BYTES: usize = 2 * FILE_READ_CHUNK_BYTES + 4096; +const MAPPED_FILE_BYTES: usize = 2 * MAPPED_COPY_CHUNK_BYTES + 4096; /// Opens a real buffered file of `file_byte` content with the device-side mapped copy enabled. fn mapped_reader() -> VortexResult<( @@ -346,8 +346,8 @@ fn mapped_reader() -> VortexResult<( #[case::empty(37, 0)] #[case::single_byte_unaligned(5, 1)] #[case::short_unaligned(15, 17)] -#[case::chunk_aligned(0, FILE_READ_CHUNK_BYTES - 1)] -#[case::chunks_with_tail(4091, 2 * FILE_READ_CHUNK_BYTES + 3)] +#[case::chunk_aligned(0, MAPPED_COPY_CHUNK_BYTES - 1)] +#[case::chunks_with_tail(4091, 2 * MAPPED_COPY_CHUNK_BYTES + 3)] #[case::through_file_end(0, MAPPED_FILE_BYTES)] #[crate::test] async fn mapped_reads_preserve_bytes_and_offsets( @@ -423,9 +423,9 @@ async fn concurrent_mapped_reads_preserve_bytes_and_offsets() -> VortexResult<() reader.read_slots.close(); let reads = [ - (4091, 2 * FILE_READ_CHUNK_BYTES + 3), + (4091, 2 * MAPPED_COPY_CHUNK_BYTES + 3), (0, MAPPED_FILE_BYTES), - (FILE_READ_CHUNK_BYTES as u64 - 7, 3 * 4096), + (MAPPED_COPY_CHUNK_BYTES as u64 - 7, 3 * 4096), ]; let buffers = wait_for( "concurrent mapped reads did not finish",