Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
emerge -1 clang takes 14 hours? [SOLVED!!]
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Sun Jan 09, 2022 10:18 pm    Post subject: emerge -1 clang takes 14 hours? [SOLVED!!] Reply with quote

So I don't think 14 hours is normal to emerge clang. What happens is it emerges fine for, it distributes its jobs all just fine, then about 20 minutes in it settles down to a single thread on localhost that takes way longer than normal to compile the rest. I tried a bunch of combinations of ccache, distcc, MAKEOPTS and EMERGE_DEFAULT_OPTS, and those had an effect, but it always settled down to hammering a single processor.

emerge --info says:

Code:

sys-devel/clang-13.0.0::gentoo was built with the following:
USE="static-analyzer xml -debug -default-compiler-rt -default-libcxx -default-lld -doc -llvm-libunwind -test" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="NVPTX (X86) -AArch64 -AMDGPU (-ARC) -ARM -AVR -BPF (-CSKY) -Hexagon -Lanai (-M68k) -MSP430 -Mips -PowerPC -RISCV -Sparc -SystemZ (-VE) -WebAssembly -XCore" PYTHON_SINGLE_TARGET="python3_9 -python3_10 -python3_8"
CFLAGS="-Ofast -march=x86-64 -mtune=generic -mfpmath=both -pipe -fgraphite-identity -floop-nest-optimize -funroll-loops -fipa-pta -ftracer -fno-plt -fno-semantic-interposition -malign-data=cacheline -mtls-dialect=gnu2 -Wl,--hash-style=gnu"
CXXFLAGS="-Ofast -march=x86-64 -mtune=generic -mfpmath=both -pipe -fgraphite-identity -floop-nest-optimize -funroll-loops -fipa-pta -ftracer -fno-plt -fno-semantic-interposition -malign-data=cacheline -mtls-dialect=gnu2 -Wl,--hash-style=gnu"
FEATURES="network-sandbox binpkg-logs protect-owned qa-unresolved-soname-deps sandbox news fixlafiles userfetch config-protect-if-modified merge-sync distcc userpriv assume-digests pid-sandbox sfperms unmerge-orphans usersandbox unknown-features-warn distlocks unmerge-logs xattr ipc-sandbox parallel-fetch binpkg-docompress strict usersync multilib-strict ebuild-locks binpkg-dostrip preserve-libs"


[edited:] Not using distcc it eventually settles down to this same behavior, it just takes a little longer to get there.

I noticed that clang itself doesn't have the clang useflag, is that maybe it? what's odd to me is that it compiles at all!

Any help greatly appreciated.

Cheers,
Jon.


Last edited by jesnow on Sat Mar 12, 2022 6:17 pm; edited 3 times in total
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3928

PostPosted: Sun Jan 09, 2022 10:39 pm    Post subject: Reply with quote

Plz see
https://wiki.gentoo.org/wiki/Clang#Bootstrapping_the_Clang_toolchain
Initially you build them with gcc then with clang via /etc/portage/env/ and /etc/portage/package.env
In my case
Code:

     Fri Jan  7 18:51:46 2022 >>> sys-devel/clang-12.0.1
       merge time: 54 minutes and 21 seconds.


with just 4 jobs.
If using distcc takes too long then plz dont.
_________________
:)
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22867

PostPosted: Sun Jan 09, 2022 11:23 pm    Post subject: Reply with quote

I don't think OP is trying to bootstrap clang with itself. In practice, if you only have clang installed to deal with those packages that are not properly tested with gcc, then the steps in that Wiki are unnecessary. Let Portage install clang when it requests to, and trust Portage to use clang when, and only when, necessary.

I routinely see times of less than 1 hour for clang. As best I recall, it does not have an extended period of single threaded operation.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2038

PostPosted: Mon Jan 10, 2022 12:00 am    Post subject: Reply with quote

I'd suggest trying to reproduce this with vanilla CFLAGS for a start, as notably something like -Ofast may substantially increase compile times.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Mon Jan 10, 2022 8:41 am    Post subject: Reply with quote

Please post the full output of
Code:
emerge --info
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Mon Jan 10, 2022 7:13 pm    Post subject: Reply with quote

Yay! -funroll-loops is back!

I haven't seen 14 hour clang build times and a lot of my machines clang is a non-issue after distcc is greased. Rust is still #1 on my slowest machine and it's just about one day to complete.

Not sure about clang, but most of these language compilers have two or more stages where the first part builds with the existing tools on the machine (or in the case of rust, a downloaded copy). Then the second stage it builds itself with what it built in the first stage. This second stage cannot be distcc'ed. Getting ninja/make to work optimally is the key here, as long as you're not using high cost compile options.

Indeed full emerge --info data would be interesting to see what we're dealing with.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Sat Jan 15, 2022 3:20 pm    Post subject: Reply with quote

Thanks everyone for your thoughtful input! Especially Hu, you have hit the nail on the head. Yes clang is probably compiling itself, that's normal, but it should be using more than one processor and ideally it should be distcc'ing. It does very nicely when it compiles other things. I think I do have some jacked up package settings (thanks to this install being originally cloveros, a whole nother story) If I can find out why these ones are messed up and *where* in the package configuration scheme they got messed up, that would help me understand both the package and how to control portage better.

And save me from waiting while clang compiles on a single thread.

Ok Here we go:

Code:

jesnow@bartali ~ $ emerge --info clang
Portage 3.0.28 (python 3.9.9-final-0, default/linux/amd64/17.1/hardened, gcc-11.2.0, glibc-2.33-r7, 5.10.27-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.10.27-gentoo-x86_64-AMD_Ryzen_5_3600_6-Core_Processor-with-glibc2.33
KiB Mem:    16317448 total,   7171824 free
KiB Swap:   22330364 total,  14467324 free
Timestamp of repository gentoo: Sat, 15 Jan 2022 14:30:01 +0000
Head commit of repository gentoo: 087a79f51d9ff452de9f3ac6d7d98bdc4e18c1aa
Head commit of repository TDE: db08e4b9f6377a40517500c1de9d6f7f9bfc5ae4

Head commit of repository abendbrot: 53ff6d3fcfa02f227ed3568850bea41df28b65db

Timestamp of repository audio-overlay: Thu, 13 Jan 2022 12:23:57 +0000
Head commit of repository audio-overlay: a3294a2d0234672a7c8030544ceb36d92b36be82

Head commit of repository cloveros: 982bdf5176064281d6e4afe59e62084db13d7657

Head commit of repository compiz-reloaded: 87fc8829f529505467b38dccb90bb69f290561f8

Head commit of repository tlp: 96db20c75e0f9a934013a77c573f16b8d598f193

sh bash 5.1_p8
ld GNU ld (Gentoo 2.37_p1 p0) 2.37
distcc 3.4 x86_64-pc-linux-gnu [enabled]
ccache version 4.5.1 [enabled]
app-misc/pax-utils:        1.3.3::gentoo
app-shells/bash:           5.1_p8::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.34.0-r6::gentoo
dev-lang/python:           3.9.9-r1::gentoo, 3.10.0_p1-r1::gentoo
dev-lang/rust:             1.56.1::gentoo
dev-util/ccache:           4.5.1::gentoo
dev-util/cmake:            3.21.4::gentoo
dev-util/meson:            0.59.4::gentoo
sys-apps/baselayout:       2.7-r3::gentoo
sys-apps/openrc:           0.44.10::gentoo
sys-apps/sandbox:          2.25::gentoo
sys-devel/autoconf:        2.13-r1::gentoo, 2.71-r1::gentoo
sys-devel/automake:        1.16.4::gentoo
sys-devel/binutils:        2.37_p1::gentoo
sys-devel/binutils-config: 5.4::gentoo
sys-devel/clang:           13.0.0::gentoo
sys-devel/gcc:             11.2.0::gentoo
sys-devel/gcc-config:      2.5-r1::gentoo
sys-devel/libtool:         2.4.6-r6::gentoo
sys-devel/lld:             13.0.0::gentoo
sys-devel/llvm:            13.0.0::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.15-r3::gentoo (virtual/os-headers)
sys-libs/glibc:            2.33-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://merckx/gentoo-portage/
    priority: -1000
    sync-rsync-extra-opts:
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes

TDE
    location: /var/db/repos/TDE
    sync-type: git
    sync-uri: https://github.com/ormorph/TDE
    masters: gentoo

abendbrot
    location: /var/db/repos/abendbrot
    sync-type: git
    sync-uri: https://github.com/barbudreadmon/abendbrot.git
    masters: gentoo

audio-overlay
    location: /var/db/repos/audio-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/audio-overlay.git
    masters: gentoo

cloveros
    location: /var/db/repos/cloveros
    sync-type: git
    sync-uri: https://gitgud.io/cloveros/cloveros-overlay.git
    masters: gentoo

compiz-reloaded
    location: /var/db/repos/compiz-reloaded
    sync-type: git
    sync-uri: https://github.com/ethus3h/compiz-reloaded-overlay.git
    masters: gentoo

tlp
    location: /var/db/repos/tlp
    sync-type: git
    sync-uri: https://github.com/dywisor/tlp-portage.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
AR="gcc-ar"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=" --jobs 10 --load-average 20"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs ccache config-protect-if-modified distcc distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j30 -l12"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X \ acl aio alsa amd64 bindist bzip2 cli crypt cups dga dri dri3 egl elogind exif fftw gif graphite hardened iconv ipv6 jack jit joystick jpeg lcms libglvnd libtirpc minimal multilib ncurses nptl numa offensive opencl openexr opengl openmp openssl otr pam pcre pie png policykit pulseaudio qt5 raw readline samba seccomp split-usr ssl ssp system-av1 system-binutils system-cairo system-clang system-cmark system-compress system-digest system-ffmpeg system-harfbuzz system-heimdal system-icu system-images system-jpeg system-lcms system-leveldb system-libevent system-libmspack system-libs system-libvpx system-libyaml system-llvm system-lua system-lz4 system-nss system-openjpeg system-pixman system-renpy system-snappy system-sqlite system-tbb system-uulib system-vpx system-zlib threads unicode v4l2 vaapi vdpau vulkan win32codecs xattr xinerama xorg xtpax zlib zsh-completion" ABI_X86="64" ADA_TARGET="gnat_2020" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="NVPTX X86" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26 ruby27" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS

=================================================================
                        Package Settings
=================================================================

sys-devel/clang-13.0.0::gentoo was built with the following:
USE="static-analyzer xml -debug -default-compiler-rt -default-libcxx -default-lld -doc -llvm-libunwind -test" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="NVPTX (X86) -AArch64 -AMDGPU (-ARC) -ARM -AVR -BPF (-CSKY) -Hexagon -Lanai (-M68k) -MSP430 -Mips -PowerPC -RISCV -Sparc -SystemZ (-VE) -WebAssembly -XCore" PYTHON_SINGLE_TARGET="python3_9 -python3_10 -python3_8"
CFLAGS="-Ofast -march=x86-64 -mtune=generic -mfpmath=both -pipe -fgraphite-identity -floop-nest-optimize -funroll-loops -fipa-pta -ftracer -fno-plt -fno-semantic-interposition -malign-data=cacheline -mtls-dialect=gnu2 -Wl,--hash-style=gnu"
CXXFLAGS="-Ofast -march=x86-64 -mtune=generic -mfpmath=both -pipe -fgraphite-identity -floop-nest-optimize -funroll-loops -fipa-pta -ftracer -fno-plt -fno-semantic-interposition -malign-data=cacheline -mtls-dialect=gnu2 -Wl,--hash-style=gnu"
FEATURES="network-sandbox binpkg-logs protect-owned qa-unresolved-soname-deps sandbox news fixlafiles userfetch config-protect-if-modified merge-sync distcc userpriv assume-digests pid-sandbox sfperms unmerge-orphans usersandbox unknown-features-warn distlocks unmerge-logs xattr ipc-sandbox parallel-fetch binpkg-docompress strict usersync multilib-strict ebuild-locks binpkg-dostrip preserve-libs"



Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1256

PostPosted: Sat Jan 15, 2022 3:35 pm    Post subject: Reply with quote

Code:
 ~ $ sudo qlop -tv clang
2021-12-01T23:14:41 >>> sys-devel/clang-13.0.1_rc1: 29′55″
2021-12-02T09:55:01 >>> sys-devel/clang-13.0.1_rc1: 30′19″
2021-12-09T23:22:31 >>> sys-devel/clang-13.0.1_rc1: 9′38″
2021-12-10T19:35:34 >>> sys-devel/clang-13.0.1_rc1: 9′01″
2022-01-07T14:09:17 >>> sys-devel/clang-13.0.1_rc1: 9′56″
2022-01-09T20:52:09 >>> sys-devel/clang-13.0.1_rc1: 9′33″
2022-01-13T23:07:28 >>> sys-devel/clang-13.0.1_rc2: 35′29″

On i7 Haswell. Clang is built with LLVM toolchain.
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Sat Jan 15, 2022 3:47 pm    Post subject: Reply with quote

Similar results -- the behavior seems to be newish with clang 13.

Code:

jesnow@bartali ~ $ sudo qlop -tv clang
2020-03-12T20:52:32 >>> sys-devel/clang-9.0.1: 21s
2020-06-01T01:30:34 >>> sys-devel/clang-9.0.1: 27′22″
2020-06-01T11:02:42 >>> sys-devel/clang-9.0.1: 15′48″
2020-06-10T22:30:16 >>> sys-devel/clang-9.0.1: 19′07″
2020-07-04T17:36:07 >>> sys-devel/clang-9.0.1: 22′00″
2020-07-04T23:01:17 >>> sys-devel/clang-9.0.1: 27′12″
2020-07-05T00:22:37 >>> sys-devel/clang-10.0.0: 1:18:23
2020-07-05T08:30:01 >>> sys-devel/clang-10.0.0: 48′20″
2020-07-05T11:48:55 <<< sys-devel/clang-9.0.1: 2s
2020-09-21T16:54:21 >>> sys-devel/clang-10.0.1: 30′39″
2020-11-26T10:41:57 >>> sys-devel/clang-11.0.0: 30′20″
2020-12-08T16:38:51 >>> sys-devel/clang-11.0.0: 6:55:42
2020-12-13T09:48:50 <<< sys-devel/clang-10.0.1: 2s
2021-01-15T12:56:02 >>> sys-devel/clang-11.0.0: 7:07:11
2021-02-24T11:49:29 >>> sys-devel/clang-11.0.1: 6:47:28
2021-04-02T16:42:39 >>> sys-devel/clang-11.1.0: 9:27:46
2021-06-21T21:58:54 >>> sys-devel/clang-11.1.0: 9:17:10
2021-06-22T10:22:53 >>> sys-devel/clang-12.0.0-r1: 8:48:28
2021-07-31T23:39:24 <<< sys-devel/clang-11.1.0: 2s
2021-08-06T21:42:52 >>> sys-devel/clang-12.0.1: 8:43:01
2021-11-06T09:41:54 >>> sys-devel/clang-13.0.0: 15:25:03
2021-11-20T12:09:40 <<< sys-devel/clang-12.0.1: 1s
2022-01-08T10:53:06 >>> sys-devel/clang-13.0.0: 15:05:54
jesnow@bartali ~ $


Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Jan 15, 2022 3:58 pm    Post subject: Reply with quote

Code:
-j30

Each job needs up to 2 GB RAM. For -j30, you should have 64GB of RAM. Add additional RAM if you use tmpfs on /var/tmp/portage.

But you have only 16 GB RAM.

Extensive swapping could be the result.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Sat Jan 15, 2022 9:59 pm    Post subject: Reply with quote

you did something different at clang-11.. once it took 30 minutes, next it took almost 7 hours.. what happened?
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Sat Jan 15, 2022 10:35 pm    Post subject: Reply with quote

mike155 wrote:
Code:
-j30

Each job needs up to 2 GB RAM. For -j30, you should have 64GB of RAM. Add additional RAM if you use tmpfs on /var/tmp/portage.
But you have only 16 GB RAM.
Extensive swapping could be the result.


I have >= 2gb/processor on this machine and each of the distcc volunteers. I'm pretty sure /var/tmp/portage is not on /tmp or using tmpfs. If I had more memory I definitely would do that.

Cheers,
Jon.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Sun Jan 16, 2022 12:13 am    Post subject: Reply with quote

Thermal throttling perhaps is another possibility?
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22867

PostPosted: Sun Jan 16, 2022 2:38 am    Post subject: Reply with quote

Thermal throttling could slow execution of running processes, but OP noted at the outset that the clang build drops into a strange single-threaded behavior. I wonder if that single threading alone is a major factor in the absurd compile times.

OP: when clang settles into this mode, what is the system load average, and what does the process tree look like? In particular, is make starting only one child at a time, or is make starting multiple jobs and yet the kernel schedules only one at a time? You have -l12 in your MAKEOPTS, likely to control run-away behavior in case of a distcc problem. Perhaps there is some path where the system load average goes so high that make is constrained by that -l12. Make will always keep at least one child running until it completes, regardless of how high the load average goes. However, if your load average exceeds 12, then Make will only run one child at a time.

Is there any indication in the distcc logs that distcc has locked out use of volunteers, and is trying to run only locally? How is DISTCC_HOSTS set? That is, assuming an unlimited number of jobs to run and system resources to run them, how many jobs would be processed on (1) the build machine and (2) all the other volunteers?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Sun Jan 16, 2022 3:10 am    Post subject: Reply with quote

Actually I sort of saw this behavior during some thermal throttling problems I had with one machine. I can't explain why this happened however, but for some reason my machine was throttled down to one job when it was overheating, for whatever reason. Must be some OS-HW interaction but it's not exactly clear to me how.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
HealerLFG
n00b
n00b


Joined: 08 Feb 2022
Posts: 15

PostPosted: Tue Feb 08, 2022 10:09 pm    Post subject: Reply with quote

Good evening. I'm a bit late to this party, but I was having this exact same problem and found this thread today, as well as the solution... an emerge of CLANG that began with make opts and jobs properly, but then settled down to a single thread maxing out 1 logical core on my cpu, with no other threads being made. I have a similar configuration: broadwell-e, liquid cooled, and 32GB of ram backed by 32GB more of a swap partition, with rather conservative jobs/opts, so it didn't seem like a thrashing or thermal issue. I also used a tad less aggressive optimizations and flags, including PGO + LTO. (no Ofast or anything known to cause UB or break strict-standards though...)

*my* issue, was an invalid /etc/portage/make.conf.lto file. I LTO'd my system with the LTO-Overlay here: https://github.com/InBetweenNames/gentooLTO . I had glossed over a step or two while configuring that /etc/portage/make.conf.lto symlink that the overlay script creates. If you used that overlay and instructions as well, I urge you to double check that .conf. After adjusting mine, it seems to properly utilize all my jobs/opts during the link phase.

cheers
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Sat Feb 12, 2022 4:38 pm    Post subject: Reply with quote

Should clang be built without LTO?


Hu: Many thanks for your input. Who knows what makeopts and JOBS= does under the hood. I mean, you do. Presumably something that low level would be consistent between big builds. But my machine right now is happiliy compiling chromium and libreoffice at the same time, and dutifully hammering the distcc volunteers. So that suggests the problem is something unique to clang that I can fix.


Cheers,
Jon.

HealerLFG wrote:
Good evening. I'm a bit late to this party, but I was having this exact same problem and found this thread today, as well as the solution... an emerge of CLANG that began with make opts and jobs properly, but then settled down to a single thread maxing out 1 logical core on my cpu, with no other threads being made. I have a similar configuration: broadwell-e, liquid cooled, and 32GB of ram backed by 32GB more of a swap partition, with rather conservative jobs/opts, so it didn't seem like a thrashing or thermal issue. I also used a tad less aggressive optimizations and flags, including PGO + LTO. (no Ofast or anything known to cause UB or break strict-standards though...)

*my* issue, was an invalid /etc/portage/make.conf.lto file. I LTO'd my system with the LTO-Overlay here: https://github.com/InBetweenNames/gentooLTO . I had glossed over a step or two while configuring that /etc/portage/make.conf.lto symlink that the overlay script creates. If you used that overlay and instructions as well, I urge you to double check that .conf. After adjusting mine, it seems to properly utilize all my jobs/opts during the link phase.

cheers


Last edited by jesnow on Sat Feb 12, 2022 5:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Sat Feb 12, 2022 4:54 pm    Post subject: Reply with quote

Pretty sure my machine was running one compile job at a time then when it was exhibiting weird behavior. I'll need to see if it happens again and investigate further, after fixing up my machine I haven't seen this behavior again.

But if you're focused on completion time versus optimized binaries, yes you should disable LTO/PGO/... - will get a bit of reprieve now but will add a few seconds to all the other programs you compile with it... Tradeoffs...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Thu Mar 10, 2022 1:48 pm    Post subject: Reply with quote

Still a problem. Clang compiles with one local thread, and takes nearly a day. It is a beast of a package to begin with, but compiling on a single core you're waiting a while. chromium by contrast on the same system compiles in 2 hours with 30 or so threads on five machines running distcc.

I've tried turning off distcc and ccache, no change in behavior. LTO, which does cause a lot of my compile-time issues, was off anyway.

Here it is doing its single thread thing and taking up 44% of memory (I have 16G), there are currently 4G occupied in the swapfile.

Code:

top - 08:19:34 up 3 days, 17:19,  9 users,  load average: 1.04, 1.09, 1.18
Tasks: 302 total,   2 running, 300 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.2 sy,  8.3 ni, 91.1 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  15935.0 total,   4022.5 free,  10511.3 used,   1401.2 buff/cache
MiB Swap:  21807.0 total,  17396.5 free,   4410.5 used.   5127.1 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                                         
 5951 portage   29   9 9304140   7.0g   7352 R  99.0  45.2 100:11.54 cc1plus                                                                                                                                         
 2291 root      20   0   24.3g  60912  30136 S   2.3   0.4  98:57.17 X                                                                                                                                               
 2697 jesnow    20   0    8272    236      0 S   0.7   0.0  25:18.66 xosview                                                                                                                                         
 2705 jesnow    20   0   11084   1540   1264 S   0.7   0.0  11:02.64 ssh                                                                                                                                             
29479 jesnow    20   0 3866900 660700 129260 S   0.7   4.0   6:42.55 thunderbird                                                                                                                                     



Code:

jesnow@bartali ~ $ ps ax | grep cc1
 5951 pts/5    RN   100:20 /usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/cc1plus -quiet -I /var/tmp/portage/sys-devel/clang-13.0.1/work/x/y/clang-abi_x86_64.amd64/lib/ASTMatchers/Dynamic -I /var/tmp/portage/sys-devel/clang-13.0.1/work/clang/lib/ASTMatchers/Dynamic -I /var/tmp/portage/sys-devel/clang-13.0.1/work/clang/include -I /var/tmp/portage/sys-devel/clang-13.0.1/work/x/y/clang-abi_x86_64.amd64/include -I /include -I /usr/lib/llvm/13/include -MD lib/ASTMatchers/Dynamic/CMakeFiles/obj.clangDynamicASTMatchers.dir/Registry.cpp.d -MF lib/ASTMatchers/Dynamic/CMakeFiles/obj.clangDynamicASTMatchers.dir/Registry.cpp.o.d -MT lib/ASTMatchers/Dynamic/CMakeFiles/obj.clangDynamicASTMatchers.dir/Registry.cpp.o -D_GNU_SOURCE -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D NDEBUG /var/tmp/portage/sys-devel/clang-13.0.1/work/clang/lib/ASTMatchers/Dynamic/Registry.cpp -quiet -dumpdir lib/ASTMatchers/Dynamic/CMakeFiles/obj.clangDynamicASTMatchers.dir/ -dumpbase Registry.cpp.cpp -dumpbase-ext .cpp -march=x86-64 -mtune=generic -mfpmath=both -malign-data=cacheline -mtls-dialect=gnu2 -Ofast -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough=3 -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -Woverloaded-virtual -Wpedantic -Wno-long-long -std=c++14 -fdiagnostics-color=always -fgraphite-identity -floop-nest-optimize -funroll-loops -fipa-pta -ftracer -fno-plt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -o -
18543 pts/8    S+     0:00 grep --colour=auto cc1


It must have hit memory constraints and started swapping but isn't paging now as I'm watching it. The process is cc1plus, the preprocessor, and the compile line has a *lot* of includes. That says to me the problem is indeed memory. 16G is plenty to compile most things but maybe clang is a different animal. There's no point in doing backflips when you can just buy more hardware. Probably the clang developers don't particularly care about us being able to compile it in only 16G, that's a very corner case for them.

So I'm going to buy 32G more memory *just* to compile clang. Since clang, llvm rust et al are incredibly popular this will only go one way. I'll have to disable distcc because none of my other machines has more than 16G either. If the new memory doesn't do the trick I will be pissed.

Cheers,
Jon.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Thu Mar 10, 2022 3:04 pm    Post subject: Reply with quote

Since you're using distcc, are you sure your other distcc boxes aren't being hammered? How long does it take without distcc?
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22867

PostPosted: Thu Mar 10, 2022 4:01 pm    Post subject: Reply with quote

If clang is compiling single-threaded, adding more memory might help that thread swap less, but will not make better use of your other CPU cores.

Your load average looks reasonable, and would not cause -l12 to matter. I also asked about the process tree during the time that this is unexpectedly single threaded. I would like to see all the Portage-related processes, tree-threaded, with arguments. ps -Hfwwww -u portage should suffice.

How exactly did you disable distcc?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Thu Mar 10, 2022 6:38 pm    Post subject: Reply with quote

Should not be a RAM issue, I've built clang-13 on a old 4 core, 8GB machine. This is also with it running at least 2GB worth of virtual machines at the same time. I use a much lower -l and -j option for MAKEOPTS as historically I don't have that many cores though now I may need to tweak things with more distcc cores available.

Somehow you have a setting to get it to take 7GB RAM for one *gcc* job that has taken 100 minutes to run... I haven't seen something more than 3GB yet, this takes the cake...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Fri Mar 11, 2022 4:22 am    Post subject: Reply with quote

Dear Hu:

Thanks, you are always on the case. This is kind of a murder mystery to me too. It just doesn't make sense that a single compile job can create such havoc. My new memory is arriving tomorrow, so maybe brute force will do the job. My current gentoo install started as a cloveros, and I still don't understand all the settings he tweaked. I noticed after my last post that -Ofast is set, so maybe that's doing extreme precompiling of things and loop-unrolling. But I tried to turn all the funky stuff off for clang.

Before I install the memory I will "emerge -1 clang" and get the more granular picture of whats running you ask for once it hits single core mode. Maybe as eccerr0r says there's just one weird setting that's blowing it all up.

I got home from work tonight and it did compile finally! Maybe single core mode is better than compiling away for 10 hours and then running out of memory and crashing.


Hu wrote:
If clang is compiling single-threaded, adding more memory might help that thread swap less, but will not make better use of your other CPU cores.

Your load average looks reasonable, and would not cause -l12 to matter. I also asked about the process tree during the time that this is unexpectedly single threaded. I would like to see all the Portage-related processes, tree-threaded, with arguments. ps -Hfwwww -u portage should suffice.

How exactly did you disable distcc?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9847
Location: almost Mile High in the USA

PostPosted: Sat Mar 12, 2022 4:09 pm    Post subject: Reply with quote

Ah... did not catch this was formerly a cloveros install, not installed from Gentoo, so technically this thread belongs in the Unsupported forum, no wonder why none of us can reproduce the issue. Also the fact it looks like cloveros went belly up 2 years ago or so, so you're stuck with the parent distribution.

It looks like cloveros has a bunch of optimizations that are not default which also includes LTO, but this would be a linker thing not compiler...

So is this the first time you tried updating with solely the Gentoo repositories? And was the plan to switch to a more base Gentoo-like install that doesn't take 14 hours to complete clang and only need < 8GB RAM? Problem is if the distribution of jobs is bad due to the package constraints, yes it's possible to end up running single threaded, which was the whole problem of going to multi core/thread software programming in the first place...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 888

PostPosted: Sat Mar 12, 2022 4:45 pm    Post subject: Reply with quote

eccerr0r wrote:
Ah... did not catch this was formerly a cloveros install, not installed from Gentoo, so technically this thread belongs in the Unsupported forum, no wonder why none of us can reproduce the issue. Also the fact it looks like cloveros went belly up 2 years ago or so, so you're stuck with the parent distribution.

It looks like cloveros has a bunch of optimizations that are not default which also includes LTO, but this would be a linker thing not compiler...

So is this the first time you tried updating with solely the Gentoo repositories?


Short answer, no it's gentoo. There is no non-gentoo code on here that I'm aware of

I've been compiling from gentoo repositories from day 1, almost 2 years ago, including clang. "Use a binhosted distro as an easy gentoo installer" they said. And it's true, it was easy at first. And it was even then fully gentoo, just a ton of cute optimizations. I was going back and forth between binhost and gentoo repositories for a while, but went full gentoo with emerge -e world long ago. That worked, this is gentoo installation. Cloveros binhost hasn't even been available for a while.

So I went out and bought 32G more memory, since every time I've complained about compilation times people say "you need more memory". Now I have 48G and I should be OK, with a Ryzen 5 3600, it should give reasonable performance. So there is no change in the behavior -- it starts out multithreaded (and using a lot but not all of memory) but settles down to hammering a single thread with about the same memory usage as before -- ie $140 bucks worth of memory had zero effect.

It wasn't because of memory limitation.

This is for sure a stupid compiler optimization that will go away when I fix the compile options, but I am out of guesses what the offending one is.

Cheers,
Jon.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum