HuaHuaY commented on code in PR #50281: URL: https://github.com/apache/arrow/pull/50281#discussion_r3518026950
########## cpp/src/arrow/util/nested_bitmap_traversal_benchmark.cc: ########## @@ -0,0 +1,154 @@ +// 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 <cstdint> +#include <cstdlib> +#include <memory> + +#include "arrow/array/array_base.h" +#include "arrow/array/array_nested.h" +#include "arrow/array/array_primitive.h" +#include "arrow/testing/gtest_util.h" +#include "arrow/testing/random.h" +#include "arrow/type.h" +#include "arrow/util/bit_block_counter.h" +#include "arrow/util/bit_run_reader.h" +#include "arrow/util/bitmap_ops.h" + +namespace arrow::internal { + +struct NestedBitmapTraversalBenchmark { Review Comment: I modified this benchmark to count the number of valid values in a `list<int8>` given an outer bitmap. But after testing the new benchmark, I discovered something unexpected: the baseline approach—`BitmapAnd` combined with `VisitSetBitRunsVoid`—actually turned out to be the fastest. I attribute this to the bitmap's minimal memory footprint, where the performance gains from `BitmapAnd`'s vectorization outweigh the overhead of materializing the bitmap. Consequently, I have decided to close this PR and simply materialize the bitmap directly when needed. At the same time, `VisitTwoBitBlocks` appears to offer the worst performance. I’m curious whether replacing the current usages of `VisitTwoBitBlocks` with `bitmapAnd` might actually improve performance. ########## cpp/src/arrow/util/nested_bitmap_traversal_benchmark.cc: ########## @@ -0,0 +1,154 @@ +// 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 <cstdint> +#include <cstdlib> +#include <memory> + +#include "arrow/array/array_base.h" +#include "arrow/array/array_nested.h" +#include "arrow/array/array_primitive.h" +#include "arrow/testing/gtest_util.h" +#include "arrow/testing/random.h" +#include "arrow/type.h" +#include "arrow/util/bit_block_counter.h" +#include "arrow/util/bit_run_reader.h" +#include "arrow/util/bitmap_ops.h" + +namespace arrow::internal { + +struct NestedBitmapTraversalBenchmark { Review Comment: I modified this benchmark to count the number of valid values in a `list<int8>` given an outer bitmap. But after testing the new benchmark, I discovered something unexpected: the baseline approach—`BitmapAnd` combined with `VisitSetBitRunsVoid`—actually turned out to be the fastest. I attribute this to the bitmap's minimal memory footprint, where the performance gains from `BitmapAnd`'s vectorization outweigh the overhead of materializing the bitmap. Consequently, I have decided to close this PR and simply materialize the bitmap directly when needed. At the same time, `VisitTwoBitBlocks` appears to offer the worst performance. I’m curious whether replacing the current usages of `VisitTwoBitBlocks` with `BitmapAnd` might actually improve performance. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
