Skip to content

Commit

Permalink
[OPPRO-155] Fix benchmark (facebookincubator#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo authored Jun 16, 2022
1 parent 614543e commit 58ede3f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cpp/velox/benchmarks/BenchmarkUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ std::string getExampleFilePath(const std::string& fileName) {
"data/" + fileName);
}

void InitVeloxBackend() {
void InitVeloxBackend(facebook::velox::memory::MemoryPool* pool) {
gluten::SetBackendFactory(
[] { return std::make_shared<::velox::compute::VeloxPlanConverter>(); });
[=] { return std::make_shared<::velox::compute::VeloxPlanConverter>(pool); });
auto veloxInitializer = std::make_shared<::velox::compute::VeloxInitializer>();
}

Expand Down
3 changes: 2 additions & 1 deletion cpp/velox/benchmarks/BenchmarkUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#pragma once

#include "compute/protobuf_utils.h"
#include "velox/common/memory/Memory.h"

/// Initilize the Velox backend.
void InitVeloxBackend();
void InitVeloxBackend(facebook::velox::memory::MemoryPool* pool);

/// Get the location of a file in this project.
std::string getExampleFilePath(const std::string& fileName);
Expand Down
5 changes: 3 additions & 2 deletions cpp/velox/benchmarks/HashJoinBenchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ auto BM_HashJoinExample = [](::benchmark::State& state) {
""").write.format("parquet").save("file:///path/to/bm_part")
*/
int main(int argc, char** argv) {
InitVeloxBackend();
std::unique_ptr<facebook::velox::memory::MemoryPool> veloxPool =
facebook::velox::memory::getDefaultScopedMemoryPool();
InitVeloxBackend(veloxPool.get());
::benchmark::Initialize(&argc, argv);

if (argc < 3) {
std::cout << "Running example." << std::endl;
::benchmark::RegisterBenchmark("hash_join_example", BM_HashJoinExample);
Expand Down
3 changes: 2 additions & 1 deletion cpp/velox/benchmarks/QueryBenchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ auto BM = [](::benchmark::State& state, const std::string& datasetPath,
};

int main(int argc, char** argv) {
InitVeloxBackend();
std::unique_ptr<memory::MemoryPool> veloxPool = memory::getDefaultScopedMemoryPool();
InitVeloxBackend(veloxPool.get());
::benchmark::Initialize(&argc, argv);
// Threads cannot work well, use ThreadRange instead.
// The multi-thread performance is not correct.
Expand Down

0 comments on commit 58ede3f

Please sign in to comment.