iChauster commented on code in PR #13426: URL: https://github.com/apache/arrow/pull/13426#discussion_r916473620
########## cpp/src/arrow/compute/exec/asof_join_benchmark.cc: ########## @@ -0,0 +1,568 @@ +// 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 <boost/process.hpp> +#include <string> + +#include "benchmark/benchmark.h" + +#include "arrow/compute/exec/test_util.h" +#include "arrow/csv/writer.h" +#include "arrow/dataset/file_parquet.h" +#include "arrow/filesystem/api.h" +#include "arrow/ipc/api.h" +#include "arrow/table.h" +#include "arrow/testing/future_util.h" + +namespace arrow { +namespace compute { + +static const char* time_col = "time"; +static const char* key_col = "id"; +static bool createdBenchmarkFiles = false; +// static std::shared_ptr<arrow::internal::TemporaryDir> temp_dir = Review Comment: @westonpace, this doesn't work for me locally, is my usage correct? ########## cpp/src/arrow/compute/exec/asof_join_benchmark.cc: ########## @@ -0,0 +1,568 @@ +// 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 <boost/process.hpp> +#include <string> + +#include "benchmark/benchmark.h" + +#include "arrow/compute/exec/test_util.h" +#include "arrow/csv/writer.h" +#include "arrow/dataset/file_parquet.h" +#include "arrow/filesystem/api.h" +#include "arrow/ipc/api.h" +#include "arrow/table.h" +#include "arrow/testing/future_util.h" + +namespace arrow { +namespace compute { + +static const char* time_col = "time"; +static const char* key_col = "id"; +static bool createdBenchmarkFiles = false; +// static std::shared_ptr<arrow::internal::TemporaryDir> temp_dir = +// arrow::internal::TemporaryDir::Make("./benchmark_data/").ValueOrDie(); + +struct ReaderNodeTableProperties { + ExecNode* execNode; + size_t total_rows; + size_t total_bytes; +}; + +// requires export PYTHONPATH=/path/to/benchmark_scripts/table_generation +// calls generate_benchmark_files to create tables (feather files) varying in frequency, +// width, key density for benchmarks. places generated files in benchmark/data. This +// operation runs once at the beginning of benchmarking. +static void DoSetup() { + if (!createdBenchmarkFiles) { + boost::process::system("mkdir benchmark_data/"); + std::error_code err; + boost::process::system("python3 -m generate_benchmark_files ./benchmark_data/", err); + if (err) { + std::cerr << "Could not generate python files." << std::endl; + std::cerr << "Error Message: " << err.message() << std::endl; + } + createdBenchmarkFiles = true; + } +} + +static std::vector<std::string> generateRightHandTables(std::string freq, int width_index, + int num_tables, + int num_ids_index) { + auto const generate_file_name = [](std::string freq, std::string is_wide, + std::string num_ids, std::string num) { + return freq + "_" + is_wide + "_" + num_ids + num + ".feather"; + }; + + std::string width_table[] = {"20_cols", "100_cols", "500_cols"}; + std::string num_ids_table[] = {"100_ids", "5000_ids", "10000_ids"}; + + std::vector<std::string> right_hand_tables; + right_hand_tables.reserve(num_tables); + + for (int j = 1; j <= num_tables; j++) { + right_hand_tables.push_back(generate_file_name( + freq, width_table[width_index], num_ids_table[num_ids_index], std::to_string(j))); + } + return right_hand_tables; +} + +std::shared_ptr<arrow::Schema> get_resultant_join_schema( Review Comment: I have a few pieces of code (this function and `output_results_to_csv`) that are related to reading the output of tables from plans / `StartAndCollect` that I used to verify correctness of outputs. I haven't really seen examples like this around the codebase but I'm not sure they fit here. Should I move this into some utility? ########## cpp/src/arrow/compute/exec/asof_join_benchmark.cc: ########## @@ -0,0 +1,568 @@ +// 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 <boost/process.hpp> +#include <string> + +#include "benchmark/benchmark.h" + +#include "arrow/compute/exec/test_util.h" +#include "arrow/csv/writer.h" +#include "arrow/dataset/file_parquet.h" +#include "arrow/filesystem/api.h" +#include "arrow/ipc/api.h" +#include "arrow/table.h" +#include "arrow/testing/future_util.h" + +namespace arrow { +namespace compute { + +static const char* time_col = "time"; +static const char* key_col = "id"; +static bool createdBenchmarkFiles = false; +// static std::shared_ptr<arrow::internal::TemporaryDir> temp_dir = +// arrow::internal::TemporaryDir::Make("./benchmark_data/").ValueOrDie(); + +struct ReaderNodeTableProperties { + ExecNode* execNode; + size_t total_rows; + size_t total_bytes; +}; + +// requires export PYTHONPATH=/path/to/benchmark_scripts/table_generation +// calls generate_benchmark_files to create tables (feather files) varying in frequency, +// width, key density for benchmarks. places generated files in benchmark/data. This +// operation runs once at the beginning of benchmarking. +static void DoSetup() { + if (!createdBenchmarkFiles) { + boost::process::system("mkdir benchmark_data/"); + std::error_code err; + boost::process::system("python3 -m generate_benchmark_files ./benchmark_data/", err); + if (err) { Review Comment: I think you mentioned handling errors gracefully, is this sufficient? I suppose we should try and exit the program as well. -- 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]
