Gentoo Archives: gentoo-amd64

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-amd64@l.g.o
Subject: [gentoo-amd64] Re: gcc 4.1 + CFLAGS
Date: Fri, 09 Jun 2006 19:01:52
Message-Id: e6cgb0$3tp$1@sea.gmane.org
In Reply to: Re: [gentoo-amd64] gcc 4.1 + CFLAGS by Samir Mishra
1 Samir Mishra <sqmishra@×××.ae> posted 44894503.5010302@×××.ae, excerpted
2 below, on Fri, 09 Jun 2006 13:53:07 +0400:
3
4 > These are the flag settings I have. My WS has >2GB RAM so I'm using
5 > -mcmodel=medium. But as you can see, they are hardly "safe".
6
7 > A few applications fail to compile, but so far from the >500 packages I
8 > currently have on my system, only the following have failed to compile
9 > -- glibc-2.4, gcc, sandbox, strace, transcode, libmpeg3. A few other
10 > applications, mainly noticed with audio applications, are behaving
11 > "strange". But I haven't had the opportunity to track all these problems
12 > down.
13 >
14 > # For GCC 4+
15 > CFLAGS="-march=k8 -O2 -pipe -fomit-frame-pointer -fforce-addr -ftracer
16 > -frename-registers -mno-tls-direct-seg-refs -mcmodel=medium"
17
18 A couple questions:
19
20 -mcmodel=medium: Here's the gcc 4.1.1 manpage entry:
21
22 -mcmodel=medium
23 Generate code for the medium model: The program is linked in the lower 2
24 GB of the address space but symbols can be located any-where in the
25 address space. Programs can be statically or dynamically linked, but
26 building of shared libraries are not supported with the medium model.
27
28 What about that last part -- shared libraries not supported?
29
30 Also... from my understanding, the address-space references here are
31 simply to the program's view of memory, from it's perspective. More
32 specifically, it's not to absolute address space (the >2 gig memory you
33 mention), but to the program's virtual address space, the protected-mode
34 virtual address space unique to it, and rather independent from its actual
35 placement in physical memory or its placement in terms of the kernel's
36 virtual address space.
37
38 As I understand it, therefore, the only reason to use -mcmodel=medium
39 would be if the program itself was expected to manipulate memory on the
40 order of gigs at a time. While this can legitimately happen, say with a
41 big database (think Oracle, which very likely uses such an option), the
42 vast majority of applications don't work with anywhere near that size of
43 data, at least not directly. While they might handle gigs of data over
44 the lifetime of the program, it's megabytes not gigabytes at a time, and
45 much of it may be indirectly, thru the kernel, so they have little need
46 for a memory allocation model that can allocate structures of multiple
47 gigs at a time or to access anything outside a two-gigabyte model. Even
48 on the big machines running apps where use of this model might be
49 legitimately called for, it would be inadvisable to compile /everything/
50 on the machine with it, only the specific apps that need it.
51
52 This would also explain why it only applies to applications, not shared
53 libraries, as only the linked application would need to reference the full
54 multi-gig allocations -- any library functions would presumably be working
55 with much smaller sections of that dataset.
56
57 Note that I'm specifically /not/ saying you are incorrect, only that it
58 disagrees with what I (think I) know, which itself may be incorrect. I'm
59 running 8 gig of memory here, but it's a fairly new upgrade, so a new
60 experience, and it's quite possible what I thought I knew is wrong. If
61 so, I'd like to know it, the better to make use of the memory I have here,
62 as well. So, if you have references as to why you are using that memory
63 model, post 'em, as I'd certainly like to read them myself!
64
65 -ftracer: Of interest here are a couple other manpage entries:
66
67 -fprofile-generate
68 Enable options usually used for instrumenting application to produce
69 profile useful for later recompilation with profile feedback based
70 optimization. [snip]
71
72 -fprofile-use
73 Enable profile feedback directed optimizations, and optimizations
74 generally profitable only with profile feedback available.
75
76 The following options are enabled: "-fbranch-probabilities", "-fvpt",
77 "-funroll-loops", "-fpeel-loops", "-ftracer", "-fno-loop-optimize".
78
79 I don't see either of these in your CFLAGS, and you don't mention
80 compiling, then profiling the program, then recompiling. Without that,
81 the -ftracer flag, which the manpage says "perform[s] tail duplication to
82 enlarge superblock size", would appear to enlarge your binaries for little
83 or no performance gain.
84
85 That said, I've seen a couple developers that use the -ftracer flag as
86 well, in various bug reports and the like, which has surprised me a bit
87 since it's common for devs to complain about others using flags they don't
88 understand the implications of. However, I've yet to find someone who can
89 suitably explain /why/ they use it, given the above and the rather
90 unlikely chance that they actually bother with that profiling and
91 recompilation with every package they use the flag with, tho I don't of
92 course go around posting the question to every bug where I see it used,
93 and I've had limited chance to ask the question in a suitable context, so
94 I've not asked that many about it.
95
96 Again, if you have a good reason to choose that flag, or if you've
97 actually done tests and /know/ it improves performance, please post it, so
98 folks (like me! =8^) can be informed and perhaps optimize their system
99 similarly. Until then, I can't reasonably defend or explain using the
100 flag if I'm not going to go to the trouble of profiling and recompiling,
101 and I don't think the performance gains would be enough to justify that
102 (if I were compiling for use by an entire distribution, not just me, the
103 effort would of course be justified) so I don't choose to use it.
104
105
106
107 --
108 Duncan - List replies preferred. No HTML msgs.
109 "Every nonfree program has a lord, a master --
110 and if you use the program, he is your master." Richard Stallman
111
112 --
113 gentoo-amd64@g.o mailing list

Replies

Subject Author
Re: [gentoo-amd64] Re: gcc 4.1 + CFLAGS Samir Mishra <sqmishra@×××.ae>
Re: [gentoo-amd64] Re: gcc 4.1 + CFLAGS Samir Mishra <sqmishra@×××.ae>