[GitHub] [arrow] wesm commented on a change in pull request #7417: ARROW-9079: [C++] Write benchmark for arithmetic kernels

2020-06-13 Thread GitBox


wesm commented on a change in pull request #7417:
URL: https://github.com/apache/arrow/pull/7417#discussion_r439765330



##
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_benchmark.cc
##
@@ -67,89 +68,35 @@ static void ArrayArrayKernel(benchmark::State& state) {
   for (auto _ : state) {
 ABORT_NOT_OK(Op(lhs, rhs, nullptr).status());
   }
+  state.SetItemsProcessed(state.iterations() * array_size);
 }
 
 void SetArgs(benchmark::internal::Benchmark* bench) {
-  bench->Unit(benchmark::kMicrosecond);
-
-  for (const auto size : kMemorySizes) {
+  for (const auto size : {kL1Size, kL2Size}) {

Review comment:
   I have a processor with 22MB L3 cache so generating that much random 
data is quite expensive. If we want to benchmark arrays that big we should 
generate a smaller sample of random data and repeat/tile it to make the bigger 
array. 





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:
us...@infra.apache.org




[GitHub] [arrow] wesm commented on a change in pull request #7417: ARROW-9079: [C++] Write benchmark for arithmetic kernels

2020-06-13 Thread GitBox


wesm commented on a change in pull request #7417:
URL: https://github.com/apache/arrow/pull/7417#discussion_r439765195



##
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_benchmark.cc
##
@@ -0,0 +1,92 @@
+// 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 
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/benchmark_util.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+template 
+static void AddArrayScalarKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, Datum(CType(15))).status());
+  }
+}
+
+template 
+static void AddArrayArrayKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+  auto rhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, rhs).status());
+  }

Review comment:
   I just did this





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:
us...@infra.apache.org




[GitHub] [arrow] wesm commented on a change in pull request #7417: ARROW-9079: [C++] Write benchmark for arithmetic kernels

2020-06-12 Thread GitBox


wesm commented on a change in pull request #7417:
URL: https://github.com/apache/arrow/pull/7417#discussion_r439588572



##
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_benchmark.cc
##
@@ -0,0 +1,92 @@
+// 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 
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/benchmark_util.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+template 
+static void AddArrayScalarKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, Datum(CType(15))).status());
+  }
+}
+
+template 
+static void AddArrayArrayKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+  auto rhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, rhs).status());
+  }

Review comment:
   It's not -- there's a toggle whether the "size" that is supplied is 
bytes or items, but it's not possible to indicate both at the moment
   
   
https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/benchmark_util.h#L100-L104





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:
us...@infra.apache.org




[GitHub] [arrow] wesm commented on a change in pull request #7417: ARROW-9079: [C++] Write benchmark for arithmetic kernels

2020-06-12 Thread GitBox


wesm commented on a change in pull request #7417:
URL: https://github.com/apache/arrow/pull/7417#discussion_r439431785



##
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_benchmark.cc
##
@@ -0,0 +1,92 @@
+// 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 
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/benchmark_util.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+template 
+static void AddArrayScalarKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, Datum(CType(15))).status());
+  }
+}
+
+template 
+static void AddArrayArrayKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+  auto rhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, rhs).status());
+  }

Review comment:
   can you add the items processed here also? (should be 
`state.iterations() * lhs->length()`)

##
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_benchmark.cc
##
@@ -0,0 +1,92 @@
+// 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 
+
+#include "arrow/compute/api_scalar.h"
+#include "arrow/compute/benchmark_util.h"
+#include "arrow/compute/kernels/test_util.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+
+template 
+static void AddArrayScalarKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, Datum(CType(15))).status());
+  }
+}
+
+template 
+static void AddArrayArrayKernel(benchmark::State& state) {
+  RegressionArgs args(state);
+
+  const int64_t array_size = args.size / sizeof(CType);
+  auto min = std::numeric_limits::lowest();
+  auto max = std::numeric_limits::max();
+
+  auto rand = random::RandomArrayGenerator(kSeed);
+  auto lhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+  auto rhs = std::static_pointer_cast>(
+  rand.Numeric(array_size, min, max, args.null_proportion));
+
+  for (auto _ : state) {
+ABORT_NOT_OK(Add(lhs, rhs).status());
+  }
+}
+
+BENCHMARK_TEMPLATE(AddArrayArrayK