Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build/ops: rpm: set build parallelism based on available memory #19122

Merged
merged 7 commits into from Jan 25, 2018

Conversation

smithfarm
Copy link
Contributor

@smithfarm smithfarm commented Nov 23, 2017

Set build parallelism based on available memory (avoids OOM on machines that have lots of cores, but little memory) and other changes needed to build master in the openSUSE Build Service (OBS).

@smithfarm smithfarm requested a review from dmick November 24, 2017 13:01
@smithfarm smithfarm changed the title build/ops: rpm: make lowmem_builder code much smarter build/ops: rpm: smarter lowmem_builder and other changes necessary to build master in OBS Nov 24, 2017
@smithfarm
Copy link
Contributor Author

Sorry for the initial instability - this PR is now ready for review.

@smithfarm
Copy link
Contributor Author

@sysrich I pulled your recent contribution into this upstream PR (JFYI - thanks).

@smithfarm smithfarm force-pushed the wip-lowmem-builder branch 2 times, most recently from b7af483 to d476ca7 Compare November 26, 2017 09:57
@smithfarm
Copy link
Contributor Author

ceph.spec.in Outdated
@@ -979,7 +978,6 @@ rm -rf %{buildroot}
%{_sbindir}/ceph-disk
%{_sbindir}/ceph-volume
%{_sbindir}/ceph-volume-systemd
%{_sbindir}/rcceph
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you put more context of this change in the commit messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

ceph.spec.in Outdated
@@ -33,6 +33,10 @@
%bcond_with ceph_test_package
%bcond_with cephfs_java
%bcond_without lowmem_builder
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we keep using ${_localstatedir} here? or we cannot define macro using another macro?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smithfarm ping?

ceph.spec.in Outdated
@@ -35,7 +36,7 @@
%bcond_without lowmem_builder
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%global _fillupdir /var/adm/fillup-templates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, this change belongs to another commit.

%if 0%{?suse_version}
# _insert_obs_source_lines_here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smithfarm so, instead of hardwiring to a certain path, OBS will inject another _remote_tarball_prefix when building rpm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tchaikov No, in the OBS builds the tarball is not downloaded at all, _remote_tarball_prefix expands to the empty string. In OBS builds, the tarball is generated from the git repo by running make-dist, before running rpmbuild.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I should have linked to the checkin script: https://build.opensuse.org/package/view_file/filesystems:ceph:mimic/ceph/checkin.sh?expand=1

The # _insert_obs_source_lines_here is used by pre_checkin.sh to add some OBS-specific "Source:" lines to the spec file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! thanks for the explanation. for those who are curious enough, see also https://build.opensuse.org/package/view_file/filesystems:ceph:mimic/ceph/pre_checkin.sh?expand=1, _insert_obs_source_lines_here is used as a mark there, and will be replaced by "Source99: ceph-rpmlintrc" by that script.

@@ -29,6 +30,7 @@ install(TARGETS ceph-osdomap-tool DESTINATION bin)
add_executable(ceph-monstore-tool ceph_monstore_tool.cc)
target_link_libraries(ceph-monstore-tool os global Boost::program_options)
install(TARGETS ceph-monstore-tool DESTINATION bin)
if(WITH_TESTS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

ceph.spec.in Outdated
# 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//')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to export these two variables. we pass them to cmake and make explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm exporting them so they appear in env so the user can see their values in the build log.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the export is dangerous in this case? If not, I would argue that it's beneficial to see the values in the build log...

ceph.spec.in Outdated
# Parallel build settings ...
# unlimit _smp_mflags in system macro
%global _smp_ncpus_max 0
CEPH_PARALLEL_BUILD="%{?_smp_mflags}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just set _smp_mflags? we are practically overriding it here. also the CEPH_PARALLEL_BUILD is confusing, might want to use something like CEPH_MFLAGS_JOBS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tchaikov Good question. I tried, but failed, to create the equivalent of CEPH_MFLAGS_JOBS="-j$lo_jobs" as an RPM macro definition. That doesn't mean there is no way to get an expanded shell variable into a macro definition - just that I don't know how.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed CEPH_PARALLEL_BUILD to CEPH_MFLAGS_JOBS.

@dmick dmick removed their request for review December 12, 2017 00:02
@smithfarm smithfarm force-pushed the wip-lowmem-builder branch 3 times, most recently from dca0dcb to ef1cf1e Compare January 10, 2018 11:06
@tchaikov tchaikov self-requested a review January 10, 2018 11:22
@smithfarm smithfarm changed the title build/ops: rpm: smarter lowmem_builder and other changes necessary to build master in OBS build/ops: rpm: changes necessary to build master in OBS Jan 10, 2018
@smithfarm smithfarm force-pushed the wip-lowmem-builder branch 2 times, most recently from 022e5a2 to 651877e Compare January 10, 2018 18:38
@smithfarm
Copy link
Contributor Author

@smithfarm
Copy link
Contributor Author

Here is what the parallelism-reduction codepath looks like - taken from OBS build log https://build.opensuse.org/public/build/home:smithfarm:branches:filesystems:ceph:mimic/openSUSE_Tumbleweed/x86_64/ceph/_log

[   78s] + CEPH_MFLAGS_JOBS=-j6
[   78s] ++ echo -j6
[   78s] ++ sed s/-j//
[   78s] + CEPH_SMP_NCPUS=6
[   78s] + echo 'Available memory:'
[   78s] Available memory:
[   78s] + free -h
[   78s]               total        used        free      shared  buff/cache   available
[   78s] Mem:           7.8G         90M        5.8G          0B        1.9G        7.4G
[   78s] Swap:          2.0G          0B        2.0G
[   78s] + echo 'System limits:'
[   78s] System limits:
[   78s] + ulimit -a
[   78s] core file size          (blocks, -c) unlimited
[   78s] data seg size           (kbytes, -d) unlimited
[   78s] scheduling priority             (-e) 0
[   78s] file size               (blocks, -f) unlimited
[   78s] pending signals                 (-i) 31869
[   78s] max locked memory       (kbytes, -l) 64
[   78s] max memory size         (kbytes, -m) unlimited
[   78s] open files                      (-n) 1024
[   78s] pipe size            (512 bytes, -p) 8
[   78s] POSIX message queues     (bytes, -q) 819200
[   78s] real-time priority              (-r) 0
[   78s] stack size              (kbytes, -s) 8192
[   78s] cpu time               (seconds, -t) unlimited
[   78s] max user processes              (-u) 4096
[   78s] virtual memory          (kbytes, -v) unlimited
[   78s] file locks                      (-x) unlimited
[   78s] + test -n 6 -a 6 -gt 1
[   78s] + mem_per_process=1800
[   78s] ++ LANG=C
[   78s] ++ free -m
[   78s] ++ sed -n 's|^Mem: *\([0-9]*\).*$|\1|p'
[   78s] + max_mem=7977
[   78s] + max_jobs=4
[   78s] + test 6 -gt 4
[   78s] + CEPH_SMP_NCPUS=4
[   78s] + echo 'Warning: Reducing build parallelism to -j4 because of memory limits'
[   78s] Warning: Reducing build parallelism to -j4 because of memory limits
[   78s] + test 4 -le 0
[   78s] + export CEPH_SMP_NCPUS
[   78s] + export CEPH_MFLAGS_JOBS=-j4
[   78s] + CEPH_MFLAGS_JOBS=-j4
[   78s] + sort
[   78s] + env
[   78s] CEPH_MFLAGS_JOBS=-j4
[   78s] CEPH_SMP_NCPUS=4

@smithfarm
Copy link
Contributor Author

@b-ranto Re-worked and re-tested.

@b-ranto
Copy link
Contributor

b-ranto commented Jan 19, 2018

@smithfarm looks great to me, thanks a lot! I did suspect this might even help us speed up the builds on machines with enough cores/memory like the 16-core centos builder you mentioned.

@smithfarm
Copy link
Contributor Author

@b-ranto Not sure about the speed-up. %_smp_mflags is set to 12, so I'm guessing the Shaman builder has 12 cores. But it has enough memory to sustain 16 parallel builds. But in this case we don't exceed %_smp_mflags - i.e. we set -j12 (no speed-up).

@smithfarm
Copy link
Contributor Author

The purpose of the patch is to avoid OOM condition on machines with high numbers of cores, but low memory.

If you like, I can have it set -j{MAX} regardless of whether that might exceed %_smp_mflags (but that seems like it might confuse people who are setting %_smp_mflags explicitly - if there are any such people)?

@smithfarm
Copy link
Contributor Author

Reinstating "needs-qa" because the PR has been completely re-worked.

@b-ranto
Copy link
Contributor

b-ranto commented Jan 19, 2018

I am happy with the PR at its current state. We override the _smp_mflags option only when we need to which is imo the best approach. If there is no speed up then I suppose we are hitting I/O limits but that is no reason to limit this. The expected speed up with 12 compared to 8 cores would also be relatively small (~25% maybe?). Thanks again for doing this!

@smithfarm smithfarm changed the title build/ops: rpm: changes necessary to build master in OBS build/ops: rpm: set build parallelism based on available memory Jan 24, 2018
smithfarm and others added 3 commits January 24, 2018 17:16
Disable java build completely. Enable lttng build on SLES only, and only for
certain architectures.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
Replace references to /var/adm/fillup-templates with new %_fillupdir macro

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1069468
Signed-off-by: Richard Brown <rbrown@suse.com>
With this macro, we can use a single Source0 line for all supported distros.
RH/CentOS/Fedora needs the prefix, while SUSE builds in the OBS use a local
tarball.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
Fixes RPMLINT warning "non-standard-group Development/Libraries"

Also, the Group: line is only needed for SUSE so put it in an appropriate
distro conditional.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
Sometimes the build machine has lots of processor cores and not enough
memory to successfully build Ceph on all of them at once. Calculate
how many parallel build processes we can sustain with the memory we
have and set a lower build parallelism if necessary. Never exceed
the value set by %_smp_mflags even if memory is aplenty.

Credits to Tomáš Chvátal for the original idea and implementation.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
Signed-off-by: Nathan Cutler <ncutler@suse.com>
As a follow-up to d7b493a we need to stop guarding

    ceph-osdomap-tool
    ceph-monstore-tool

with WITH_TESTS because they have been moved out of the ceph-test package.

(N.B. ceph-kvstore-tool was also moved out of ceph-test, but apparently never
had the guard.)

Signed-off-by: Nathan Cutler <ncutler@suse.com>
@smithfarm
Copy link
Contributor Author

Rebased to fix wrong Group name in "build/ops: rpm: fix Group for rados-objclass-devel subpackage"

@smithfarm
Copy link
Contributor Author

This PR passed a rados run here: http://pulpito.ceph.com/smithfarm-2018-01-24_19:46:55-rados-wip-smithfarm-testing-distro-basic-smithi/

197 of 202 tests passed.

Failed tests:

  • "2018-01-25 02:00:26.400626 osd.5 osd.5 172.21.15.77:6810/36898 23 : cluster [ERR] 3.0 scrub stat mismatch, got 48/48 objects, 5/5 clones, 23/23 dirty, 0/0 omap, 0/0 pinned, 1/1 hit_set_archive, 7/7 whiteouts, 112856156/114189825 bytes, 249/249 hit_set_archive bytes." in cluster log
  • "2018-01-25 01:54:14.602444 mgr.z client.4375 172.21.15.193:0/3577525578 1 : cluster [ERR] Unhandled exception from module 'prometheus' while running on mgr.z: error(98, 'Address already in use')" in cluster log
  • "2018-01-25 01:40:33.702645 mon.f mon.0 172.21.15.94:6789/0 118 : cluster [WRN] Health check failed: 1 slow ops, oldest one blocked for 33 sec (SLOW_OPS)" in cluster log

Two tests are still running.

@smithfarm smithfarm merged commit 34cc708 into ceph:master Jan 25, 2018
@smithfarm smithfarm deleted the wip-lowmem-builder branch January 25, 2018 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants