From 32cfcf401eca9d20595f0b37d6f237945cdab3ac Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Thu, 8 Aug 2024 19:21:59 +0800 Subject: [PATCH] refactor(interactive): Reduce the size of codegen library (#4118) Currently, Interactive's gremlin tests utilize the codegen and compilation stack, generating a dynamic library for each query. Executing many queries consumes significant disk space. --- .github/workflows/interactive.yml | 1 + flex/bin/load_plan_and_gen.sh | 6 ++++++ flex/resources/hqps/CMakeLists.txt.template | 2 +- flex/tests/hqps/hqps_adhoc_test.sh | 1 + k8s/Makefile | 6 +++--- k8s/dockerfiles/flex-interactive.Dockerfile | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/interactive.yml b/.github/workflows/interactive.yml index 97f666d60dcb..9481af75685f 100644 --- a/.github/workflows/interactive.yml +++ b/.github/workflows/interactive.yml @@ -252,6 +252,7 @@ jobs: #set back sed -i 's/default_graph: graph_algo/default_graph: ldbc/g' ../tests/hqps/engine_config_test.yaml + rm -rf /tmp/codegen - name: Test cypher&cpp procedure generation and loading env: diff --git a/flex/bin/load_plan_and_gen.sh b/flex/bin/load_plan_and_gen.sh index 6a62b077c034..6fae6a1e5200 100755 --- a/flex/bin/load_plan_and_gen.sh +++ b/flex/bin/load_plan_and_gen.sh @@ -345,6 +345,12 @@ compile_hqps_so() { info "Finish building, output to ${output_so_path}" popd + # strip the output_so_path + strip ${output_so_path} + # clean the cmake directory, the cmake files may take up a lot of space + cmd="rm -rf ${cur_dir}/CMakeFiles" + eval ${cmd} + ################### now copy ########################## # if dst_so_path eq output_so_path, skip copying. if [ ${dst_so_path} == ${output_so_path} ]; then diff --git a/flex/resources/hqps/CMakeLists.txt.template b/flex/resources/hqps/CMakeLists.txt.template index c1d2ce5660f3..67fba9b92490 100644 --- a/flex/resources/hqps/CMakeLists.txt.template +++ b/flex/resources/hqps/CMakeLists.txt.template @@ -39,7 +39,7 @@ if(EXISTS "/opt/graphscope/include") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -Wl,-rpath,$ORIGIN -O0 -flto -Werror=unused-result -fPIC -no-pie") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -Wl,-rpath,$ORIGIN -O2 -flto -Werror=unused-result -fPIC -no-pie") add_library(${QUERY_NAME} SHARED ${PROJECT_SOURCE_DIR}/${QUERY_NAME}.cc) target_include_directories(${QUERY_NAME} PUBLIC ${FLEX_INCLUDE_PREFIX} ${FLEX_INCLUDE_PREFIX}/flex/build/engines/hqps_db/) diff --git a/flex/tests/hqps/hqps_adhoc_test.sh b/flex/tests/hqps/hqps_adhoc_test.sh index a5f9968fddfb..019499bb9da2 100644 --- a/flex/tests/hqps/hqps_adhoc_test.sh +++ b/flex/tests/hqps/hqps_adhoc_test.sh @@ -188,6 +188,7 @@ run_cypher_test(){ else echo "GRAPH_NAME: ${GRAPH_NAME} not supported, use movies, ldbc or graph_algo" fi + rm -rf /tmp/neo4j-* || true } diff --git a/k8s/Makefile b/k8s/Makefile index 84c829324f30..8657b4b52f47 100644 --- a/k8s/Makefile +++ b/k8s/Makefile @@ -154,13 +154,13 @@ interactive-experimental: flex-interactive: cd $(WORKING_DIR)/.. && \ docker build \ - -f ${DOCKERFILES_DIR}/flex-interactive.Dockerfile \ --target runtime \ + --build-arg ENABLE_COORDINATOR=${ENABLE_COORDINATOR} \ --build-arg REGISTRY=$(REGISTRY) \ --build-arg BUILDER_VERSION=$(BUILDER_VERSION) \ --build-arg ARCH=${ARCH} \ - --build-arg ENABLE_COORDINATOR=${ENABLE_COORDINATOR} \ - -t graphscope/interactive:${VERSION} . + -t graphscope/interactive:${VERSION} \ + -f ${DOCKERFILES_DIR}/flex-interactive.Dockerfile . learning: cd $(WORKING_DIR)/.. && \ diff --git a/k8s/dockerfiles/flex-interactive.Dockerfile b/k8s/dockerfiles/flex-interactive.Dockerfile index 641a16539020..693179a5f3d2 100644 --- a/k8s/dockerfiles/flex-interactive.Dockerfile +++ b/k8s/dockerfiles/flex-interactive.Dockerfile @@ -2,9 +2,9 @@ ARG REGISTRY=registry.cn-hongkong.aliyuncs.com ARG BUILDER_VERSION=latest +FROM $REGISTRY/graphscope/graphscope-dev:$BUILDER_VERSION AS builder ARG ARCH=x86_64 ARG ENABLE_COORDINATOR="false" -FROM $REGISTRY/graphscope/graphscope-dev:$BUILDER_VERSION AS builder RUN sudo mkdir -p /opt/flex && sudo chown -R graphscope:graphscope /opt/flex/ USER graphscope