Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved/Answered] -Os vs -O2
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Clete2
Guru
Guru


Joined: 09 Aug 2003
Posts: 530
Location: Bloomington, Illinois

PostPosted: Wed Dec 01, 2010 3:16 pm    Post subject: [Solved/Answered] -Os vs -O2 Reply with quote

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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10590
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Dec 01, 2010 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Clete2
Guru
Guru


Joined: 09 Aug 2003
Posts: 530
Location: Bloomington, Illinois

PostPosted: Wed Dec 01, 2010 3:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Dec 01, 2010 3:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10590
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Dec 01, 2010 3:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
Clete2
Guru
Guru


Joined: 09 Aug 2003
Posts: 530
Location: Bloomington, Illinois

PostPosted: Wed Dec 01, 2010 4:27 pm    Post subject: Reply with quote

Thanks for the input, John and i92guboj. I will go with -Os.
_________________
My Blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum