-
Notifications
You must be signed in to change notification settings - Fork 28
Make unbounded fanout messages spillable #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 27 commits into
rapidsai:main
from
nirandaperera:Make-unbounded-fanout-state-spillable
Dec 15, 2025
Merged
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3876116
adding spillable messages
nirandaperera dc13cdf
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera d4e9a1b
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera 7163773
adding test
nirandaperera dd0d345
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera ca10c57
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera 363b61e
new API
nirandaperera feb04a8
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera 72e0be3
merge conflict
nirandaperera 5606f6a
enabling extracting message ID
nirandaperera ea830ac
minor changes
nirandaperera f9947c1
Merge branch 'main' into Make-unbounded-fanout-state-spillable
nirandaperera 0d1cc9a
Update cpp/include/rapidsmpf/memory/memory_type.hpp
nirandaperera d5db515
doxygen error
nirandaperera 61ba76e
Revert "enabling extracting message ID"
nirandaperera 090dfde
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera 4488ded
Merge branch 'Make-unbounded-fanout-state-spillable' of github.com:ni…
nirandaperera a2ad554
remove cout
nirandaperera e3958a2
Apply suggestions from code review
nirandaperera 5dc7708
addressing comments
nirandaperera b4c6cac
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera 55c8114
API change
nirandaperera d0e6a50
Merge branch 'main' of github.com:rapidsai/rapidsmpf into Make-unboun…
nirandaperera 6298b2e
precommit
nirandaperera a8c232e
minro change
nirandaperera c4d4a39
Merge branch 'main' into Make-unbounded-fanout-state-spillable
nirandaperera 1373521
fix build
nirandaperera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |
|
|
||
| #include <array> | ||
| #include <ostream> | ||
| #include <ranges> | ||
| #include <span> | ||
|
|
||
| namespace rapidsmpf { | ||
|
|
||
|
|
@@ -33,6 +35,27 @@ constexpr std::array<char const*, MEMORY_TYPES.size()> MEMORY_TYPE_NAMES{ | |
| */ | ||
| constexpr std::array<MemoryType, 1> SPILL_TARGET_MEMORY_TYPES{{MemoryType::HOST}}; | ||
|
|
||
| /** | ||
| * @brief Get the lower memory types than or equal to the @p mem_type . | ||
| * | ||
| * @param mem_type The memory type. | ||
| * @return A span of the lower memory types than the given memory type. | ||
| */ | ||
| constexpr std::span<MemoryType const> leq_memory_types(MemoryType mem_type) noexcept { | ||
| return std::views::drop_while(MEMORY_TYPES, [&](MemoryType const& mt) { | ||
| return mt != mem_type; | ||
| }); | ||
| } | ||
|
|
||
| static_assert(std::ranges::equal(leq_memory_types(MemoryType::DEVICE), MEMORY_TYPES)); | ||
| static_assert(std::ranges::equal( | ||
| leq_memory_types(MemoryType::HOST), std::ranges::single_view{MemoryType::HOST} | ||
| )); | ||
| // unknown memory type should return an empty view | ||
| static_assert(std::ranges::equal( | ||
| leq_memory_types(static_cast<MemoryType>(-1)), std::ranges::empty_view<MemoryType>{} | ||
| )); | ||
|
Comment on lines
+53
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not immediately just have: ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would return a |
||
|
|
||
| /** | ||
| * @brief Get the name of a MemoryType. | ||
| * | ||
|
|
||
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <gmock/gmock.h> | ||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <rapidsmpf/streaming/core/channel.hpp> | ||
| #include <rapidsmpf/streaming/core/context.hpp> | ||
| #include <rapidsmpf/streaming/core/node.hpp> | ||
|
|
||
| #include "base_streaming_fixture.hpp" | ||
|
|
||
| using namespace rapidsmpf; | ||
| using namespace rapidsmpf::streaming; | ||
|
|
||
| using StreamingChannel = BaseStreamingFixture; | ||
|
|
||
| TEST_F(StreamingChannel, ReceiveMessageId) { | ||
| constexpr int num_messages = 10; | ||
| auto ch = ctx->create_channel(); | ||
| std::vector<Node> nodes; | ||
|
|
||
| nodes.push_back([](auto ctx, auto ch_out) -> Node { | ||
| ShutdownAtExit c{ch_out}; | ||
| co_await ctx->executor()->schedule(); | ||
| for (int i = 0; i < num_messages; ++i) { | ||
| co_await ch_out->send( | ||
| Message{ | ||
| static_cast<uint64_t>(i), | ||
| std::make_unique<int>(i * 10), | ||
| ContentDescription{}, | ||
| [](Message const& /* msg */, MemoryReservation& /* res */) | ||
| -> Message { RAPIDSMPF_FAIL("should not be called"); } | ||
| } | ||
| ); | ||
| } | ||
| co_await ch_out->drain(ctx->executor()); | ||
| }(ctx, ch)); | ||
|
|
||
| std::vector<int> recv_vals; | ||
| std::vector<uint64_t> recv_seq_nums; | ||
| nodes.push_back( | ||
| [](auto ctx, | ||
| auto ch_in, | ||
| std::vector<int>& values, | ||
| std::vector<uint64_t>& seq_nums) -> Node { | ||
| ShutdownAtExit c{ch_in}; | ||
| co_await ctx->executor()->schedule(); | ||
| while (true) { | ||
| auto msg_id = co_await ch_in->receive_message_id(); | ||
| if (msg_id == SpillableMessages::InvalidMessageId) { | ||
| break; | ||
| } | ||
| auto msg = ctx->spillable_messages()->extract(msg_id); | ||
| seq_nums.push_back(msg.sequence_number()); | ||
| values.push_back(msg.template get<int>()); | ||
| } | ||
| }(ctx, ch, recv_vals, recv_seq_nums) | ||
| ); | ||
|
|
||
| run_streaming_pipeline(std::move(nodes)); | ||
|
|
||
| // Verify all messages were received correctly. | ||
| EXPECT_EQ(num_messages, recv_vals.size()); | ||
| EXPECT_EQ(num_messages, recv_seq_nums.size()); | ||
|
|
||
| std::ranges::sort(recv_seq_nums); | ||
| std::ranges::sort(recv_vals); | ||
| for (int i = 0; i < num_messages; ++i) { | ||
| EXPECT_EQ(static_cast<uint64_t>(i), recv_seq_nums[i]); | ||
| EXPECT_EQ(i * 10, recv_vals[i]); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.