From 24580f2493920c5a6546beca0c4b16b9182e8221 Mon Sep 17 00:00:00 2001 From: MMeent Date: Wed, 6 Oct 2021 14:37:27 +0200 Subject: [PATCH] Improve build system: (#703) - Build postgresql with -O2 for releases - Make make make postgresql with 8 parallel threads The node is xlarge, so it has 8 vCPU available --- .circleci/config.yml | 22 ++++++++++++++++------ Makefile | 18 ++++++++++++++---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a168fef1c8..24d151f765 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,6 +24,12 @@ jobs: # A job to build postgres build-postgres: executor: zenith-build-executor + parameters: + build_type: + type: enum + enum: ["debug", "release"] + environment: + BUILD_TYPE: << parameters.build_type >> steps: # Checkout the git repo (circleci doesn't have a flag to enable submodules here) - checkout @@ -39,7 +45,7 @@ jobs: name: Restore postgres cache keys: # Restore ONLY if the rev key matches exactly - - v03-postgres-cache-{{ checksum "/tmp/cache-key-postgres" }} + - v04-postgres-cache-<< parameters.build_type >>-{{ checksum "/tmp/cache-key-postgres" }} # FIXME We could cache our own docker container, instead of installing packages every time. - run: @@ -59,12 +65,12 @@ jobs: if [ ! -e tmp_install/bin/postgres ]; then # "depth 1" saves some time by not cloning the whole repo git submodule update --init --depth 1 - make postgres + make postgres -j8 fi - save_cache: name: Save postgres cache - key: v03-postgres-cache-{{ checksum "/tmp/cache-key-postgres" }} + key: v04-postgres-cache-<< parameters.build_type >>-{{ checksum "/tmp/cache-key-postgres" }} paths: - tmp_install @@ -96,7 +102,7 @@ jobs: name: Restore postgres cache keys: # Restore ONLY if the rev key matches exactly - - v03-postgres-cache-{{ checksum "/tmp/cache-key-postgres" }} + - v04-postgres-cache-<< parameters.build_type >>-{{ checksum "/tmp/cache-key-postgres" }} - restore_cache: name: Restore rust cache @@ -328,14 +334,18 @@ workflows: build_and_test: jobs: - check-codestyle - - build-postgres + - build-postgres: + name: build-postgres-<< matrix.build_type >> + matrix: + parameters: + build_type: ["debug", "release"] - build-zenith: name: build-zenith-<< matrix.build_type >> matrix: parameters: build_type: ["debug", "release"] requires: - - build-postgres + - build-postgres-<< matrix.build_type >> - run-pytest: name: pg_regress-tests-<< matrix.build_type >> matrix: diff --git a/Makefile b/Makefile index 7daf3697c7..2edf2a6b4a 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,18 @@ else SECCOMP = endif +# +# We differentiate between release / debug build types using the BUILD_TYPE +# environment variable. +# +ifeq ($(BUILD_TYPE),release) + PG_CONFIGURE_OPTS = --enable-debug + PG_CFLAGS = -O2 -g3 ${CFLAGS} +else + PG_CONFIGURE_OPTS = --enable-debug --enable-cassert --enable-depend + PG_CFLAGS = -O0 -g3 ${CFLAGS} +endif + # # Top level Makefile to build Zenith and PostgreSQL # @@ -30,10 +42,8 @@ tmp_install/build/config.status: +@echo "Configuring postgres build" mkdir -p tmp_install/build (cd tmp_install/build && \ - ../../vendor/postgres/configure CFLAGS='-O0 -g3 $(CFLAGS)' \ - --enable-cassert \ - --enable-debug \ - --enable-depend \ + ../../vendor/postgres/configure CFLAGS='$(PG_CFLAGS)' \ + $(PG_CONFIGURE_OPTS) \ $(SECCOMP) \ --prefix=$(abspath tmp_install) > configure.log)