Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-30 15:20:49 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-31 11:39:43 +0300
commit661df273ca29beff08f922474c1bb33415f83e2b (patch)
tree00bf7f6f70766d6242269c8e9a005520b3efa02c
parent76402fead439fc9b1ee4cb6ef20619ecfe4aee34 (diff)
Makefile: Fix performance issues caused by tracing in binariespks-makefile-per-target-go-flags
We have observed multiple times already that short-lived Go binaries spawned by Gitaly have major initialization overhead because they need to initialize the `awk-sdk-go` dependency. This dependency has megabytes of maps containing all the different datacenters of AWS, and this cost quickly adds up in case the binary only does very limited work. As a result, we have seen runtime of `gitaly-hooks` and `gitaly-lfs-smudge` to be dominated by this initialization. The thing though is that neither of these has a direct dependency on `awk-sdk-go`. Instead, it is being pulled in as an indirect dependency via `labkit`, but only if compiled with tracing enabled. And we do in fact compile all binaries with tracing enabled by default. Ultimately, having tracing in such short-lived binaries isn't all that helpful, and in combination with the performance issues we're observing it is time to drop the tracing infrastructure there. We cannot drop the dependency on `labkit` though: it's required so that we can inject and extract the correlation ID via the environment. But luckily, tracing is only enabled when specific build tags are set. Conversely, if they're unset, we also don't pull in the problematic `awk-sdk-go` package. Fix the performance issue by splitting up Go build tags to be per binary. Like this, we can keep tracing enabled in both Praefect and Gitaly while we disable it for all the other binaries. Furthermore, this also allows us to inject the Git2go-specific build tags only for the `gitaly-git2go-v14` binary. Changelog: fixed
-rw-r--r--Makefile13
1 files changed, 8 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 0d517e1f9..f5a135df5 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,8 @@ GITALY_PACKAGE := gitlab.com/gitlab-org/gitaly/v14
BUILD_TIME := $(shell date +"%Y%m%d.%H%M%S")
GITALY_VERSION := $(shell ${GIT} describe --match v* 2>/dev/null | sed 's/^v//' || cat ${SOURCE_DIR}/VERSION 2>/dev/null || echo unknown)
GO_LDFLAGS := -X ${GITALY_PACKAGE}/internal/version.version=${GITALY_VERSION} -X ${GITALY_PACKAGE}/internal/version.buildtime=${BUILD_TIME} -X ${GITALY_PACKAGE}/internal/version.moduleVersion=${MODULE_VERSION}
-GO_BUILD_TAGS := tracer_static,tracer_static_jaeger,tracer_static_stackdriver,continuous_profiler_stackdriver,static,system_libgit2
+SERVER_BUILD_TAGS := tracer_static,tracer_static_jaeger,tracer_static_stackdriver,continuous_profiler_stackdriver
+GIT2GO_BUILD_TAGS := static,system_libgit2
# Dependency versions
GOLANGCI_LINT_VERSION ?= 1.44.2
@@ -259,12 +260,11 @@ find_go_sources = $(shell find ${SOURCE_DIR} -type d \( -name ruby -o -nam
# run_go_tests will execute Go tests with all required parameters. Its
# behaviour can be modified via the following variables:
#
-# GO_BUILD_TAGS: tags used to build the executables
# TEST_OPTIONS: any additional options
# TEST_PACKAGES: packages which shall be tested
run_go_tests = PATH='${SOURCE_DIR}/internal/testhelper/testdata/home/bin:${PATH}' \
TEST_TMP_DIR='${TEST_TMP_DIR}' \
- ${GOTESTSUM} --format ${TEST_FORMAT} --junitfile ${TEST_REPORT} -- -ldflags '${GO_LDFLAGS}' -tags '${GO_BUILD_TAGS}' ${TEST_OPTIONS} ${TEST_PACKAGES}
+ ${GOTESTSUM} --format ${TEST_FORMAT} --junitfile ${TEST_REPORT} -- -ldflags '${GO_LDFLAGS}' -tags '${SERVER_BUILD_TAGS},${GIT2GO_BUILD_TAGS}' ${TEST_OPTIONS} ${TEST_PACKAGES}
unexport GOROOT
export GOBIN = ${BUILD_DIR}/bin
@@ -311,6 +311,9 @@ help:
## Build Go binaries and install required Ruby Gems.
build: ${SOURCE_DIR}/.ruby-bundle ${GITALY_EXECUTABLES}
+gitaly: GO_BUILD_TAGS = ${SERVER_BUILD_TAGS}
+praefect: GO_BUILD_TAGS = ${SERVER_BUILD_TAGS}
+gitaly-git2go-v14: GO_BUILD_TAGS = ${GIT2GO_BUILD_TAGS}
gitaly-git2go-v14: libgit2
.PHONY: ${GITALY_EXECUTABLES}
@@ -423,7 +426,7 @@ check-mod-tidy:
.PHONY: lint
## Run Go linter.
lint: ${GOLANGCI_LINT} libgit2
- ${Q}${GOLANGCI_LINT} run --build-tags "${GO_BUILD_TAGS}" --out-format tab --config ${GOLANGCI_LINT_CONFIG} ${GOLANGCI_LINT_OPTIONS}
+ ${Q}${GOLANGCI_LINT} run --build-tags "${SERVER_BUILD_TAGS},${GIT2GO_BUILD_TAGS}" --out-format tab --config ${GOLANGCI_LINT_CONFIG} ${GOLANGCI_LINT_OPTIONS}
.PHONY: format
## Run Go formatter and adjust imports.
@@ -530,7 +533,7 @@ ${SOURCE_DIR}/NOTICE: ${BUILD_DIR}/NOTICE
${BUILD_DIR}/NOTICE: ${GO_LICENSES} clean-ruby-vendor-go
${Q}rm -rf ${BUILD_DIR}/licenses
- ${Q}GOOS=linux GOFLAGS="-tags=${GO_BUILD_TAGS}" ${GO_LICENSES} save ${SOURCE_DIR}/... --save_path=${BUILD_DIR}/licenses
+ ${Q}GOOS=linux GOFLAGS="-tags=${SERVER_BUILD_TAGS},${GIT2GO_BUILD_TAGS}" ${GO_LICENSES} save ${SOURCE_DIR}/... --save_path=${BUILD_DIR}/licenses
${Q}go run ${SOURCE_DIR}/_support/noticegen/noticegen.go -source ${BUILD_DIR}/licenses -template ${SOURCE_DIR}/_support/noticegen/notice.template > ${BUILD_DIR}/NOTICE
${BUILD_DIR}: