View previous topic :: View next topic |
Author |
Message |
Clete2 Guru
Joined: 09 Aug 2003 Posts: 530 Location: Bloomington, Illinois
|
Posted: Wed Dec 01, 2010 3:16 pm Post subject: [Solved/Answered] -Os vs -O2 |
|
|
Can someone give an example of `df -h` using -Os vs -O2? I am wondering how much space it saves. _________________ My Blog
Last edited by Clete2 on Wed Dec 01, 2010 4:27 pm; edited 1 time in total |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10590 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Dec 01, 2010 3:21 pm Post subject: |
|
|
I don't think that's the primary reason to choose -Os. On some CPU architectures with small cache, -Os compiled code may run faster because there are more cache hits as opposed to -O2 compiled code. Anecdotally, I can report that the actual disk space saved is minimal. Alas, I don't have anything quantitative.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters.
Last edited by John R. Graham on Wed Dec 01, 2010 4:32 pm; edited 1 time in total |
|
Back to top |
|
|
Clete2 Guru
Joined: 09 Aug 2003 Posts: 530 Location: Bloomington, Illinois
|
Posted: Wed Dec 01, 2010 3:27 pm Post subject: |
|
|
I see. The machine I am considering it on is a Pentium II with 256KB of cache. Maybe -Os is the way to go. Right now I am using -O2.
Edit: I don't know a whole log about processors, so I couldn't tell you what level cache that /proc/cpuinfo is reporting:
/proc/cpuinfo wrote: | processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 6
model name : Mobile Pentium II
stepping : 10
cpu MHz : 363.925
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pse36 mmx fxsr
bogomips : 727.85
clflush size : 32
cache_alignment : 32
address sizes : 36 bits physical, 32 bits virtual
power management: |
_________________ My Blog |
|
Back to top |
|
|
i92guboj Bodhisattva
Joined: 30 Nov 2004 Posts: 10315 Location: Córdoba (Spain)
|
Posted: Wed Dec 01, 2010 3:34 pm Post subject: |
|
|
Indeed, the purpose of -Os is to make the code fit into the CPU cache (in the range of kilobytes/megabytes). It really doesn't make much sense when talking about disk space, even if you have an old machine unless we are talking about devices that have a very limited storage capacity.
To start with, the only files affected by that "optimization" are binary files generated by gcc. Binary files are only a small part of the files you have on your hard disk, and not all of them are generated by gcc (there's java, python, proprietary binaries, and some others). |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10590 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Dec 01, 2010 3:49 pm Post subject: |
|
|
Clete2 wrote: | ...I don't know a whole log about processors, so I couldn't tell you what level cache that /proc/cpuinfo is reporting... | That's the L2 cache; 256k is quite small by modern standards. You should go for -Os for sure.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Clete2 Guru
Joined: 09 Aug 2003 Posts: 530 Location: Bloomington, Illinois
|
Posted: Wed Dec 01, 2010 4:27 pm Post subject: |
|
|
Thanks for the input, John and i92guboj. I will go with -Os. _________________ My Blog |
|
Back to top |
|
|
|