Skip to content

Commit

Permalink
build/ops: rpm: make lowmem_builder code much smarter
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Cutler <ncutler@suse.com>
Signed-off-by: Tomas Chvatal <tchvatal@suse.com>
  • Loading branch information
smithfarm committed Nov 24, 2017
1 parent f613b71 commit 107616c
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions ceph.spec.in
Expand Up @@ -138,6 +138,9 @@ BuildRequires: make
BuildRequires: parted
BuildRequires: perl
BuildRequires: pkgconfig
%if %{with lowmem_builder}
BuildRequires: procps
%endif
BuildRequires: python
BuildRequires: python-devel
BuildRequires: python-nose
Expand Down Expand Up @@ -797,18 +800,42 @@ export CPPFLAGS="$java_inc"
export CFLAGS="$RPM_OPT_FLAGS"
export CXXFLAGS="$RPM_OPT_FLAGS"

env | sort

# Parallel build settings ...
# unlimit _smp_mflags in system macro
%global _smp_ncpus_max 0
CEPH_PARALLEL_BUILD="%{?_smp_mflags}"
%if %{with lowmem_builder}
%if 0%{?jobs} > 8
%define _smp_mflags -j8
%endif
lo_jobs="%{?jobs:%{jobs}}"
%if 0%{?suse_version}
%ifarch %arm
%if ! 0%{?qemu_user_space_build:1}
# native hardware is not that powerful
lo_jobs="1"
%endif
%endif
%endif
# do not eat all memory
echo "Available memory:"
free
echo "System limits:"
ulimit -a
lo_jobs_reduced=
if test -n "$lo_jobs" -a "$lo_jobs" -gt 1 ; then
mem_per_process=1600
max_mem=$(LANG=C free -t -m | sed -n "s|^Mem: *\([0-9]*\).*$|\1|p")
max_jobs="$(($max_mem / $mem_per_process))"
test "$lo_jobs" -gt "$max_jobs" && lo_jobs="$max_jobs" && lo_jobs_reduced="yes" && echo "Warning: Reducing build parallelism to -j$max_jobs because of memory limits"
test "$lo_jobs" -le 0 && lo_jobs=1 && echo "Warning: Not using parallel build at all because of memory limits"
fi
# run make
if test -n "$lo_jobs" ; then
CEPH_PARALLEL_BUILD="-j$lo_jobs"
fi
%endif

# unlimit _smp_mflags in system macro if not set above
%define _smp_ncpus_max 0
# extract the number of processors for use with cmake
%define _smp_ncpus %(echo %{_smp_mflags} | sed 's/-j//')
export CEPH_PARALLEL_BUILD
export CEPH_SMP_NCPUS=$(echo "$CEPH_PARALLEL_BUILD" | sed 's/-j//')

env | sort

mkdir build
cd build
Expand Down Expand Up @@ -853,9 +880,9 @@ cmake .. \
%else
-DWITH_RADOSGW_BEAST_FRONTEND=OFF \
%endif
-DBOOST_J=%{_smp_ncpus}
-DBOOST_J=$CEPH_SMP_NCPUS

make %{?_smp_mflags}
make "$CEPH_PARALLEL_BUILD"


%if 0%{with make_check}
Expand Down

0 comments on commit 107616c

Please sign in to comment.