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

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

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


##########
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);
+    auto array = arrow::internal::checked_pointer_cast<const arrow::StringArray>(values);
+    generated_array_size_in_bytes += array->value_data()->size();
+    chunks.push_back(std::move(values));
+  }
+
+  state.counters["generated_array_size"] = generated_array_size_in_bytes;

Review Comment:
   I'm not certain this is useful as a counter.
   
   I would much rather see (for all of the benchmarks in this file and, ideally, all compute benchmarks) a bytes-per-second counter.  If I had that then I wouldn't care about generated_array_size.
   



##########
cpp/src/arrow/compute/kernels/vector_sort_benchmark.cc:
##########
@@ -154,6 +222,12 @@ static void ChunkedArraySortIndicesInt64Wide(benchmark::State& state) {
   ChunkedArraySortFuncInt64Benchmark(state, SortRunner(state), min, max);
 }
 
+static void ChunkedArraySortIndicesString(benchmark::State& state) {
+  const auto min_length = 0;
+  const auto max_length = 32;

Review Comment:
   Given that you went to the trouble of making this configurable, should we have a `ArraySortIndicesStringShort` and `ArraySortIndicesStringLong` similar to how we have `Narrow` and `Wide` versions of the integer benchmarks?



-- 
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