Skip to content

Makefile: Fix performance issues caused by tracing in binaries

Patrick Steinhardt requested to merge pks-makefile-per-target-go-flags into master

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

Fixes #4020 (closed)

Edited by Patrick Steinhardt

Merge request reports