Skip to content

Commit a45a521

Browse files
authored
Fix flaky StreamPoolTest.ConcurrentThreadsGetDistinctStreams (#23820)
`ConcurrentThreadsGetDistinctStreams` relied on a latch to keep its two threads overlapping, but the latch only guarantees that both threads have started, not that both have acquired a stream pool. Each thread now takes its pool before waiting on the latch, so both pools are live at the same time. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Muhammad Haseeb (https://github.com/mhaseeb123) - David Wendt (https://github.com/davidwendt) - MithunR (https://github.com/mythrocks) URL: #23820
1 parent 8a4d125 commit a45a521

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cpp/tests/utilities_tests/stream_pool_tests.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ TEST_F(StreamPoolTest, ConcurrentThreadsGetDistinctStreams)
4040
auto constexpr num_streams = 8;
4141

4242
// Repeated requests make a shared round-robin counter very likely to hand the same stream to both
43-
// threads. The latch makes them overlap; a thread starting after the other exited would adopt its
44-
// retired pool and see the same streams.
43+
// threads. Each thread takes its pool before the latch: a pool is created on first use and
44+
// returned to the free list when its thread exits, so a thread that made its first request after
45+
// the other one exited would adopt the retired pool and see the same streams.
4546
auto collect = [](std::unordered_set<cudaStream_t>& out, std::latch& ready) {
47+
auto const first = get_hashable_streams(num_streams);
48+
out.insert(first.begin(), first.end());
4649
ready.arrive_and_wait();
4750
for (auto request = 0; request < num_requests; request++) {
4851
auto const streams = get_hashable_streams(num_streams);

0 commit comments

Comments
 (0)