Add a file-backed DiskBuffer - #1195
Conversation
Signed-off-by: niranda perera <niranda.perera@gmail.com>
|
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. |
DiskBuffer handleDiskBuffer
| * Transfers ownership of the backing file. The moved-from object is empty | ||
| * (`path()` is empty and `size()` is zero). |
There was a problem hiding this comment.
| * Transfers ownership of the backing file. The moved-from object is empty | |
| * (`path()` is empty and `size()` is zero). | |
| * Transfers ownership of the backing file. |
There was a problem hiding this comment.
Seems unnecessarily verbose docstring for a mover.
| * @param reservation Memory reservation covering at least `source->size()` | ||
| * bytes. |
There was a problem hiding this comment.
Why at least, and not exactly?
| RAPIDSMPF_EXPECTS( | ||
| source->is_latest_write_done(), | ||
| "cannot write buffer to disk with pending stream-ordered writes", | ||
| std::logic_error | ||
| ); |
There was a problem hiding this comment.
Could we validate source->is_latest_write_done() before calling create_unique_path()? As written, a buffer with pending stream-ordered writes throws here after path has already been created, and thus not cleaned.
| * @note This is a point-in-time check and is subject to TOCTOU races: | ||
| * another thread may call `get()` after this returns `true`. Like | ||
| * `std::future`, concurrent `is_ready()`/`get()` from multiple | ||
| * threads is undefined behavior. |
There was a problem hiding this comment.
| * @note This is a point-in-time check and is subject to TOCTOU races: | |
| * another thread may call `get()` after this returns `true`. Like | |
| * `std::future`, concurrent `is_ready()`/`get()` from multiple | |
| * threads is undefined behavior. | |
| * @note This is a point-in-time check and is subject to TOCTOU races: | |
| * another thread may call `get()` after this returns `true`. Like | |
| * `std::future`, concurrent `is_ready()`/`get()` from multiple | |
| * threads is undefined behavior. |
| * @return Number of bytes transferred. The caller must check this against | ||
| * the requested size. | ||
| * | ||
| * @note Like `std::future::get()`, this is not thread-safe. Calling get() | ||
| * concurrently from multiple threads is undefined behavior. |
There was a problem hiding this comment.
| * @return Number of bytes transferred. The caller must check this against | |
| * the requested size. | |
| * | |
| * @note Like `std::future::get()`, this is not thread-safe. Calling get() | |
| * concurrently from multiple threads is undefined behavior. | |
| * @return Number of bytes transferred. The caller must check this against | |
| * the requested size. | |
| * | |
| * @note Like `std::future::get()`, this is not thread-safe. Calling get() | |
| * concurrently from multiple threads is undefined behavior. |
| * `std::future`, concurrent `is_ready()`/`get()` from multiple | ||
| * threads is undefined behavior. | ||
| */ | ||
| [[nodiscard]] virtual bool is_ready() const = 0; |
There was a problem hiding this comment.
This seems to have been added by this PR (not included in #1186 that introduced this class) and is only used by DiskFutureIsReadyBeforeGet, do we really need it just to satisfy testing?
| RAPIDSMPF_EXPECTS( | ||
| disk_resource_ != nullptr, "the disk resource pointer cannot be NULL" | ||
| ); |
There was a problem hiding this comment.
Why not? Isn't that effectively forcing us to enable disk spilling, even when that's not wanted?
| // create a dir for each pid under the spill directory | ||
| std::shared_ptr<disk::DiskResource> disk_res{ | ||
| new disk::DiskResource{std::move(spill_directory) / std::to_string(::getpid())} | ||
| }; |
There was a problem hiding this comment.
And also forcing creating a spilling directory?
DiskResourcecould read and write files, but nothing owned a backing file or moved aBufferto and from disk. This addsDiskBufferas a move-only, file-backed handle outside theMemoryTypetaxonomy, owned throughunique_ptr.from_bufferand restore withrestore; both block until the transfer finishes and delete the file when the handle is released.BufferResourceown ashared_ptr<DiskResource>so disk handles can outlive the buffer resource, and allocate unique spill paths under its directory.Closes #1184
Depends on #1193 #1186
Related #1170