Skip to content

Commit

Permalink
Migrate left join and conditional join benchmarks to use nvbench (#15931
Browse files Browse the repository at this point in the history
)

The current [left join](https://github.com/rapidsai/cudf/blob/580ee40bf5fe1a66eaba914cdddb718a09193bab/cpp/benchmarks/join/left_join.cu) and [conditional join](https://github.com/rapidsai/cudf/blob/580ee40bf5fe1a66eaba914cdddb718a09193bab/cpp/benchmarks/join/conditional_join.cu) benchmarks are still using gbench.
This PR migrates the **left join** and **conditional join** benchmarks to use **nvbench**.

Closes #15699.

- [x] Migrate from gbench to nvbench
- [x] Similar to #15644, use `JOIN_KEY_TYPE_RANGE`, `JOIN_NULLABLE_RANGE` and `JOIN_SIZE_RANGE` to reduce the number of test cases and simplify the implementation
- [x] Get rid of the dispatching between gbench and nvbench in [join_common.hpp](https://github.com/rapidsai/cudf/blob/580ee40bf5fe1a66eaba914cdddb718a09193bab/cpp/benchmarks/join/join_common.hpp)

Authors:
  - Srinivas Yadav (https://github.com/srinivasyadav18)
  - Yunsong Wang (https://github.com/PointKernel)

Approvers:
  - Yunsong Wang (https://github.com/PointKernel)
  - Shruti Shivakumar (https://github.com/shrshi)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #15931
  • Loading branch information
srinivasyadav18 authored Jun 11, 2024
1 parent 1bd210d commit ff1e4bb
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 429 deletions.
6 changes: 4 additions & 2 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ ConfigureNVBench(

# ##################################################################################################
# * join benchmark --------------------------------------------------------------------------------
ConfigureBench(JOIN_BENCH join/left_join.cu join/conditional_join.cu)
ConfigureNVBench(JOIN_NVBENCH join/join.cu join/mixed_join.cu join/distinct_join.cu)
ConfigureNVBench(
JOIN_NVBENCH join/left_join.cu join/conditional_join.cu join/join.cu join/mixed_join.cu
join/distinct_join.cu
)

# ##################################################################################################
# * iterator benchmark ----------------------------------------------------------------------------
Expand Down
288 changes: 41 additions & 247 deletions cpp/benchmarks/join/conditional_join.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,250 +14,44 @@
* limitations under the License.
*/

#include <benchmarks/join/join_common.hpp>

template <typename Key>
class ConditionalJoin : public cudf::benchmark {};

// For compatibility with the shared logic for equality (hash) joins, all of
// the join lambdas defined by these macros accept a null_equality parameter
// but ignore it (don't forward it to the underlying join implementation)
// because conditional joins do not use this parameter.
#define CONDITIONAL_INNER_JOIN_BENCHMARK_DEFINE(name, Key, Nullable) \
BENCHMARK_TEMPLATE_DEFINE_F(ConditionalJoin, name, Key) \
(::benchmark::State & st) \
{ \
auto join = [](cudf::table_view const& left, \
cudf::table_view const& right, \
cudf::ast::operation binary_pred, \
cudf::null_equality compare_nulls) { \
return cudf::conditional_inner_join(left, right, binary_pred); \
}; \
BM_join<Key, Nullable, join_t::CONDITIONAL>(st, join); \
}

CONDITIONAL_INNER_JOIN_BENCHMARK_DEFINE(conditional_inner_join_32bit, int32_t, false);
CONDITIONAL_INNER_JOIN_BENCHMARK_DEFINE(conditional_inner_join_64bit, int64_t, false);
CONDITIONAL_INNER_JOIN_BENCHMARK_DEFINE(conditional_inner_join_32bit_nulls, int32_t, true);
CONDITIONAL_INNER_JOIN_BENCHMARK_DEFINE(conditional_inner_join_64bit_nulls, int64_t, true);

#define CONDITIONAL_LEFT_JOIN_BENCHMARK_DEFINE(name, Key, Nullable) \
BENCHMARK_TEMPLATE_DEFINE_F(ConditionalJoin, name, Key) \
(::benchmark::State & st) \
{ \
auto join = [](cudf::table_view const& left, \
cudf::table_view const& right, \
cudf::ast::operation binary_pred, \
cudf::null_equality compare_nulls) { \
return cudf::conditional_left_join(left, right, binary_pred); \
}; \
BM_join<Key, Nullable, join_t::CONDITIONAL>(st, join); \
}

CONDITIONAL_LEFT_JOIN_BENCHMARK_DEFINE(conditional_left_join_32bit, int32_t, false);
CONDITIONAL_LEFT_JOIN_BENCHMARK_DEFINE(conditional_left_join_64bit, int64_t, false);
CONDITIONAL_LEFT_JOIN_BENCHMARK_DEFINE(conditional_left_join_32bit_nulls, int32_t, true);
CONDITIONAL_LEFT_JOIN_BENCHMARK_DEFINE(conditional_left_join_64bit_nulls, int64_t, true);

#define CONDITIONAL_FULL_JOIN_BENCHMARK_DEFINE(name, Key, Nullable) \
BENCHMARK_TEMPLATE_DEFINE_F(ConditionalJoin, name, Key) \
(::benchmark::State & st) \
{ \
auto join = [](cudf::table_view const& left, \
cudf::table_view const& right, \
cudf::ast::operation binary_pred, \
cudf::null_equality compare_nulls) { \
return cudf::conditional_full_join(left, right, binary_pred); \
}; \
BM_join<Key, Nullable, join_t::CONDITIONAL>(st, join); \
}

CONDITIONAL_FULL_JOIN_BENCHMARK_DEFINE(conditional_full_join_32bit, int32_t, false);
CONDITIONAL_FULL_JOIN_BENCHMARK_DEFINE(conditional_full_join_64bit, int64_t, false);
CONDITIONAL_FULL_JOIN_BENCHMARK_DEFINE(conditional_full_join_32bit_nulls, int32_t, true);
CONDITIONAL_FULL_JOIN_BENCHMARK_DEFINE(conditional_full_join_64bit_nulls, int64_t, true);

#define CONDITIONAL_LEFT_ANTI_JOIN_BENCHMARK_DEFINE(name, Key, Nullable) \
BENCHMARK_TEMPLATE_DEFINE_F(ConditionalJoin, name, Key) \
(::benchmark::State & st) \
{ \
auto join = [](cudf::table_view const& left, \
cudf::table_view const& right, \
cudf::ast::operation binary_pred, \
cudf::null_equality compare_nulls) { \
return cudf::conditional_left_anti_join(left, right, binary_pred); \
}; \
BM_join<Key, Nullable, join_t::CONDITIONAL>(st, join); \
}

CONDITIONAL_LEFT_ANTI_JOIN_BENCHMARK_DEFINE(conditional_left_anti_join_32bit, int32_t, false);
CONDITIONAL_LEFT_ANTI_JOIN_BENCHMARK_DEFINE(conditional_left_anti_join_64bit, int64_t, false);
CONDITIONAL_LEFT_ANTI_JOIN_BENCHMARK_DEFINE(conditional_left_anti_join_32bit_nulls, int32_t, true);
CONDITIONAL_LEFT_ANTI_JOIN_BENCHMARK_DEFINE(conditional_left_anti_join_64bit_nulls, int64_t, true);

#define CONDITIONAL_LEFT_SEMI_JOIN_BENCHMARK_DEFINE(name, Key, Nullable) \
BENCHMARK_TEMPLATE_DEFINE_F(ConditionalJoin, name, Key) \
(::benchmark::State & st) \
{ \
auto join = [](cudf::table_view const& left, \
cudf::table_view const& right, \
cudf::ast::operation binary_pred, \
cudf::null_equality compare_nulls) { \
return cudf::conditional_left_semi_join(left, right, binary_pred); \
}; \
BM_join<Key, Nullable, join_t::CONDITIONAL>(st, join); \
}

CONDITIONAL_LEFT_SEMI_JOIN_BENCHMARK_DEFINE(conditional_left_semi_join_32bit, int32_t, false);
CONDITIONAL_LEFT_SEMI_JOIN_BENCHMARK_DEFINE(conditional_left_semi_join_64bit, int64_t, false);
CONDITIONAL_LEFT_SEMI_JOIN_BENCHMARK_DEFINE(conditional_left_semi_join_32bit_nulls, int32_t, true);
CONDITIONAL_LEFT_SEMI_JOIN_BENCHMARK_DEFINE(conditional_left_semi_join_64bit_nulls, int64_t, true);

// inner join -----------------------------------------------------------------------
BENCHMARK_REGISTER_F(ConditionalJoin, conditional_inner_join_32bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({400'000, 100'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_inner_join_64bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({400'000, 100'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_inner_join_32bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({400'000, 100'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_inner_join_64bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({400'000, 100'000})
->Args({100'000, 1'000'000})
->UseManualTime();

// left join -----------------------------------------------------------------------
BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_join_32bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_join_64bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_join_32bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_join_64bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

// full join -----------------------------------------------------------------------
BENCHMARK_REGISTER_F(ConditionalJoin, conditional_full_join_32bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_full_join_64bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_full_join_32bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_full_join_64bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

// left anti-join -------------------------------------------------------------
BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_anti_join_32bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_anti_join_64bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_anti_join_32bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_anti_join_64bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

// left semi-join -------------------------------------------------------------
BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_semi_join_32bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_semi_join_64bit)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_semi_join_32bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();

BENCHMARK_REGISTER_F(ConditionalJoin, conditional_left_semi_join_64bit_nulls)
->Unit(benchmark::kMillisecond)
->Args({100'000, 100'000})
->Args({100'000, 400'000})
->Args({100'000, 1'000'000})
->UseManualTime();
#include "join_common.hpp"

template <typename Key, bool Nullable>
void nvbench_conditional_inner_join(nvbench::state& state,
nvbench::type_list<Key, nvbench::enum_type<Nullable>>)
{
auto join = [](cudf::table_view const& left,
cudf::table_view const& right,
cudf::ast::operation binary_pred,
cudf::null_equality compare_nulls) {
return cudf::conditional_inner_join(left, right, binary_pred);
};
BM_join<Key, Nullable, join_t::CONDITIONAL>(state, join);
}

template <typename Key, bool Nullable>
void nvbench_conditional_left_join(nvbench::state& state,
nvbench::type_list<Key, nvbench::enum_type<Nullable>>)
{
auto join = [](cudf::table_view const& left,
cudf::table_view const& right,
cudf::ast::operation binary_pred,
cudf::null_equality compare_nulls) {
return cudf::conditional_left_join(left, right, binary_pred);
};
BM_join<Key, Nullable, join_t::CONDITIONAL>(state, join);
}

NVBENCH_BENCH_TYPES(nvbench_conditional_inner_join,
NVBENCH_TYPE_AXES(JOIN_KEY_TYPE_RANGE, JOIN_NULLABLE_RANGE))
.set_name("conditional_inner_join")
.set_type_axes_names({"Key", "Nullable"})
.add_int64_axis("left_size", JOIN_SIZE_RANGE)
.add_int64_axis("right_size", JOIN_SIZE_RANGE);

NVBENCH_BENCH_TYPES(nvbench_conditional_left_join,
NVBENCH_TYPE_AXES(JOIN_KEY_TYPE_RANGE, JOIN_NULLABLE_RANGE))
.set_name("conditional_left_join")
.set_type_axes_names({"Key", "Nullable"})
.add_int64_axis("left_size", JOIN_SIZE_RANGE)
.add_int64_axis("right_size", JOIN_SIZE_RANGE);
Loading

0 comments on commit ff1e4bb

Please sign in to comment.