aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2020-04-07 16:57:04 -0700
committerPaul Eggert2020-04-07 18:26:01 -0700
commitb9b32074cecb0e0d20cf527eadacbb0b7f5cced9 (patch)
tree959e0dbb2e49f23b13b81d9efcca681ad6b4b341
parent6382e1330814ca4df20eeccd8b4ef9ca17b997af (diff)
downloademacs-b9b32074cecb0e0d20cf527eadacbb0b7f5cced9.tar.gz
emacs-b9b32074cecb0e0d20cf527eadacbb0b7f5cced9.zip
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
-rw-r--r--src/conf_post.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/conf_post.h b/src/conf_post.h
index eb8fb18c00c..79fb4cfe8a7 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -432,15 +432,13 @@ extern int emacs_setenv_TZ (char const *);
432 432
433#else 433#else
434 434
435/* Use 'static' instead of 'extern inline' because 'static' typically 435/* Use 'static inline' instead of 'extern inline' because 'static inline'
436 has better performance for Emacs. Do not use the 'inline' keyword, 436 has much better performance for Emacs when compiled with 'gcc -Og'. */
437 as modern compilers inline automatically. ATTRIBUTE_UNUSED
438 pacifies gcc -Wunused-function. */
439 437
440# ifndef INLINE 438# ifndef INLINE
441# define INLINE EXTERN_INLINE 439# define INLINE EXTERN_INLINE
442# endif 440# endif
443# define EXTERN_INLINE static ATTRIBUTE_UNUSED 441# define EXTERN_INLINE static inline
444# define INLINE_HEADER_BEGIN 442# define INLINE_HEADER_BEGIN
445# define INLINE_HEADER_END 443# define INLINE_HEADER_END
446 444