Gentoo Archives: gentoo-performance

From: Adam Petaccia <adam@×××××××××.com>
To: gentoo-performance@l.g.o
Subject: Re: [gentoo-performance] inline considered harmful
Date: Thu, 22 Jul 2004 00:50:03
Message-Id: 40FF0F39.2070404@tpetaccia.com
In Reply to: [gentoo-performance] inline considered harmful by Mario Domenech Goulart
1 With gcc, is there a way to enable all -O3 options but function
2 inlines? Would -fno-inline work or something like that?
3
4 Mario Domenech Goulart wrote:
5
6 >Hello,
7 >
8 >There's an interesting discussion in the OpenBSD mailing
9 >list about the use of inline.
10 >
11 >Here's the beginning of the thread about this topic:
12 >
13 >,----[ http://www.sigmasoft.com/cgi-bin/wilma_hiliter/openbsd-tech/200407/msg00175.html ]
14 >| inline considered harmful.
15 >|
16 >| * To: tech@×××××××.org
17 >| * Subject: inline considered harmful.
18 >| * From: Artur Grabowski <art@××××××××.org>
19 >| * Date: 21 Jul 2004 03:54:46 +0200
20 >| * User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
21 >|
22 >| Today we did a bunch of removal of inline functions in the kernel.
23 >| It all started to make floppies fit, but now it's a quest.
24 >|
25 >| If you think that I'm crazy doing this because it might hurt your
26 >| precious performance, go back to your vax and leave the performance
27 >| tuning to people who have a cache.
28 >|
29 >| Every single inline we removed today (and there are more in the
30 >| pipeline and even more waiting to be fixed) shrunk the code and MADE
31 >| IT FASTER. Yes, modern cpus have something called "cache". The cache
32 >| prefers the code to be smaller, rather than free from function calls.
33 >| Yes, some cpus have expensive function call overhead. Don't use them.
34 >| i386 has quite expensive function calls, on the other hand it doesn't
35 >| have any relevant amount of registers either. So a function call
36 >| instead of the same function inlined can potentially make the job
37 >| easier for the register allocator in the compiler which could eat the
38 >| overhead. At the same time the instruction cache can run the same code
39 >| in the same place, instead of loading it from main memory 4711 times.
40 >| And guess what? The stack on i386 is in the cache too, so the function
41 >| call overhead isn't that bad anyway.
42 >|
43 >| I'm tired of seeing code where everything is made inline just because
44 >| someone acted on a meme that hasn't been true for over a decade. Bloat,
45 >| bloat and more bloat. Since people can't use inline correctly (it does
46 >| have valid and correct uses), from now on inline in the OpenBSD kernel
47 >| is considered to be a bug until proven otherwise. So. Next time I see
48 >| code that adds to the bloat with inlines, I expect performance figures
49 >| and kernel size comparisons that show that the inline actually
50 >| contributes anything. Otherwise the code does not go in.
51 >|
52 >| There's still a lot of work to be done in the kernel (yes, macros can
53 >| be evil too, just see nfs), so send diffs. And there's a whole
54 >| unexplored field in userland too.
55 >|
56 >| //art
57 >`----
58 >
59 >Mario
60 >
61 >
62 >--
63 >gentoo-performance@g.o mailing list
64 >
65 >
66 >
67 >
68
69 --
70 gentoo-performance@g.o mailing list

Replies

Subject Author
Re: [gentoo-performance] inline considered harmful "Douglas Breault Jr." <GenKreton@×××××××.net>