Skip to content

Add a KvikIO-backed DiskResource for blocking disk spill I/O - #1186

Draft
nirandaperera wants to merge 1 commit into
rapidsai:mainfrom
nirandaperera:disk-spill-stage-1
Draft

Add a KvikIO-backed DiskResource for blocking disk spill I/O#1186
nirandaperera wants to merge 1 commit into
rapidsai:mainfrom
nirandaperera:disk-spill-stage-1

Conversation

@nirandaperera

Copy link
Copy Markdown
Contributor

This adds a public, blocking rapidsmpf::disk::DiskResource on KvikIO CompatMode::AUTO (GDS when available) and keeps disk outside MemoryType / Buffer / BufferResource.

  • write / read / flush take a path, pointer, size, device flag, and optional file offset; callers must sync device pointers before I/O.
  • Spill location comes from config option disk_spill_dir (RAPIDSMPF_DISK_SPILL_DIR); empty uses the system temp directory.
  • C++ tests cover host, pinned, and device Buffer round-trips, unaligned offsets, flush, and the spill-dir option.
  • libkvikio is a public dependency of librapidsmpf (CMake, conda, DFG / pyproject).

Closes #1183
Related to #1170

@nirandaperera nirandaperera self-assigned this Aug 31, 2026
@nirandaperera nirandaperera added the improvement Improves an existing functionality label Aug 31, 2026
@nirandaperera
nirandaperera requested a review from a team as a code owner August 31, 2026 17:34
@nirandaperera nirandaperera added the non-breaking Introduces a non-breaking change label Aug 31, 2026
@nirandaperera
nirandaperera requested review from a team as code owners August 31, 2026 17:34

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ me when this is ready for a full review (I still see plenty of failing CI here and it's behind main, unsure if it's ready yet).

Quick note... if this is merged, please also update RAPIDS dependency graph to reflect that, following these examples: NVIDIA/cuvs#2257 (review)

@nirandaperera
nirandaperera marked this pull request as draft September 3, 2026 03:29
@copy-pr-bot

copy-pr-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

);

/**
* @brief Durably synchronize file data to storage (fdatasync).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Durably synchronize file data to storage (fdatasync).
* @brief Durably synchronize file data to storage.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not add implementation details on the docstrings.

};

/**
* @brief Spill directory from `disk_spill_dir` (`RAPIDSMPF_DISK_SPILL_DIR`).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Spill directory from `disk_spill_dir` (`RAPIDSMPF_DISK_SPILL_DIR`).
* @brief Spill directory from `disk_spill_dir`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to list all possible ways to set a configuration, users should refer to the docs.

Comment on lines +68 to +70
auto file = std::make_unique<kvikio::FileHandle>(
path.string(), "w+", kvikio::FileHandle::m644, kvikio::CompatMode::AUTO
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto file = std::make_unique<kvikio::FileHandle>(
path.string(), "w+", kvikio::FileHandle::m644, kvikio::CompatMode::AUTO
);
auto const flags = std::filesystem::exists(path) ? "r+" : "w+";
auto file = std::make_unique<kvikio::FileHandle>(
path.string(), flags, kvikio::FileHandle::m644, kvikio::CompatMode::AUTO);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written, "w+" enables O_TRUNC, so every write() first truncates the path and a later pwrite() cannot retain bytes written by an earlier call. KvikIO supports "r+" for read/write access without truncation, so selecting "r+" when the spill file already exists (and "w+" only for initial creation) would preserve offset writes. I think the proposal above fixes nonzero offset writes.

Please also add a test that writes two distinct ranges to one path and verifies both remain intact.

return options.get<std::filesystem::path>(
"disk_spill_dir", [](std::string const& value) {
if (value.empty()) {
return std::filesystem::temp_directory_path();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Often this will be a ramdisk, which seems like a bad default.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this be a ramdisk? Wouldn't a ramdisk effectively be a proxy for spill-to-host?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nevermind, I misunderstood your statement. temp_directory_path() will often be a ramdisk, you're not saying users would often be a ramdisk. I agree with your statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Disk Memory Resource

4 participants