Skip to content
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

rpc: optimize small tuple deserialization #2519

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/seastar/rpc/rpc_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,19 @@ inline std::tuple<T...> do_unmarshall(connection& c, Input& in) {
// left-to-right. So we deserialize into something that can be lazily
// constructed (and can conditionally destroy itself if we only constructed some
// of the arguments).
//
// As a special case, if the tuple has 1 or fewer elements, there is no ordering
// problem, and we can deserialize directly into a std::tuple<T...>.
if constexpr (sizeof...(T) <= 1) {
return std::tuple(unmarshal_one<Serializer, Input>::template helper<T>::doit(c, in)...);
} else {
std::tuple<std::optional<T>...> temporary;
return std::apply([&] (auto&... args) {
// Comma-expression preserves left-to-right order
(..., (args = unmarshal_one<Serializer, Input>::template helper<typename std::remove_reference_t<decltype(args)>::value_type>::doit(c, in)));
return std::tuple(std::move(*args)...);
}, temporary);
}
}

template <typename Serializer, typename... T>
Expand Down