Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[POLLING] -Os for kernel is good or not? :)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Bash[DevNull]
Guru
Guru


Joined: 10 Oct 2003
Posts: 333

PostPosted: Sat Mar 11, 2006 7:32 am    Post subject: [POLLING] -Os for kernel is good or not? :) Reply with quote

Interesting in yours opinion
_________________
Biomechanical Artificial Sabotage Humanoid
Back to top
View user's profile Send private message
bollucks
l33t
l33t


Joined: 27 Oct 2004
Posts: 606

PostPosted: Sat Mar 11, 2006 10:40 am    Post subject: Reply with quote

Yes

(If you can find a workload, any workload with hard numbers to show it's better or worse I'll be very very impressed)
Back to top
View user's profile Send private message
frenkel
Veteran
Veteran


Joined: 13 May 2003
Posts: 1034
Location: .nl

PostPosted: Sat Mar 11, 2006 3:14 pm    Post subject: Reply with quote

No, get's loaded once and after that stays in memory. It's _the_ most important thing your computer is running, don't optimize for size, but for speed.
Back to top
View user's profile Send private message
tkdfighter
Apprentice
Apprentice


Joined: 14 May 2004
Posts: 271
Location: Bludenz, Austria

PostPosted: Sat Mar 11, 2006 9:12 pm    Post subject: Reply with quote

If you want to run the Linux kernel on an embedded system, you should probably optimize for size using -Os. But for any other computer you will want to go for -O2.

But that's just my 2c.
Back to top
View user's profile Send private message
bollucks
l33t
l33t


Joined: 27 Oct 2004
Posts: 606

PostPosted: Sun Mar 12, 2006 9:28 am    Post subject: Reply with quote

Here read an informed decision:
http://article.gmane.org/gmane.linux.kernel.ck/4689
Back to top
View user's profile Send private message
stef
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jul 2003
Posts: 93

PostPosted: Wed Mar 15, 2006 10:16 am    Post subject: Reply with quote

Well, I am using -Os for my kernel now
(have been using -Os as CFLAG for my system some time and well ... had more ram which for me felt speeding up things as less swapping makes everything way faster) ...
I recently changed back my CFLAGS to -O2 since -Os caused some bad binaries for some kde packages (gcc is a hard thing to keep working correctly)
but so far kernel seems to be running perfectly so i keep this... (and maybe also try -Os for CFLAGS again and see if gcc does it now)
Back to top
View user's profile Send private message
Bash[DevNull]
Guru
Guru


Joined: 10 Oct 2003
Posts: 333

PostPosted: Wed Mar 15, 2006 1:52 pm    Post subject: Reply with quote

stef wrote:
Well, I am using -Os for my kernel now
(have been using -Os as CFLAG for my system some time and well ... had more ram which for me felt speeding up things as less swapping makes everything way faster) ...
I recently changed back my CFLAGS to -O2 since -Os caused some bad binaries for some kde packages (gcc is a hard thing to keep working correctly)
but so far kernel seems to be running perfectly so i keep this... (and maybe also try -Os for CFLAGS again and see if gcc does it now)


and how much RAM in your system?
On my NoteBook just 256Mb... so im thinking to change -O3 to -Os for all packages...
_________________
Biomechanical Artificial Sabotage Humanoid
Back to top
View user's profile Send private message
stef
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jul 2003
Posts: 93

PostPosted: Sat Mar 18, 2006 12:10 pm    Post subject: Reply with quote

I have 512 MB on AMD64 (so progs get a little bigger because of pointers being 64 instead of 32 bit)

But well .. yesterday i got IO error on my hd, so I guess it maybe still buggy gcc for me on -Os .. so i'll switch back to normal compilation for kernel and see if it's bad hardware or really a software/compiler problem)
Back to top
View user's profile Send private message
Kaapeli
Tux's lil' helper
Tux's lil' helper


Joined: 27 Dec 2004
Posts: 110
Location: Oulu, Finland

PostPosted: Sat Mar 18, 2006 8:14 pm    Post subject: Reply with quote

bollucks wrote:
Here read an informed decision:
http://article.gmane.org/gmane.linux.kernel.ck/4689


(quoted from the above website)
Quote:

Well the kernel is a different beast to userspace. The cycles saved by using
O2 in the kernel are almost certainly offset by the extra icache footprint of
the larger kernel created by O2 versus Os. In the kernel's case, compiling
for size effectively allows more ram for userspace to use. Thus, optimising
the kernel for size can speed up userspace.


My thought is that saving a few megabytes doesn't really have any significant speedup on userspace, especially if you already have a gigabyte of ram or so. I understand that if you're very low in ram, saving a few megabytes can make a difference, but PCs today tend to have so much ram that saving a few megabytes will only have very marginal effect on userspace performance.

Quote:
It is not common that a kernel
function itself actually costs you much in cpu cycles, so this is a better
compromise - most of your cycles are spent in userspace. If the kernel _is_
using a lot of cpu cycles then that is a bug in the kernel and O2 isn't the
way to fix it.


I thought that the sys column on top and vmstat indicates the amount of CPU cycles spent on kernel mode. When running some scripts that forks a lot (emerging something for example), it's not uncommon for me to see the sys percentage to go above 50% level. Does that mean my CPU is spending way too much time in kernel mode or something else?
_________________
Temperatures
Back to top
View user's profile Send private message
bollucks
l33t
l33t


Joined: 27 Oct 2004
Posts: 606

PostPosted: Sun Mar 19, 2006 12:44 am    Post subject: Reply with quote

Kaapeli wrote:
My thought is that saving a few megabytes doesn't really have any significant speedup on userspace, especially if you already have a gigabyte of ram or so. I understand that if you're very low in ram, saving a few megabytes can make a difference, but PCs today tend to have so much ram that saving a few megabytes will only have very marginal effect on userspace performance.

The L1 cache in your cpu is absolutely miniscule. This isn't about ordinary ram. Check the output of the command:
Code:
dmesg | grep L1
and you'll see why it counts. This is the fastest ram your CPU operates from, followed by the L2 cache (substitute L1 above with L2). This does matter.
Kaapeli wrote:
I thought that the sys column on top and vmstat indicates the amount of CPU cycles spent on kernel mode. When running some scripts that forks a lot (emerging something for example), it's not uncommon for me to see the sys percentage to go above 50% level. Does that mean my CPU is spending way too much time in kernel mode or something else?

That's usually for short bursts when you are calling on system resources and are limited in ways beyond simple CPU "calculations". Most things spend their time in userspace, and if they don't there's something wrong. Real cpu bound things like mp3 encoding and the like use close to zero system time except when waiting on I/O.

As I said originally, though: If you can find any hard evidence it helps either way I'll be impressed.
Back to top
View user's profile Send private message
stef
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jul 2003
Posts: 93

PostPosted: Thu Mar 23, 2006 11:25 am    Post subject: Reply with quote

just for information:
switched back to kernel without -Os after the IO error mentioned above.
s.m.a.r.t. does not find any errors and I didn't get any IO errors anymore,
so seems to be a bug in gcc (GCC) 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8 )
on amd64 .. at least for me. (hopefully they'll get -Os fixed in gcc some days)

just in case one didn't think of L1/L2 caches and is too lazy to look it up - here' mine:
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)
so really some MB more or less do make a difference.
Back to top
View user's profile Send private message
stef
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jul 2003
Posts: 93

PostPosted: Fri Apr 07, 2006 12:17 pm    Post subject: Reply with quote

switched to gcc 4.1 ... and now trying -Os kernel 2.6.16-r1 - up to now everything fine!
Back to top
View user's profile Send private message
sirdilznik
l33t
l33t


Joined: 28 Apr 2005
Posts: 731

PostPosted: Fri Apr 07, 2006 3:16 pm    Post subject: Reply with quote

I've been running -Os for my kernel since it became an option (rest of my system is -O2). As far as stability goes I've had zero issues. As far as performance goes, I agree with bollucks, performance difference is negligible if any.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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