Make the CUDA stream pool per-thread and per-device - #23672
Draft
vuule wants to merge 2 commits into
Draft
Conversation
The global pool handed overlapping streams to concurrent threads, creating false dependencies between unrelated work. Each thread now owns a pool per device that grows on demand up to LIBCUDF_STREAM_POOL_SIZE, and pools are recycled through a free list when a thread exits so thread churn does not accumulate streams.
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.
Description
libcudf's stream pool was a single global pool of 32 streams shared by every thread, so concurrent threads calling
fork_streamswere handed overlapping streams. That creates false dependencies between unrelated work and serializes it. Each thread now owns a pool per device, created empty and grown on demand up to a cap configurable withLIBCUDF_STREAM_POOL_SIZE(default 32). A request grows the pool to twice the requested count and hands out streams starting at a rotating offset, so a nestedfork_streamsgenerally avoids the streams its caller already holds. Pools are returned to a per-device free list when a thread exits and adopted by the next thread that needs one, so applications that create and destroy many threads do not accumulate streams.fork_streamsandjoin_streamskeep their signatures. Streams may still be used from other threads, which libcudf does in the host compression, CSV, and JSON read paths, but they must not outlive the thread that acquired them; all current call sites join before the acquiring frame returns.Multithreaded parquet reads improve by 7-12% in GPU time at 8 threads (
parquet_multithreaded_read_decode_mixed27.4 ms to 25.5 ms,parquet_multithreaded_read_decode_string29.5 ms to 26.8 ms), with run-to-run noise dropping from 9-11% to 4-6%. Single- and two-thread configs, ORC, and groupby are unchanged, and peak memory is unchanged.Checklist