feat(data): wait for asynchronous batch readers - #184
Draft
9prady9 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_only_data_batch::record_reader_event(stream)so consumers can publish asynchronous GPU reads before releasing their shared locktry_to_mutable()non-blockingWhy
A reader can enqueue an asynchronous copy from a non-owning GPU view and release its read lock before the copy finishes. The batch can then be reclaimed and its memory reused, silently corrupting the in-flight copy. Writer events only order readers after writers; they do not order reclaim after readers.
This change records the inverse dependency on the batch. Any path that obtains mutable access—including replacement, conversion, rebind, and raw mutable access—crosses the same reader-event barrier before it can reuse the representation.
Correctness details
readonly_to_mutable()uses the same barrier, whiletry_to_mutable()queries events and returnsnulloptwhen any remain pendingTest plan
pixi run pre-commit run --files include/cucascade/data/data_batch.hpp src/data/data_batch.cpp test/data/test_data_batch.cppcucascade_testscucascade_cudf_testscucascade_cudf_tests '[reader_event]'on a GPU host; this development host has no usable NVIDIA driver and returnscudaErrorNoDevice