[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: testsuite: Pass -kb16k -kc128k for performance tests

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue May 30 17:07:07 UTC 2023



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
f7f9e4e7 by Matthew Pickering at 2023-05-30T13:06:59-04:00
testsuite: Pass -kb16k -kc128k for performance tests

Setting a larger stack chunk size gives a greater protection
from stack thrashing (where the repeated overflow/underflow allocates a lot of
stack chunks which sigificantly impact allocations). This
stabilises some tests against differences cause by more things being
pushed onto the stack.

The performance tests are generally testing work done by the compiler,
using allocation as a proxy, so removing/stabilising the allocations due
to the stack gives us more stable tests which are also more sensitive
to actual changes in compiler performance.

The tests which increase are ones where we compile a lot of modules, and
for each module we spawn a thread to compile the module in. Therefore
increasing these numbers has a multiplying effect on these tests because
there are many more stacks which we can increase in size.

The most significant improvements though are cases such as T8095 which
reduce significantly in allocations (30%). This isn't a performance
improvement really but just helps stabilise the test against this
threshold set by the defaults.

Fixes #23439

-------------------------
Metric Decrease:
    InstanceMatching
    T14683
    T8095
    T9872b_defer
    T9872d
    T9961
    hie002
    T19695
    T3064
Metric Increase:
    MultiLayerModules
    T13701
    T14697
-------------------------

- - - - -
f6f46fc6 by Ben Gamari at 2023-05-30T13:06:59-04:00
Move via-C flags into GHC

These were previously hardcoded in configure (with no option for
overriding them) and simply passed onto ghc through the settings file.

Since configure already guarantees gcc supports those flags, we simply
move them into GHC.

- - - - -


10 changed files:

- compiler/GHC/Settings/IO.hs
- configure.ac
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cfg/system.config.in
- hadrian/src/Rules/Generate.hs
- − m4/fp_gcc_extra_flags.m4
- + m4/fp_gcc_supports_via_c_flags.m4
- testsuite/driver/testlib.py


Changes:

=====================================
compiler/GHC/Settings/IO.hs
=====================================
@@ -76,7 +76,6 @@ initSettings top_dir = do
       getToolSetting :: String -> ExceptT SettingsError m String
       getToolSetting key = expandToolDir useInplaceMinGW mtool_dir <$> getSetting key
   targetPlatformString <- getSetting "target platform string"
-  myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
   cc_prog <- getToolSetting "C compiler command"
   cxx_prog <- getToolSetting "C++ compiler command"
   cc_args_str <- getToolSetting "C compiler flags"
@@ -93,6 +92,16 @@ initSettings top_dir = do
       cpp_args = map Option (words cpp_args_str)
       cc_args  = words cc_args_str ++ unreg_cc_args
       cxx_args = words cxx_args_str
+
+      -- The extra flags we need to pass gcc when we invoke it to compile .hc code.
+      --
+      -- -fwrapv is needed for gcc to emit well-behaved code in the presence of
+      -- integer wrap around (#952).
+      extraGccViaCFlags = if platformUnregisterised platform
+                            -- configure guarantees cc support these flags
+                            then ["-fwrapv", "-fno-builtin"]
+                            else []
+
   ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind"
   ldSupportsFilelist      <- getBooleanSetting "ld supports filelist"
   ldSupportsResponseFiles <- getBooleanSetting "ld supports response files"
@@ -204,7 +213,7 @@ initSettings top_dir = do
       , toolSettings_opt_lc      = []
       , toolSettings_opt_i       = []
 
-      , toolSettings_extraGccViaCFlags = words myExtraGccViaCFlags
+      , toolSettings_extraGccViaCFlags = extraGccViaCFlags
       }
 
     , sTargetPlatform = platform


=====================================
configure.ac
=====================================
@@ -622,14 +622,15 @@ FP_GCC_VERSION
 dnl ** See whether cc supports -no-pie
 FP_GCC_SUPPORTS_NO_PIE
 
+dnl ** Check support for the extra flags passed by GHC when compiling via C
+FP_GCC_SUPPORTS_VIA_C_FLAGS
+
 dnl ** Used to determine how to compile ghc-prim's atomics.c, used by
 dnl    unregisterised, Sparc, and PPC backends. Also determines whether
 dnl    linking to libatomic is required for atomic operations, e.g. on
 dnl    RISCV64 GCC.
 FP_CC_SUPPORTS__ATOMICS
 
-FP_GCC_EXTRA_FLAGS
-
 dnl ** look to see if we have a C compiler using an llvm back end.
 dnl
 FP_CC_LLVM_BACKEND


=====================================
distrib/configure.ac.in
=====================================
@@ -164,7 +164,7 @@ AC_SUBST([OptCmd])
 dnl ** Check gcc version and flags we need to pass it **
 FP_GCC_VERSION
 FP_GCC_SUPPORTS_NO_PIE
-FP_GCC_EXTRA_FLAGS
+FP_GCC_SUPPORTS_VIA_C_FLAGS
 
 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])


=====================================
hadrian/bindist/Makefile
=====================================
@@ -79,8 +79,7 @@ WrapperBinsDir=${bindir}
 # N.B. this is duplicated from includes/ghc.mk.
 lib/settings : config.mk
 	@rm -f $@
-	@echo '[("GCC extra via C opts", "$(GccExtraViaCOpts)")' >> $@
-	@echo ',("C compiler command", "$(SettingsCCompilerCommand)")' >> $@
+	@echo '[("C compiler command", "$(SettingsCCompilerCommand)")' >> $@
 	@echo ',("C compiler flags", "$(SettingsCCompilerFlags)")' >> $@
 	@echo ',("C++ compiler command", "$(SettingsCxxCompilerCommand)")' >> $@
 	@echo ',("C++ compiler flags", "$(SettingsCxxCompilerFlags)")' >> $@


=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -234,7 +234,6 @@ GhcRtsWithLibdw=$(strip $(if $(filter $(TargetArch_CPP),i386 x86_64 s390x), at UseL
 # might become redundant.
 # See Note [tooldir: How GHC finds mingw on Windows]
 
-GccExtraViaCOpts = @GccExtraViaCOpts@
 LdHasFilelist = @LdHasFilelist@
 LdSupportsResponseFiles = @LdSupportsResponseFiles@
 LdHasBuildId = @LdHasBuildId@


=====================================
hadrian/cfg/system.config.in
=====================================
@@ -137,7 +137,6 @@ conf-merge-objects-args-stage3  = @MergeObjsArgs@
 # might become redundant.
 # See Note [tooldir: How GHC finds mingw on Windows]
 
-gcc-extra-via-c-opts = @GccExtraViaCOpts@
 ld-has-no-compact-unwind = @LdHasNoCompactUnwind@
 ld-has-filelist = @LdHasFilelist@
 ld-supports-response-files = @LdSupportsResponseFiles@


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -411,8 +411,7 @@ generateSettings :: Expr String
 generateSettings = do
     ctx <- getContext
     settings <- traverse sequence $
-        [ ("GCC extra via C opts", expr $ lookupSystemConfig "gcc-extra-via-c-opts")
-        , ("C compiler command", expr $ settingsFileSetting SettingsFileSetting_CCompilerCommand)
+        [ ("C compiler command", expr $ settingsFileSetting SettingsFileSetting_CCompilerCommand)
         , ("C compiler flags", expr $ settingsFileSetting SettingsFileSetting_CCompilerFlags)
         , ("C++ compiler command", expr $ settingsFileSetting SettingsFileSetting_CxxCompilerCommand)
         , ("C++ compiler flags", expr $ settingsFileSetting SettingsFileSetting_CxxCompilerFlags)


=====================================
m4/fp_gcc_extra_flags.m4 deleted
=====================================
@@ -1,20 +0,0 @@
-# FP_GCC_EXTRA_FLAGS
-# ------------------
-# Determine which extra flags we need to pass gcc when we invoke it
-# to compile .hc code.
-#
-# -fwrapv is needed for gcc to emit well-behaved code in the presence of
-# integer wrap around. (#952)
-#
-AC_DEFUN([FP_GCC_EXTRA_FLAGS],
-[AC_REQUIRE([FP_GCC_VERSION])
-AC_CACHE_CHECK([for extra options to pass gcc when compiling via C], [fp_cv_gcc_extra_opts],
-[
- if test "$Unregisterised" = "YES"; then
-   # These used to be conditioned on gcc version but we no longer support
-   # GCC versions which lack support for these flags
-   fp_cv_gcc_extra_opts="-fwrapv -fno-builtin"
- fi
-])
-AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
-])


=====================================
m4/fp_gcc_supports_via_c_flags.m4
=====================================
@@ -0,0 +1,17 @@
+# FP_GCC_SUPPORTS_VIA_C_FLAGS
+# ---------------------------
+# Make sure GCC supports the flags passed by GHC when compiling via C
+AC_DEFUN([FP_GCC_SUPPORTS_VIA_C_FLAGS],
+[
+   AC_REQUIRE([AC_PROG_CC])
+   AC_MSG_CHECKING([whether CC supports flags passed by GHC when compiling via C])
+   echo 'int main() { return 0; }' > conftest.c
+   if $CC -fwrapv -fno-builtin -Werror -x c conftest.c -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then
+       AC_MSG_RESULT([yes])
+   else
+       AC_MSG_RESULT([no])
+       AC_MSG_ERROR([gcc must support the flags -fwrapv and -fno-builtin])
+   fi
+   rm -f conftest.c conftest.o conftest
+])
+


=====================================
testsuite/driver/testlib.py
=====================================
@@ -1791,7 +1791,11 @@ async def simple_build(name: Union[TestName, str],
 
     stats_file = name + '.comp.stats'
     if isCompilerStatsTest():
-        extra_hc_opts += ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS'
+        # Set a bigger chunk size to reduce variation due to additional under/overflowing
+        # The tests are attempting to test how much work the compiler is doing by proxy of
+        # bytes allocated. The additional allocations caused by stack overflow can cause
+        # spurious failures if you trip over the limit (see #23439)
+        extra_hc_opts += ' +RTS -kc128k -kb16k -V0 -t' + stats_file + ' --machine-readable -RTS'
     if backpack:
         extra_hc_opts += ' -outputdir ' + name + '.out'
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdec1da2575588d0b7d04a76e45e826d43ec134b...f6f46fc6479890d07e5c215e40cc3bd6a954a9d6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdec1da2575588d0b7d04a76e45e826d43ec134b...f6f46fc6479890d07e5c215e40cc3bd6a954a9d6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230530/3fcc6163/attachment-0001.html>


More information about the ghc-commits mailing list