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 2022/03/30 11:27:39 UTC
[GitHub] [arrow] sanjibansg opened a new pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
sanjibansg opened a new pull request #12755:
URL: https://github.com/apache/arrow/pull/12755
This PR adds an Expression Execution benchmark in `arrow-compute` which uses the batch size as a parameter and measures the bytes per second for the executing the scalar expression.
```
Running ./arrow-compute-expression-execution-benchmark
Run on (10 X 24.1213 MHz CPU s)
CPU Caches:
L1 Data 64 KiB (x10)
L1 Instruction 128 KiB (x10)
L2 Unified 4096 KiB (x5)
Load Average: 2.19, 2.04, 2.08
-----------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
-----------------------------------------------------------------------------
Execution/1 4919345 ns 4919150 ns 140 bytes_per_second=15.1461G/s
Execution/10 4835820 ns 4835814 ns 145 bytes_per_second=1.54071G/s
Execution/100 5074145 ns 5073754 ns 138 bytes_per_second=150.37M/s
Execution/1000 7421182 ns 7420883 ns 94 bytes_per_second=10.281M/s
Execution/10000 29646953 ns 29645130 ns 23 bytes_per_second=263.534k/s
Execution/100000 252627153 ns 252615333 ns 3 bytes_per_second=3.09265k/s
Execution/1000000 2478820334 ns 2478711000 ns 1 bytes_per_second=32.2748/s
Execution/10000000 24733585625 ns 24730194000 ns 1 bytes_per_second=0.323491/s
```
--
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
[GitHub] [arrow] westonpace commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
westonpace commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838571535
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
Also, I think this would need to be `state.iterations() * 8 * array_size * array_batches`
--
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
[GitHub] [arrow] pitrou commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838547675
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
At least this would be more informative as items-per-second, because the byte size of the data is irrelevant here.
--
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
[GitHub] [arrow] drin commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
drin commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838882448
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
Ah, thanks for the clarification; that makes a lot of sense.
--
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
[GitHub] [arrow] westonpace commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
westonpace commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838565356
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
This is probably my fault as I asked for bytes-per-second in the JIRA issue. I think items per second is a good compromise.
--
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
[GitHub] [arrow] github-actions[bot] commented on pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#issuecomment-1083035417
https://issues.apache.org/jira/browse/ARROW-16014
--
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
[GitHub] [arrow] drin commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
drin commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838738104
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
If the items are homogenous types, then I think bytes per second and items per second are interchangeable, especially for simple data types.
I think that if this benchmark is expanded it would be useful to see both, for benchmarking heterogenous types or complex types.
--
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
[GitHub] [arrow] drin commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
drin commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838741993
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
unless I'm misunderstanding what the bytes processed is counting? I see a single array being processed, so I think items and bytes are directly related.
--
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
[GitHub] [arrow] westonpace commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
westonpace commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838761964
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
They are directly related and yes, interchangeable, but I think I agree with @pitrou that items/second is probably more likely to be all we need. It also makes it clearer to the reader what is being tested. The code we are testing here (kernel dispatch) never actually operates on the arrays themselves. It is only responsible for passing the arrays to the appropriate kernels. So the size (or byte width) of the array shouldn't matter too much.
The kernel benchmarks themselves are a different story. And you will notice that in `compare_benchmark.cc` for example we test the kernel on a wide variety of data types.
--
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
[GitHub] [arrow] westonpace commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
westonpace commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838574799
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
Review comment:
It makes it so that each iteration is processing 10 million elements. Then the CPU/Time column is meaningful because it shows the time required to do the exact same amount of "work" at different batch sizes.
--
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
[GitHub] [arrow] pitrou commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838542907
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
+ ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+ }
+ state.SetBytesProcessed(state.iterations() * 8 * array_size);
Review comment:
Bytes-per-second is not really a measure of overhead, is it?
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
Review comment:
Why this expression in particular?
If we want to measure evaluation overhead, we should use a trivial expression, such as a cast from date64 to int64 (which is effectively zero-copy).
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
+
+static void Execution(benchmark::State& state) {
+ const auto array_batches = static_cast<int32_t>(state.range(0));
+ const auto array_size = 10000000 / array_batches;
+
+ ExecContext ctx;
+ auto dataset_schema = schema({
+ field("x", int64()),
+ });
+ ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+ /*length=*/1);
+
+ ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+ for (auto _ : state) {
+ for (int it = 0; it < array_batches; ++it)
Review comment:
I don't understand what the point of `array_batches` is here. You're having a pure repetition loop inside another pure repetition loop :-)
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
Review comment:
Same question here.
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
Review comment:
Is this include file required?
##########
File path: cpp/src/arrow/compute/exec/CMakeLists.txt
##########
@@ -36,6 +36,7 @@ add_arrow_compute_test(union_node_test PREFIX "arrow-compute")
add_arrow_compute_test(util_test PREFIX "arrow-compute")
add_arrow_benchmark(expression_benchmark PREFIX "arrow-compute")
+add_arrow_benchmark(expression_execution_benchmark PREFIX "arrow-compute")
Review comment:
I'm not sure it's useful to create a separate executable for this. Simply add the benchmark to the existing expression benchmark file?
--
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
[GitHub] [arrow] westonpace commented on a change in pull request #12755: ARROW-16014: [C++] Create more benchmarks for measuring expression evaluation overhead
Posted by GitBox <gi...@apache.org>.
westonpace commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838679395
##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+ and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), literal(0)));
Review comment:
I think this is a good idea though it might be nice to do both. My original thinking was to purely measure overhead and this suggestion will improve that.
However, looking at the numbers we are getting, it is interesting to see that there is a switching point between 100 & 1000 where the bottleneck switches from kernel execution to kernel overhead. I think this is helpful context and my goal is to drive that down just a little further so we can keep that 5mil ns performance all the way to 1000 or 10000. So it might be nice still to have both a "zero copy" benchmark and a "simple operation that needs to copy" benchmark.
--
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