Skip to content
Closed
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
8 changes: 6 additions & 2 deletions vortex-cuda/src/pooled_read_at/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions vortex-cuda/src/pooled_read_at/file/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
Loading