Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting -march to native = slow merge times.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Jojobinha_2009
Tux's lil' helper
Tux's lil' helper


Joined: 27 Mar 2021
Posts: 77
Location: Brazil

PostPosted: Mon Apr 12, 2021 12:47 am    Post subject: Setting -march to native = slow merge times. Reply with quote

This is kind of related to my previous LibreOffice post.

I have noticed that if I use
Code:
-march=native
in my make.conf, I get overall longer merge times, in fact much longer for certain packages.

My machine stuck compiling PyQt5 for almost 5 hours using that parameter.

However, once I do what the wiki says and put
Code:
 -march=skylake
I get much faster merge times, In fact I think this was one of the factors that made my system able to build LibreOffice in a whopping 48 minutes and Firefox in 33 minutes.


What does the "Native" mean here and why does it seem to influence compile times so much?
_________________
Intel Core i5-9400F / 24GB DDR4 2666MHz / GeForce GTX 1060 3GB

Powered by Gentoo for x86_64

======================================================

Seize the day, and remember to have fun!
Back to top
View user's profile Send private message
mustafasalih1993
n00b
n00b


Joined: 09 Feb 2021
Posts: 38

PostPosted: Mon Apr 12, 2021 1:52 am    Post subject: Reply with quote

Hello Jojobinha_2009

the gcc man page tells the following about -march=native:

"-march=native causes the compiler to auto-detect the architecture of the build computer. At present, this feature is only supported on GNU/Linux, and not all architectures are recognized. If the auto-detect is unsuccessful the option has no effect."

it's basically tells the compiler to auto-detect your hardware this is useful if you don't know your hardware
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3267
Location: Canada

PostPosted: Mon Apr 12, 2021 2:51 am    Post subject: Reply with quote

mustafasalih1993 wrote:
Hello Jojobinha_2009

the gcc man page tells the following about -march=native:

"-march=native causes the compiler to auto-detect the architecture of the build computer. At present, this feature is only supported on GNU/Linux, and not all architectures are recognized. If the auto-detect is unsuccessful the option has no effect."

it's basically tells the compiler to auto-detect your hardware this is useful if you don't know your hardware



I wonder how I can check the result of autodetection ?
Back to top
View user's profile Send private message
mustafasalih1993
n00b
n00b


Joined: 09 Feb 2021
Posts: 38

PostPosted: Mon Apr 12, 2021 3:05 am    Post subject: Reply with quote

dmpogo wrote:

I wonder how I can check the result of autodetection ?


Hello dmpogo
you can the see the result with:
Code:

gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 | grep march
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2719

PostPosted: Mon Apr 12, 2021 4:07 am    Post subject: Reply with quote

Reminder that setting =specific has a different meaning than =native

Like my cheap minipc haswell is missing some features, app-misc/resolve-march-native gives me:
Code:
-march=haswell -mabm -mno-avx -mno-avx2 -mno-bmi -mno-bmi2 -mno-f16c -mno-fma -mno-xsave -mno-xsaveopt --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=2048
So -march=haswell wouldn't be the same as -march=native, I don't even have avx.

On my skylake, =native additionally enables two flags:
Code:
-march=skylake -mabm -mrtm --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=12288

GCC might also change how this is handled in new versions, add support for more things, etc.. and =native stays up to date (not that it can be helped if cross-compiling / distcc).

Edit: For me native vs exact flags doesn't seem to make any (noticeable) differences in compile times, likely some isolated hardware-specific issue if it does.
Back to top
View user's profile Send private message
kukibl
Apprentice
Apprentice


Joined: 10 Jun 2008
Posts: 237

PostPosted: Mon Apr 12, 2021 6:07 am    Post subject: Reply with quote

@Jojobinha_2009

Is this subjective thing or you have some exact merge time differences (maybe to query it with genlop)?
Back to top
View user's profile Send private message
Jojobinha_2009
Tux's lil' helper
Tux's lil' helper


Joined: 27 Mar 2021
Posts: 77
Location: Brazil

PostPosted: Mon Apr 12, 2021 10:33 pm    Post subject: Reply with quote

kukibl wrote:
@Jojobinha_2009

Is this subjective thing or you have some exact merge time differences (maybe to query it with genlop)?



Its subjective, however I can feel a noticeable slow down in large merges if I use native.

As I said, last time I used this, my machine got stuck merging PyQt5 for over 4 hours. I could hear the CPU cooler chugging along at high speed... And no end on sight.

Whereas once I used march=skylake, I didn't even notice that PyQt5 was compiled... It just flashed through.
_________________
Intel Core i5-9400F / 24GB DDR4 2666MHz / GeForce GTX 1060 3GB

Powered by Gentoo for x86_64

======================================================

Seize the day, and remember to have fun!
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


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

PostPosted: Tue Apr 13, 2021 12:40 am    Post subject: Reply with quote

@Jojobinha_2009: please measure and post emerge compile times for different '-march' variants on your machine.

Below are the results on my Ivybridge machine for 'time emerge --oneshot --nodeps PyQt5':
Code:
CFLAGS="-O2 -pipe"                  : 612 secs
CFLAGS="-O2 -pipe -march=native"    : 609 secs
CFLAGS="-O2 -pipe -march=skylake"   : 605 secs
CFLAGS="-O2 -pipe -march=ivybridge" : 613 secs
CFLAGS="-O2 -pipe -march=znver2"    : 608 secs

I don't see any difference.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54236
Location: 56N 3W

PostPosted: Tue Apr 13, 2021 8:38 am    Post subject: Reply with quote

Jojobinha_2009,

Are you sure its the -march setting?

Show us
Code:
emerge --info
before and after the changes you make.
I would expect some CFLAGS to change the build time but -march is not one of them.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Jojobinha_2009
Tux's lil' helper
Tux's lil' helper


Joined: 27 Mar 2021
Posts: 77
Location: Brazil

PostPosted: Tue Apr 13, 2021 11:26 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Jojobinha_2009,

Are you sure its the -march setting?

Show us
Code:
emerge --info
before and after the changes you make.
I would expect some CFLAGS to change the build time but -march is not one of them.


Sorry I can't show the output of the command before I make the change (because I've already rebuilt my entire install using -march=skylake).
But here's the result after:

Code:
emerge --info
Portage 3.0.18 (python 3.8.9-final-0, default/linux/amd64/17.1/desktop/plasma/systemd, gcc-10.3.0, glibc-2.33, 5.11.13-gentoo-x86_64 x86_64)
=================================================================
System uname: Linux-5.11.13-gentoo-x86_64-x86_64-Intel-R-_Core-TM-_i5-9400F_CPU_@_2.90GHz-with-glibc2.2.5
KiB Mem:    24443880 total,  20767204 free
KiB Swap:   25165820 total,  25165820 free
Timestamp of repository gentoo: Tue, 13 Apr 2021 21:30:01 +0000
Head commit of repository gentoo: 30dc5d18c70ec8859ea68dff03c14e3324c4800e
sh bash 5.1_p4
ld GNU ld (Gentoo 2.35.2 p1) 2.35.2
app-shells/bash:          5.1_p4::gentoo
dev-lang/perl:            5.32.1::gentoo
dev-lang/python:          2.7.18_p8::gentoo, 3.8.9::gentoo, 3.9.4::gentoo
dev-lang/rust:            1.51.0::gentoo
dev-util/cmake:           3.20.1::gentoo
sys-apps/baselayout:      2.7-r1::gentoo
sys-apps/sandbox:         2.23::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.3-r1::gentoo
sys-devel/binutils:       2.35.2::gentoo
sys-devel/gcc:            10.3.0::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.11::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33::gentoo
Repositories:

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

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=skylake -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=skylake -O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=6 --load-average=6"
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=skylake -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified 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=skylake -O2 -pipe"
GENTOO_MIRRORS="http://gentoo.gossamerhost.com rsync://gentoo.gossamerhost.com/gentoo-distfiles/ ftp://mirrors.tera-byte.com/pub/gentoo http://gentoo.mirrors.tera-byte.com/ rsync://mirrors.tera-byte.com/gentoo"
LANG="pt_BR.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j7"
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"
USE="L10N=pt_BR X a52 aac acl acpi activities alsa amd64 berkdb branding bzip2 cairo cdda cdr cli crypt cups dbus declarative dri dts dvd dvdr emboss encode exif flac fortran gdbm gif gpm gui iconv icu imlib ipv6 jpeg jumbo-build kde kipi kwallet lcms libglvnd libnotify libtirpc lto mad mng mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf phonon plasma png policykit ppds pulseaudio qml qt5 readline sdl seccomp semantic-desktop spell split-usr ssl startup-notification svg systemd tcpd tiff truetype udev udisks unicode upower usb vorbis widgets wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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="mmx mmxext sse sse2" 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" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python3_8" RUBY_TARGETS="ruby26" 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:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS

_________________
Intel Core i5-9400F / 24GB DDR4 2666MHz / GeForce GTX 1060 3GB

Powered by Gentoo for x86_64

======================================================

Seize the day, and remember to have fun!
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Wed Apr 14, 2021 12:22 pm    Post subject: Reply with quote

Phebom II X6
Code:
Casti ~ # gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 | grep march
 /usr/libexec/gcc/x86_64-pc-linux-gnu/9.3.0/cc1 -E -quiet -v - -march=amdfam10 -mmmx -m3dnow -msse -msse2 -msse3 -mno-ssse3 -msse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-sgx -mno-bmi2 -mno-pconfig -mno-wbnoinvd -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mlzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mprfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-shstk -mno-avx512vbmi2 -mno-avx512vnni -mno-vaes -mno-vpclmulqdq -mno-avx512bitalg -mno-movdiri -mno-movdir64b -mno-waitpkg -mno-cldemote -mno-ptwrite --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=amdfam10
Casti ~ # gcc -march=amdfam10 -E -v - </dev/null 2>&1 | grep cc1 | grep march
 /usr/libexec/gcc/x86_64-pc-linux-gnu/9.3.0/cc1 -E -quiet -v - -march=amdfam10
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Wed Apr 14, 2021 12:23 pm    Post subject: Reply with quote

Phenom II X6
Code:
Casti ~ # gcc -march=native -E -v - </dev/null 2>&1 | grep cc1 | grep march
 /usr/libexec/gcc/x86_64-pc-linux-gnu/9.3.0/cc1 -E -quiet -v - -march=amdfam10 -mmmx -m3dnow -msse -msse2 -msse3 -mno-ssse3 -msse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-sgx -mno-bmi2 -mno-pconfig -mno-wbnoinvd -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mlzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mprfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid -mno-gfni -mno-shstk -mno-avx512vbmi2 -mno-avx512vnni -mno-vaes -mno-vpclmulqdq -mno-avx512bitalg -mno-movdiri -mno-movdir64b -mno-waitpkg -mno-cldemote -mno-ptwrite --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=amdfam10
Casti ~ # gcc -march=amdfam10 -E -v - </dev/null 2>&1 | grep cc1 | grep march
 /usr/libexec/gcc/x86_64-pc-linux-gnu/9.3.0/cc1 -E -quiet -v - -march=amdfam10

Same with gcc 10.2.0
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
Page 1 of 1

 
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