From daac8f3d73722b2547d4e6b702c2cb221a6f7912 Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Wed, 18 Oct 2023 15:13:57 +0200 Subject: [PATCH] [ Matthias Klose ] * Limit the number of parallel processes based on the available memory and the packages to be built (flang has some memory hogs). --- debian/changelog | 8 ++++++++ debian/rules | 30 +++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index d2b69887..84c821ea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +llvm-toolchain-17 (1:17.0.3-1~exp2) UNRELEASED; urgency=medium + + [ Matthias Klose ] + * Limit the number of parallel processes based on the available memory + and the packages to be built (flang has some memory hogs). + + -- Matthias Klose Wed, 18 Oct 2023 15:00:25 +0200 + llvm-toolchain-17 (1:17.0.3-1~exp1) experimental; urgency=medium [ Matthias Klose ] diff --git a/debian/rules b/debian/rules index 43883ba2..cb65d3f9 100755 --- a/debian/rules +++ b/debian/rules @@ -27,27 +27,38 @@ else BRANCH_NAME=$(LLVM_VERSION) endif +VENDOR=$(shell lsb_release -is) +DISTRO=$(shell lsb_release -sc) + SONAME_EXT := 1 SONAME_OPENMP := 5 # Manage the case when the version is 3.5~svn213052-1~exp1 or 3.4.2-1 DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9.]+)(~|-)(.*),\3,p") ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) - NJOBS := $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) + NCPUS := $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) else - NJOBS := $(shell nproc) + NCPUS := $(shell nproc) endif -VENDOR=$(shell lsb_release -is) -DISTRO=$(shell lsb_release -sc) - -DH_VERSION := $(shell dpkg -s debhelper | grep '^Version' | awk '{print $$2}') - -include /usr/share/dpkg/architecture.mk - # this contains all packages to be built. Note that for at least the clean target, # this always includes the binary-indep packages. packages := $(shell dh_listpackages) +# flang has some memory hogs, of up to 6.2gb per process. Limit the parallel jobs +# based on the available memory +ifneq (,$(filter flang-$(LLVM_VERSION), $(packages))) + MEM_PER_CPU=3900 +else + MEM_PER_CPU=2100 +endif +NJOBS := $(shell mt=`awk '/^MemTotal/ { print $$2 }' /proc/meminfo`; \ + awk -vn=$(NCPUS) -vmt=$$mt -vm=$(MEM_PER_CPU) \ + 'END { mt/=1024; n2 = int(mt/m); print n==1 ? 1 : n2