mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-30 19:16:31 +00:00
acc333c40b
When GTS is running in a container runtime which has configured CPU or memory limits or under an init system that uses cgroups to impose CPU and memory limits the values the Go runtime sees for GOMAXPROCS and GOMEMLIMIT are still based on the host resources, not the cgroup. At least for the throttling middlewares which use GOMAXPROCS to configure their queue size, this can result in GTS running with values too big compared to the resources that will actuall be available to it. This introduces 2 dependencies which can pick up resource contraints from the current cgroup and tune the Go runtime accordingly. This should result in the different queues being appropriately sized and in general more predictable performance. These dependencies are a no-op on non-Linux systems or if running in a cgroup that doesn't set a limit on CPU or memory. The automatic tuning of GOMEMLIMIT can be disabled by either explicitly setting GOMEMLIMIT yourself or by setting AUTOMEMLIMIT=off. The automatic tuning of GOMAXPROCS can similarly be counteracted by setting GOMAXPROCS yourself.
68 lines
2 KiB
Makefile
68 lines
2 KiB
Makefile
# The development version of clang is distributed as the 'clang' binary,
|
|
# while stable/released versions have a version number attached.
|
|
# Pin the default clang to a stable version.
|
|
CLANG ?= clang-11
|
|
CFLAGS := -target bpf -O2 -g -Wall -Werror $(CFLAGS)
|
|
|
|
# Obtain an absolute path to the directory of the Makefile.
|
|
# Assume the Makefile is in the root of the repository.
|
|
REPODIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
UIDGID := $(shell stat -c '%u:%g' ${REPODIR})
|
|
|
|
IMAGE := $(shell cat ${REPODIR}/testdata/docker/IMAGE)
|
|
VERSION := $(shell cat ${REPODIR}/testdata/docker/VERSION)
|
|
|
|
# clang <8 doesn't tag relocs properly (STT_NOTYPE)
|
|
# clang 9 is the first version emitting BTF
|
|
TARGETS := \
|
|
testdata/loader-clang-7 \
|
|
testdata/loader-clang-9 \
|
|
testdata/loader-clang-11 \
|
|
testdata/invalid_map \
|
|
testdata/raw_tracepoint \
|
|
testdata/invalid_map_static \
|
|
testdata/initialized_btf_map \
|
|
testdata/strings \
|
|
internal/btf/testdata/relocs
|
|
|
|
.PHONY: all clean docker-all docker-shell
|
|
|
|
.DEFAULT_TARGET = docker-all
|
|
|
|
# Build all ELF binaries using a Dockerized LLVM toolchain.
|
|
docker-all:
|
|
docker run --rm --user "${UIDGID}" \
|
|
-v "${REPODIR}":/ebpf -w /ebpf --env MAKEFLAGS \
|
|
"${IMAGE}:${VERSION}" \
|
|
make all
|
|
|
|
# (debug) Drop the user into a shell inside the Docker container as root.
|
|
docker-shell:
|
|
docker run --rm -ti \
|
|
-v "${REPODIR}":/ebpf -w /ebpf \
|
|
"${IMAGE}:${VERSION}"
|
|
|
|
clean:
|
|
-$(RM) testdata/*.elf
|
|
-$(RM) internal/btf/testdata/*.elf
|
|
|
|
all: $(addsuffix -el.elf,$(TARGETS)) $(addsuffix -eb.elf,$(TARGETS))
|
|
|
|
testdata/loader-%-el.elf: testdata/loader.c
|
|
$* $(CFLAGS) -mlittle-endian -c $< -o $@
|
|
|
|
testdata/loader-%-eb.elf: testdata/loader.c
|
|
$* $(CFLAGS) -mbig-endian -c $< -o $@
|
|
|
|
%-el.elf: %.c
|
|
$(CLANG) $(CFLAGS) -mlittle-endian -c $< -o $@
|
|
|
|
%-eb.elf : %.c
|
|
$(CLANG) $(CFLAGS) -mbig-endian -c $< -o $@
|
|
|
|
# Usage: make VMLINUX=/path/to/vmlinux vmlinux-btf
|
|
.PHONY: vmlinux-btf
|
|
vmlinux-btf: internal/btf/testdata/vmlinux-btf.gz
|
|
internal/btf/testdata/vmlinux-btf.gz: $(VMLINUX)
|
|
objcopy --dump-section .BTF=/dev/stdout "$<" /dev/null | gzip > "$@"
|