From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E17973858C52; Thu, 21 Sep 2023 16:40:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E17973858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695314424; bh=LCdbg2/aLk7/zBO3uK6UzYw0A2Us18/yd2xznU3VnLU=; h=From:To:Subject:Date:From; b=a8eSPHFUTS5y63aIWPtWCLLtWZ8vKl5i+7AxeeAPMRv/8iL30cdI+0pB45VIj96sm xZBzfWvPmYTttGG6AkQRBV2SvAZsBbstcTXV3bhJZ3RmAsYNYHmsm8vDlLDYlzgwkv e6gCdG7BWh/5VOMI/GtD8oLv3+5EXJX7c9T0EsiA= From: "hp at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/111523] New: Unexpected performance regression with -ftrivial-auto-var-init=zero for e.g. systemctl unmask Date: Thu, 21 Sep 2023 16:40:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hp at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcchost cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111523 Bug ID: 111523 Summary: Unexpected performance regression with -ftrivial-auto-var-init=3Dzero for e.g. systemctl unmask Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org Target Milestone: --- Host: x86_64-pc-linux-gnu Target: arm-linux-eabi This issue is opened on request from the author of -ftrivial-auto-var-init (https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630894.html) when= I mentioned an local observation, that systemd's use of -ftrivial-auto-var-init=3Dzero caused a slowdown of at least 35% observable= with a mostly harmless command such as "systemctl unmask x". The performance-regression was identified as corresponding to https://github.com/systemd/systemd.git commit 1a4e392760 (which adds -ftrivial-auto-var-init=3Dzero to build flags). My own belief is that this kind of slowdown is totally expected with -ftrivial-auto-var-init=3Dzero, but there was disagreement, and bugzilla mi= ght help with fixing any issues. Please note that I'm sorry but I'm not going = to analyze the problem myself to the level yielding a self-contained test-case. The build environment is Poky (OpenEmbedded) mickledore-4.2 or 4.2.1 (the e= xact version for the observation was probably mickledore-4.2.1, could have been = 4.2; there appears to be no related change in-between). From that version, all o= ther version numbers are deducible; specifically gcc-12.2.0. Regarding systemd, matters are somewhat complicated by Poky pulling https://github.com/systemd/systemd-stable.git (note the "-stable" differenc= e to the first quoted repo) with the version seemingly v253.1 (actually, git hash 6c327d74aa0). The commit-hash introducing=20 -ftrivial-auto-var-init=3Dzero is the same, 1a4e392760cb5, so it seems -sta= ble is just some kind of subset repo. According to the target gcc -v option, it was configured as follows. While= the quoted version below is 12.3 (per Poky 4.2.3), from the gcc "recipes", it appears the gcc configuration options were the same in mickledore-4.2: Configured with: ../../../../../../work-shared/gcc-12.3.0-r0/gcc-12.3.0/configure --build=3Dx86_64-linux --host=3Dx86_64-linux --target=3Darm-poky-linux-gnue= abi --prefix=3D/host-native/usr --exec_prefix=3D/host-native/usr --bindir=3D/host-native/usr/bin/arm-poky-linux-gnueabi --sbindir=3D/host-native/usr/bin/arm-poky-linux-gnueabi --libexecdir=3D/host-native/usr/libexec/arm-poky-linux-gnueabi --datadir=3D/host-native/usr/share --sysconfdir=3D/host-native/etc --sharedstatedir=3D/host-native/com --localstatedir=3D/host-native/var --libdir=3D/host-native/usr/lib/arm-poky-linux-gnueabi --includedir=3D/host-native/usr/include --oldincludedir=3D/host-native/usr/= include --infodir=3D/host-native/usr/share/info --mandir=3D/host-native/usr/share/m= an --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=3D/host-native --enable-clocale=3Dgeneric --with-gnu= -ld --enable-shared --enable-languages=3Dc,c++ --enable-threads=3Dposix --disable-multilib --enable-default-pie --enable-c99 --enable-long-long --enable-symvers=3Dgnu --enable-libstdcxx-pch --program-prefix=3Darm-poky-linux-gnueabi- --without-local-prefix --disable-install-libiberty --disable-libssp --enable-libitm --enable-lto --disable-bootstrap --with-system-zlib --with-linker-hash-style=3Dsysv --enable-linker-build-id --with-ppl=3Dno --with-cloog=3Dno --enable-checking=3Drelease --enable-cheaders=3Dc_global --without-isl --with-gxx-include-dir=3D/not/exist/usr/include/c++/12.3.0 --with-sysroot=3D/not/exist --with-build-sysroot=3D/host --enable-poison-system-directories=3Derror --with-system-zlib --disable-sta= tic --disable-nls --with-glibc-version=3D2.28 --enable-initfini-array I'm washing my hands; these configure options are a Poky invention. The build options besides -ftrivial-auto-var-init=3Dzero are (quoting from = the log for a random command-line building a file in systemd/systemctl): arm-poky-linux-gnueabi-gcc -mthumb -mfpu=3Dneon -mfloat-abi=3Dhard -mcpu=3D= cortex-a9 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=3D2 -Wformat -Wformat-securi= ty -Werror=3Dformat-security --sysroot=3D/home/hp/cfp/build/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/= systemd/1_253.4+git999-r0/recipe-sysroot -Isystemctl.p -I. -I../../../../../../workspace/sources/systemd -Isrc/basic -I../../../../../../workspace/sources/systemd/src/basic -Isrc/fundamental -I../../../../../../workspace/sources/systemd/src/fundamental -Isrc/systemd -I../../../../../../workspace/sources/systemd/src/systemd -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-bus -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-device -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-event -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-hwdb -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-id128 -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-journal -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-netlink -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-network -I../../../../../../workspace/sources/systemd/src/libsystemd/sd-resolve -Isrc/shared -I../../../../../../workspace/sources/systemd/src/shared -fdiagnostics-color=3Dalways -D_FILE_OFFSET_BITS=3D64 -Wall -Winvalid-pch -= Wextra -std=3Dgnu11 -Wno-missing-field-initializers -Wno-unused-parameter -Warray-= bounds -Warray-bounds=3D2 -Wdate-time -Wendif-labels -Werror=3Dformat=3D2 -Werror=3Dformat-signedness -Werror=3Dimplicit-function-declaration -Werror=3Dimplicit-int -Werror=3Dincompatible-pointer-types -Werror=3Dint-c= onversion -Werror=3Doverflow -Werror=3Doverride-init -Werror=3Dreturn-type -Werror=3Dshift-count-overflow -Werror=3Dshift-overflow=3D2 -Werror=3Dundef -Wfloat-equal -Wimplicit-fallthrough=3D5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=3D2 -Wstrict-prototypes -Wsuggest-attribute=3Dnoreturn -Wunused-function -Wwrite-strings -Wzero-length-bounds -Wno-maybe-uninitial= ized -Wno-unused-result -Werror=3Dmissing-declarations -Werror=3Dmissing-prototy= pes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=3Dhidden --param=3Dssp-buffer-size=3D4 -ffunction-sections -fdata-sections -Werror=3Dshadow -include config.h -O2 = -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=3D/home/hp/cfp/build/workspace/sources/systemd=3D/usr/sr= c/debug/systemd/1_253.4+git999-r0 -fdebug-prefix-map=3D/home/hp/cfp/build/workspace/sources/systemd=3D/usr/sr= c/debug/systemd/1_253.4+git999-r0 -fmacro-prefix-map=3D/home/hp/cfp/build/tmp/work/cortexa9hf-neon-poky-linux= -gnueabi/systemd/1_253.4+git999-r0/systemd-253.4+git999=3D/usr/src/debug/sy= stemd/1_253.4+git999-r0 -fdebug-prefix-map=3D/home/hp/cfp/build/tmp/work/cortexa9hf-neon-poky-linux= -gnueabi/systemd/1_253.4+git999-r0/systemd-253.4+git999=3D/usr/src/debug/sy= stemd/1_253.4+git999-r0 -fdebug-prefix-map=3D/home/hp/cfp/build/tmp/work/cortexa9hf-neon-poky-linux= -gnueabi/systemd/1_253.4+git999-r0/recipe-sysroot=3D -fmacro-prefix-map=3D/home/hp/cfp/build/tmp/work/cortexa9hf-neon-poky-linux= -gnueabi/systemd/1_253.4+git999-r0/recipe-sysroot=3D -fdebug-prefix-map=3D/home/hp/cfp/build/tmp/work/cortexa9hf-neon-poky-linux= -gnueabi/systemd/1_253.4+git999-r0/recipe-sysroot-native=3D -pthread -MD -MQ systemctl.p/src_systemctl_systemctl-add-dependency.c.o -MF systemctl.p/src_systemctl_systemctl-add-dependency.c.o.d -o systemctl.p/src_systemctl_systemctl-add-dependency.c.o -c ../../../../../../workspace/sources/systemd/src/systemctl/systemctl-add-dep= endency.c I'm told that the performance regression is more visible with "systemctl daemon-reload" (here's where a 3 seconds to 8 seconds regression was observ= ed) but that might affect the system-under-test negatively, and so "systemctl unmask x" is the preferable safe means to expose the problem; x can be repl= ace, but it's assumed here that x is *not* the name of a systemd service. Quoti= ng my colleague on the performance regression: "It is scaling depending on how many service files there is on system. Before looping through each file took just a few milliseconds if i remember correctly and with the flag -ftrivial-auto-var-init=3Dzero each unit took bettween 50-250 milliseconds." When running "systemctl unmask not-a-valid-service-name" on my host Debian = 11 system, I noticed from warning messages that this command indeed seems to p= arse all systemd service files.=