You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "wgtmac (via GitHub)" <gi...@apache.org> on 2023/03/31 15:45:04 UTC

[GitHub] [arrow] wgtmac commented on a diff in pull request #34811: GH-14937: [C++] String Sort / Rank Benchmarks

wgtmac commented on code in PR #34811:
URL: https://github.com/apache/arrow/pull/34811#discussion_r1154634019


##########
cpp/src/arrow/compute/kernels/vector_sort_benchmark.cc:
##########
@@ -99,6 +99,40 @@ static void ChunkedArraySortFuncInt64Benchmark(benchmark::State& state,
   ArraySortFuncBenchmark(state, runner, std::make_shared<ChunkedArray>(chunks));
 }
 
+template <typename Runner>
+static void ChunkedArraySortFuncStringBenchmark(benchmark::State& state,
+                                                const Runner& runner, int32_t min_length,
+                                                int32_t max_length) {
+  RegressionArgs args(state);
+
+  // The array_size is derived from these two equations:
+  //
+  //     size = array_size * (1.0 - args.null_proportion) * string_mean_length
+  //     string_mean_length = (max_length + min_length) / 2.0
+  const double valid_proportion = 1.0 - args.null_proportion;
+  const double array_size =
+      (valid_proportion > std::numeric_limits<double>::epsilon())
+          ? (args.size * 2) / (valid_proportion * (max_length + min_length))
+          : (args.size * 2) / (max_length + min_length);
+
+  const auto n_chunks = 10;
+  const auto array_chunk_size = static_cast<int64_t>(std::round(array_size / n_chunks));
+  auto rand = random::RandomArrayGenerator(kSeed);
+
+  ArrayVector chunks;
+  int64_t generated_array_size_in_bytes = 0;
+  for (auto i = 0; i < n_chunks; ++i) {
+    auto values =
+        rand.String(array_chunk_size, min_length, max_length, args.null_proportion);

Review Comment:
   I am not familiar with the sort function here. Does it sort null values to the first or to the end? Does the null distribution affect the benchmark result? It would be good to provide some benchmark result as well.



##########
cpp/src/arrow/compute/kernels/vector_sort_benchmark.cc:
##########
@@ -99,6 +99,40 @@ static void ChunkedArraySortFuncInt64Benchmark(benchmark::State& state,
   ArraySortFuncBenchmark(state, runner, std::make_shared<ChunkedArray>(chunks));
 }
 
+template <typename Runner>
+static void ChunkedArraySortFuncStringBenchmark(benchmark::State& state,
+                                                const Runner& runner, int32_t min_length,
+                                                int32_t max_length) {
+  RegressionArgs args(state);
+
+  // The array_size is derived from these two equations:
+  //
+  //     size = array_size * (1.0 - args.null_proportion) * string_mean_length
+  //     string_mean_length = (max_length + min_length) / 2.0
+  const double valid_proportion = 1.0 - args.null_proportion;
+  const double array_size =
+      (valid_proportion > std::numeric_limits<double>::epsilon())
+          ? (args.size * 2) / (valid_proportion * (max_length + min_length))
+          : (args.size * 2) / (max_length + min_length);
+
+  const auto n_chunks = 10;

Review Comment:
   Is `n_chunks` worth being a parameter instead of a constant value?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org