You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/10/26 16:22:16 UTC

[GitHub] [arrow] david1437 opened a new pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

david1437 opened a new pull request #8529:
URL: https://github.com/apache/arrow/pull/8529


   


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

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



[GitHub] [arrow] github-actions[bot] commented on pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8529:
URL: https://github.com/apache/arrow/pull/8529#issuecomment-716717268


   https://issues.apache.org/jira/browse/ARROW-5394


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

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



[GitHub] [arrow] pitrou commented on pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #8529:
URL: https://github.com/apache/arrow/pull/8529#issuecomment-724216961


   Ok, it seems the git situation is still a bit messed up, I'll fix it up :-)


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

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



[GitHub] [arrow] pitrou commented on a change in pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #8529:
URL: https://github.com/apache/arrow/pull/8529#discussion_r519891890



##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {

Review comment:
       Should be `value_set_length`.

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));

Review comment:
       Is the first call for warmup?

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[2]->size()) +
+                          (state.iterations() * value_set->data()->buffers[2]->size()));
+}
+
+template <typename Type>
+static void SetLookupBenchmarkNumeric(benchmark::State& state,
+                                      const std::string& func_name,
+                                      const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.Numeric<Type>(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.Numeric<Type>(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[1]->size()) +
+                          (state.iterations() * value_set->data()->buffers[1]->size()));
+}
+
+static void IndexInStringSmall(benchmark::State& state) {

Review comment:
       Call this "SmallSet" instead of "Small"?

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[2]->size()) +
+                          (state.iterations() * value_set->data()->buffers[2]->size()));
+}
+
+template <typename Type>
+static void SetLookupBenchmarkNumeric(benchmark::State& state,
+                                      const std::string& func_name,
+                                      const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;

Review comment:
       Well, for more realistic data, how about using `std::numeric_limits<Type::c_type>::max()` instead?

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));

Review comment:
       It doesn't seem logical to add this second term. The "items" processed are the input array items.

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[2]->size()) +
+                          (state.iterations() * value_set->data()->buffers[2]->size()));
+}
+
+template <typename Type>
+static void SetLookupBenchmarkNumeric(benchmark::State& state,
+                                      const std::string& func_name,
+                                      const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.Numeric<Type>(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.Numeric<Type>(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[1]->size()) +
+                          (state.iterations() * value_set->data()->buffers[1]->size()));
+}
+
+static void IndexInStringSmall(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IsInStringSmall(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "is_in_meta_binary", state.range(0));
+}
+
+static void IndexInStringLarge(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "index_in_meta_binary", 1 << 20);

Review comment:
       `1 << 20` sounds very large and irrealistic for a lookup set. How about `1 << 10` (which is already quite a lot of lookup strings).

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[2]->size()) +
+                          (state.iterations() * value_set->data()->buffers[2]->size()));

Review comment:
       Ditto here.

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[2]->size()) +
+                          (state.iterations() * value_set->data()->buffers[2]->size()));
+}
+
+template <typename Type>
+static void SetLookupBenchmarkNumeric(benchmark::State& state,
+                                      const std::string& func_name,
+                                      const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.Numeric<Type>(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.Numeric<Type>(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[1]->size()) +
+                          (state.iterations() * value_set->data()->buffers[1]->size()));
+}
+
+static void IndexInStringSmall(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IsInStringSmall(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "is_in_meta_binary", state.range(0));
+}
+
+static void IndexInStringLarge(benchmark::State& state) {

Review comment:
       "LargeSet"?

##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[2]->size()) +
+                          (state.iterations() * value_set->data()->buffers[2]->size()));
+}
+
+template <typename Type>
+static void SetLookupBenchmarkNumeric(benchmark::State& state,
+                                      const std::string& func_name,
+                                      const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.Numeric<Type>(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.Numeric<Type>(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  for (auto _ : state) {
+    ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));
+  }
+  state.SetItemsProcessed((state.iterations() * array_length) +
+                          (state.iterations() * valueSetLength));
+  state.SetBytesProcessed((state.iterations() * values->data()->buffers[1]->size()) +
+                          (state.iterations() * value_set->data()->buffers[1]->size()));
+}
+
+static void IndexInStringSmall(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IsInStringSmall(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "is_in_meta_binary", state.range(0));
+}
+
+static void IndexInStringLarge(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "index_in_meta_binary", 1 << 20);
+}
+
+static void IsInStringLarge(benchmark::State& state) {
+  SetLookupBenchmarkString(state, "is_in_meta_binary", 1 << 20);
+}
+
+static void IndexInInt8Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int8Type>(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IndexInInt16Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int16Type>(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IndexInInt32Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int32Type>(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IndexInInt64Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int64Type>(state, "index_in_meta_binary", state.range(0));
+}
+
+static void IsInInt8Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int8Type>(state, "is_in_meta_binary", state.range(0));
+}
+
+static void IsInInt16Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int16Type>(state, "is_in_meta_binary", state.range(0));
+}
+
+static void IsInInt32Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int32Type>(state, "is_in_meta_binary", state.range(0));
+}
+
+static void IsInInt64Small(benchmark::State& state) {
+  SetLookupBenchmarkNumeric<Int64Type>(state, "is_in_meta_binary", state.range(0));
+}
+
+BENCHMARK(IndexInStringSmall)->RangeMultiplier(2)->Range(2, 64);

Review comment:
       We may cut down on the number of benchmark instances and use `RangeMultiplier(4)` instead.




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

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



[GitHub] [arrow] david1437 commented on pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
david1437 commented on pull request #8529:
URL: https://github.com/apache/arrow/pull/8529#issuecomment-716742511


   CI errors seem unrelated


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

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



[GitHub] [arrow] david1437 commented on a change in pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
david1437 commented on a change in pull request #8529:
URL: https://github.com/apache/arrow/pull/8529#discussion_r520002950



##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_benchmark.cc
##########
@@ -0,0 +1,143 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/kernels/common.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+static void SetLookupBenchmarkString(benchmark::State& state,
+                                     const std::string& func_name,
+                                     const int32_t valueSetLength) {
+  const int64_t array_length = 1 << 20;
+  const int64_t value_min_size = 0;
+  const int64_t value_max_size = 32;
+  const double null_probability = 0.01;
+  random::RandomArrayGenerator rng(kSeed);
+
+  auto values =
+      rng.String(array_length, value_min_size, value_max_size, null_probability);
+  auto value_set =
+      rng.String(valueSetLength, value_min_size, value_max_size, null_probability);
+  ABORT_NOT_OK(CallFunction(func_name, {values, value_set}));

Review comment:
       Yes exactly




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

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



[GitHub] [arrow] pitrou closed pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
pitrou closed pull request #8529:
URL: https://github.com/apache/arrow/pull/8529


   


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

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



[GitHub] [arrow] david1437 commented on pull request #8529: ARROW-5394: [C++][Benchmark] IsIn and IndexIn benchmark for integer and string types

Posted by GitBox <gi...@apache.org>.
david1437 commented on pull request #8529:
URL: https://github.com/apache/arrow/pull/8529#issuecomment-724171027


   Not too proficient with git so hopefully, I rebased correctly.  Added changes as you recommended.


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

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