Re: Convert macros to static inline functions
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Maxim Orlov <orlovmg@gmail.com>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-02-11T09:37:16Z
Lists: pgsql-hackers
On 31.01.25 14:29, Maxim Orlov wrote: > Great job! I've been working on the 64 XIDs patch for years, and I've > never liked this place. On the other hand, > as we know, inlining does not always work since it only suggests to the > compiler to do it. After all, many of > these calls are used in pretty "hot" places and every instruction is > important, in my opinion. Wouldn't it be > better to use pg_attribute_always_inline in this particular module? > > PFA patch. I don't use pg_attribute_always_inline for fastgetattr and > heap_getattr because they are relatively > large. I think it's worth leaving the possibility for debugging here. I've done some analysis with -Winline. The reasons for inlining to fail are: 1) The function is too large. 2) The function call is unlikely. (Usually when used in elog() arguments.) 3) The function can never be inlined because it uses setjmp(). (This is kind of a bug on our end, I think.) The existing uses of pg_attribute_always_inline all appear to address reason 1. I think my/your patch does not touch any functions near the limit size, so it does not seem necessary. I think if we use pg_attribute_always_inline without any evidence, then "inline" by itself might become meaningless.
Commits
-
Add some const decorations (htup.h)
- b15b8c5cf882 18.0 landed
-
Convert macros to static inline functions (htup_details.h, itup.h)
- 34694ec888d6 18.0 landed
-
Convert macros to static inline functions (rel.h)
- 3edc71ec0438 16.0 landed
-
Convert macros to static inline functions (itup.h)
- 14a8bd98274a 16.0 landed
-
Convert macros to static inline functions (tupmacs.h)
- f58d7073b775 16.0 landed
-
Convert macros to static inline functions (xlog_internal.h)
- 507ba16b28c7 16.0 landed
-
Convert macros to static inline functions (bufmgr.h)
- 9c727360bcc7 16.0 landed
-
Convert macros to static inline functions (itemptr.h)
- aeb767ca0b02 16.0 landed
-
Convert macros to static inline functions (bufpage.h)
- 2cd2569c72b8 16.0 landed
-
Convert macros to static inline functions (block.h)
- d63d957e330c 16.0 landed