From 24657d2fd7b705d20215f20e081f67b818bdd27b Mon Sep 17 00:00:00 2001 From: "xiaolei.zl" Date: Thu, 5 Sep 2024 16:18:05 +0800 Subject: [PATCH] adapt to boost-leaf Committed-by: xiaolei.zl from Dev container --- .devcontainer/devcontainer.json | 2 +- flex/bin/adhoc_runner.cc | 51 ++++++++++++++++++---------- flex/scripts/install_dependencies.sh | 12 ++++++- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4e5ffa8b324d..7b66de3c741c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ { "name": "GraphScope", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "registry.cn-hongkong.aliyuncs.com/graphscope/graphscope-dev:latest", + "image": "registry.cn-hongkong.aliyuncs.com/graphscope/graphscope-dev:v0.24.0-amd", // TODO(fixme) // Features to add to the dev container. More info: https://containers.dev/features. "features": { diff --git a/flex/bin/adhoc_runner.cc b/flex/bin/adhoc_runner.cc index d2d8203856d4..976dac8b51f4 100644 --- a/flex/bin/adhoc_runner.cc +++ b/flex/bin/adhoc_runner.cc @@ -23,6 +23,7 @@ #include "flex/engines/graph_db/runtime/adhoc/runtime.h" namespace bpo = boost::program_options; +namespace bl = boost::leaf; std::string read_pb(const std::string& filename) { std::ifstream file(filename, std::ios::binary); @@ -74,6 +75,32 @@ void load_params(const std::string& filename, } } +gs::runtime::Context eval_plan( + const physical::PhysicalPlan& plan, gs::ReadTransaction& txn, + const std::map& params) { + gs::runtime::Context ctx; + { + ctx = bl::try_handle_all( + [&plan, &txn, ¶ms]() { + return gs::runtime::runtime_eval(plan, txn, params); + }, + [&ctx](const gs::Status& err) { + LOG(FATAL) << "Error in execution: " << err.error_message(); + return ctx; + }, + [&](const bl::error_info& err) { + LOG(FATAL) << "boost leaf error: " << err.error().value() << ", " + << err.exception()->what(); + return ctx; + }, + [&]() { + LOG(FATAL) << "Unknown error in execution"; + return ctx; + }); + } + return ctx; +} + int main(int argc, char** argv) { bpo::options_description desc("Usage:"); desc.add_options()("help", "Display help message")( @@ -158,41 +185,29 @@ int main(int argc, char** argv) { double t1 = -grape::GetCurrentTime(); for (int i = 0; i < query_num; ++i) { auto& m = map[i % params_num]; - auto ctx = gs::runtime::runtime_eval(pb, txn, m); - if (!ctx) { - LOG(ERROR) << "Eval plan failed: " << ctx.error(); - return -1; - } + auto ctx = eval_plan(pb, txn, m); gs::Encoder output(outputs[i]); - gs::runtime::eval_sink(ctx.value(), txn, output); + gs::runtime::eval_sink(ctx, txn, output); } t1 += grape::GetCurrentTime(); double t2 = -grape::GetCurrentTime(); for (int i = 0; i < query_num; ++i) { auto& m = map[i % params_num]; - auto ctx = gs::runtime::runtime_eval(pb, txn, m); - if (!ctx) { - LOG(ERROR) << "Eval plan failed: " << ctx.error(); - return -1; - } + auto ctx = eval_plan(pb, txn, m); outputs[i].clear(); gs::Encoder output(outputs[i]); - gs::runtime::eval_sink(ctx.value(), txn, output); + gs::runtime::eval_sink(ctx, txn, output); } t2 += grape::GetCurrentTime(); double t3 = -grape::GetCurrentTime(); for (int i = 0; i < query_num; ++i) { auto& m = map[i % params_num]; - auto ctx = gs::runtime::runtime_eval(pb, txn, m); - if (!ctx) { - LOG(ERROR) << "Eval plan failed: " << ctx.error(); - return -1; - } + auto ctx = eval_plan(pb, txn, m); outputs[i].clear(); gs::Encoder output(outputs[i]); - gs::runtime::eval_sink(ctx.value(), txn, output); + gs::runtime::eval_sink(ctx, txn, output); } t3 += grape::GetCurrentTime(); diff --git a/flex/scripts/install_dependencies.sh b/flex/scripts/install_dependencies.sh index cc298d4463f6..42712f99c60b 100755 --- a/flex/scripts/install_dependencies.sh +++ b/flex/scripts/install_dependencies.sh @@ -14,11 +14,21 @@ echo "parallelism: $parallelism" sudo apt-get update && sudo apt install -y \ ninja-build ragel libhwloc-dev libnuma-dev libpciaccess-dev vim wget curl \ git g++ libunwind-dev libgoogle-glog-dev cmake libopenmpi-dev default-jdk libcrypto++-dev \ - libboost-all-dev libxml2-dev protobuf-compiler libprotobuf-dev libncurses5-dev libcurl4-openssl-dev + libxml2-dev protobuf-compiler libprotobuf-dev libncurses5-dev libcurl4-openssl-dev sudo apt install -y xfslibs-dev libgnutls28-dev liblz4-dev maven openssl pkg-config \ libsctp-dev gcc make python3 systemtap-sdt-dev libtool libyaml-cpp-dev \ libc-ares-dev stow libfmt-dev diffutils valgrind doxygen python3-pip net-tools graphviz +# install boost +pushd /tmp/ +curl -L -o boost_1_75_0.tar.gz "https://graphscope.oss-cn-beijing.aliyuncs.com/dependencies/boost_1_75_0.tar.gz" +tar -xzf boost_1_75_0.tar.gz +pushd boost_1_75_0 && ./bootstrap.sh \ +--with-libraries=system,filesystem,context,program_options,regex,thread,chrono,date_time # unit_test_framework used by seastar +./b2 install link=shared runtime-link=shared variant=release threading=multi --with-test +popd && rm -rf boost_1_75_0 +popd && rm boost_1_75_0.tar.gz + pushd /tmp git clone https://github.com/alibaba/libgrape-lite.git cd libgrape-lite