Project

General

Profile

Actions

Bug #10080

closed

Functions marked as "static inline" are not inlined by gcc

Added by gustavo.pedrosa (Gustavo Frederico Temple Pedrosa) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877)
[ruby-core:63920]

Description

Since GCC 4.8.3, some static inline functions (such as rb_call0) are not
inlined in the generated machine code. This happens in both x86-64 and ppc64
platforms and it can be verified by using the following commands:

(in ppc64)

 objdump -dS ruby | grep bl.*rb_call0

   155838:       c1 f8 ff 4b     bl      1550f8 <rb_call0+0x8>
   1558a4:       55 f8 ff 4b     bl      1550f8 <rb_call0+0x8>
   1559e4:       15 f7 ff 4b     bl      1550f8 <rb_call0+0x8>
   158b88:       71 c5 ff 4b     bl      1550f8 <rb_call0+0x8>
   15bf40:       b9 91 ff 4b     bl      1550f8 <rb_call0+0x8>
   15c0f8:       01 90 ff 4b     bl      1550f8 <rb_call0+0x8>
   15c490:       69 8c ff 4b     bl      1550f8 <rb_call0+0x8>
   15c4cc:       2d 8c ff 4b     bl      1550f8 <rb_call0+0x8>
   15c8bc:       3d 88 ff 4b     bl      1550f8 <rb_call0+0x8>
   15cc94:       65 84 ff 4b     bl      1550f8 <rb_call0+0x8>
   15d344:       b5 7d ff 4b     bl      1550f8 <rb_call0+0x8>
   15d3c4:       35 7d ff 4b     bl      1550f8 <rb_call0+0x8>
   
(in x86-64)
  
 objdump -dS ruby | grep call\.*rb_call0
  
   126280:       e8 cb f9 ff ff          callq  125c50 <rb_call0>
   126347:       e8 04 f9 ff ff          callq  125c50 <rb_call0>
   1264cc:       e8 7f f7 ff ff          callq  125c50 <rb_call0>
   128a9e:       e8 ad d1 ff ff          callq  125c50 <rb_call0>
   12ade9:       e8 62 ae ff ff          callq  125c50 <rb_call0>
   12af6a:       e8 e1 ac ff ff          callq  125c50 <rb_call0>
   12b2e6:       e8 65 a9 ff ff          callq  125c50 <rb_call0>
   12b5d7:       e8 74 a6 ff ff          callq  125c50 <rb_call0>
   12b899:       e8 b2 a3 ff ff          callq  125c50 <rb_call0>
   12bccd:       e8 7e 9f ff ff          callq  125c50 <rb_call0>
   12bdf0:       e8 5b 9e ff ff          callq  125c50 <rb_call0>

This behaviour can be fixed if every inlined function were marked with the always_inline attribute when compiling with GCC.

Updated by normalperson (Eric Wong) over 10 years ago

Can you show a performance difference with always_inline on those
functions?

Inlining is not always faster, it bloats the code and eats cache.
Perhaps GCC is avoiding that bloat.

Updated by gustavo.pedrosa (Gustavo Frederico Temple Pedrosa) over 10 years ago

Eric Wong wrote:

Can you show a performance difference with always_inline on those
functions?

Inlining is not always faster, it bloats the code and eats cache.
Perhaps GCC is avoiding that bloat.

Sorry, yes, you are right. There is a small performance penalty when
every function marked as inline is, in fact, inlined. There are other
issues, a lot of functions are not being inlined because GCC cannot
do that or because they imply in code bloating (as detected by the
compiler heuristics). Do you think it would be interesting to remove
the inline keyword in such cases?

Updated by ko1 (Koichi Sasada) over 10 years ago

(2014/07/23 1:31), wrote:

Do you think it would be interesting to remove
the inline keyword in such cases?

Why remove them?

--
// SASADA Koichi at atdot dot net

Updated by normalperson (Eric Wong) over 10 years ago

I don't think removing "inline" is necessary, either. It is a hint
to the compiler (and as evidenced, your compiler is capable of
ignoring it). Different compilers may still inline it and produce
faster code.

Updated by gustavo.pedrosa (Gustavo Frederico Temple Pedrosa) over 10 years ago

Eric Wong wrote:

I don't think removing "inline" is necessary, either. It is a hint
to the compiler (and as evidenced, your compiler is capable of
ignoring it). Different compilers may still inline it and produce
faster code.

Yes, you are right.
So, can I close this issue?

Updated by normalperson (Eric Wong) over 10 years ago

wrote:

So, can I close this issue?

Sure.

Updated by gustavo.pedrosa (Gustavo Frederico Temple Pedrosa) over 10 years ago

Eric Wong wrote:

wrote:

So, can I close this issue?

Sure.

I don't have permissions to close, can you close for me, please?
Thank you very much, indeed.

Updated by normalperson (Eric Wong) over 10 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0