emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b9b3207: Improve inlining when compiling with -Og


From: Paul Eggert
Subject: master b9b3207: Improve inlining when compiling with -Og
Date: Tue, 7 Apr 2020 21:26:06 -0400 (EDT)

branch: master
commit b9b32074cecb0e0d20cf527eadacbb0b7f5cced9
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Improve inlining when compiling with -Og
    
    * src/conf_post.h (EXTERN_INLINE) [!EMACS_EXTERN_INLINE]:
    Make it static inline, not merely static.  This is a worthwhile
    performance improvement on my two platforms A and B (see below).
    On my platform A this change improves user+system CPU performance of
    ‘make compile-always’ by 52% on an -Og build, and by 1.4% on the
    default -O2 build.  On my platform B this improves the same benchmark
    by 41% on an -Og build, and by -0.8% on the default -O2 build.
    That "-0.8%" is a small negative for this change, and I recall that
    it is why I didn't make this change earlier.  However, Platform B uses
    an older GCC so we needn't worry overmuch about this small negative.
    
    With this change the performance advantage of -O2 over -Og has dropped
    on platform A; formerly -O2 was 87% faster than -Og, and now it is
    only 25% faster.  On platform B the performance advantage of -O2 over
    -Og has dropped from being 62% faster to being 14% faster.
    
    Platform A is GCC 9.3.1 20200317 (Red Hat 9.3.1-1) on Fedora 31
    x86-64 (AMD Phenom II X4 910e, circa 2010).  Platform B is GCC (Ubuntu
    7.5.0-3ubuntu1~18.04) 7.5.0 on Ubuntu 18.04.4 (Intel Xeon E3-1225 V2,
    circa 2012).
    
    This patch was inspired by a suggestion by Andrea Corallo in:
    https://lists.gnu.org/r/emacs-devel/2020-04/msg00263.html
---
 src/conf_post.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/conf_post.h b/src/conf_post.h
index eb8fb18..79fb4cf 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -432,15 +432,13 @@ extern int emacs_setenv_TZ (char const *);
 
 #else
 
-/* Use 'static' instead of 'extern inline' because 'static' typically
-   has better performance for Emacs.  Do not use the 'inline' keyword,
-   as modern compilers inline automatically.  ATTRIBUTE_UNUSED
-   pacifies gcc -Wunused-function.  */
+/* Use 'static inline' instead of 'extern inline' because 'static inline'
+   has much better performance for Emacs when compiled with 'gcc -Og'.  */
 
 # ifndef INLINE
 #  define INLINE EXTERN_INLINE
 # endif
-# define EXTERN_INLINE static ATTRIBUTE_UNUSED
+# define EXTERN_INLINE static inline
 # define INLINE_HEADER_BEGIN
 # define INLINE_HEADER_END
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]