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