DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 29th May 2008
Sunsawe Sunsawe is offline
Port Guard
 
Join Date: May 2008
Posts: 39
Question How to optimize FreeBSD 7.0 ?

Hi,

While i was googling, i found this page.

The optimizations described are said 'applyable' to FreeBSD 4 and 5.
Can they be applied to a FreeBSD 7.0 ? I am interesting in optimizing the software compilation process. Where can i find an up to date guide to achieve this?
How, once it is done, recompile all the already installed ports?

Thanks
Reply With Quote
  #2   (View Single Post)  
Old 29th May 2008
erno erno is offline
Port Guard
 
Join Date: May 2008
Location: Finland
Posts: 12
Default

I suggest that you leave your CFLAGS alone. You just break things if you play with them. Default CFLAGS are quaranteed to work.
Reply With Quote
  #3   (View Single Post)  
Old 29th May 2008
Oliver_H's Avatar
Oliver_H Oliver_H is offline
Real Name: Oliver Herold
UNIX lover
 
Join Date: May 2008
Location: Germany
Posts: 427
Default

Just change the scheduler from 4BSD to SCHED_ULE.
__________________
use UNIX or die :-)
Reply With Quote
  #4   (View Single Post)  
Old 29th May 2008
Sunsawe Sunsawe is offline
Port Guard
 
Join Date: May 2008
Posts: 39
Default

Quote:
Originally Posted by erno View Post
I suggest that you leave your CFLAGS alone. You just break things if you play with them. Default CFLAGS are quaranteed to work.
Maybe, but I don't think that's the best way to learn more about it and how to use it even more efficiently.

That's why I am asking. I guess that if these flags are there and modifiable it must be because they can be used and I'd like to know how.
If somebody can help me....
Reply With Quote
  #5   (View Single Post)  
Old 29th May 2008
richardpl richardpl is offline
Spam Deminer
 
Join Date: May 2008
Location: Croatia
Posts: 284
Default

But that flags may interact very badly with some ports, so use them on your own risk.
Reply With Quote
  #6   (View Single Post)  
Old 29th May 2008
Sunsawe Sunsawe is offline
Port Guard
 
Join Date: May 2008
Posts: 39
Default

Quote:
Originally Posted by richardpl View Post
But that flags may interact very badly with some ports, so use them on your own risk.
yes I got that. But being afraid of them won't help me to understand them.
Of course I have a sandbox to play with them. I would just like to have a more detailed guide than the make.conf itself.
Reply With Quote
  #7   (View Single Post)  
Old 29th May 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 445
Default

@Sunsawe: tinkering to learn more is a noble effort, IMO, but there is a clearly a best practice here. If you mess with your CFLAGS (against the good advice on this thread), you're on your own to fix the problem.

From the manpages for make.conf(5):
Quote:
CFLAGS (str) Controls the compiler setting when compiling C code.
Optimization levels other than -O and -O2 are not sup-
ported...
__________________
Kill your t.v.
Reply With Quote
  #8   (View Single Post)  
Old 29th May 2008
harisman's Avatar
harisman harisman is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Hellas (Greece)
Posts: 66
Default

Dont' play with the CFLAGS, just set the CPUTYPE value to according your CPU on /etc/make.conf . This enables all the safe and recommended optimizations.

Last edited by harisman; 29th May 2008 at 03:37 PM.
Reply With Quote
  #9   (View Single Post)  
Old 29th May 2008
Sunsawe Sunsawe is offline
Port Guard
 
Join Date: May 2008
Posts: 39
Default

Thanks, it seems that only setting the cpu is useful.
But how can I recompile all the already installed ports to take this change in account?
Reply With Quote
Old 29th May 2008
harisman's Avatar
harisman harisman is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Hellas (Greece)
Posts: 66
Default

First, do a backup of all installed packages with pkg_create -b using a 'for' loop

Then, do a portupgrade -arR
Reply With Quote
Old 29th May 2008
Oliver_H's Avatar
Oliver_H Oliver_H is offline
Real Name: Oliver Herold
UNIX lover
 
Join Date: May 2008
Location: Germany
Posts: 427
Default

The performance gain will be marginal but looking after the problem if some port fails to compile will drives you crazy. Furthermore posting a PR with such 'optimizations' will not get you any response. This is in my opinion 'Gentooish behaviour'.

>But how can I recompile all the already installed ports to take this change in account?

As you can see, there are more important thing to learn instead of tinkering with the stability and reliability of the system

http://www.gsp.com/cgi-bin/man.cgi?s...ic=portupgrade
__________________
use UNIX or die :-)
Reply With Quote
Old 29th May 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

The posts generally applicable.

My advice:

Set CPUTYPE as harisman suggested, it makes sense to do so (for example I havn't used any thing but i685 and em64t chips in a long time, never seen an Intel 80386 either)

Using SCHED_ULE might be worth while as Oliver_H posted. I've personally never had a problem with any of the schedulers I've built kernels off, but I don't run high load servers !

Do not mess with CFLAGS or CXXFLAGS unless you know what you are doing.

Do not mess with CFLAGS unless you know what you are doing and are a C Programmer familiar with the available options to gcc.

Do not not mess with CXXFLAGS unless you know what you are doing and are a C++ Programmer familiar with the available options to g++.

Do not touch CFLAGS or CXXFLAGS for building world or kernel unless you are a FreeBSD hacker and know what you are doing.

Always read the compiler documentation before setting CFLAGS/CXXFLAGS outside your own programs, and even then read it if you don't know what is happening.


(Might seem rude but the above comments might make life easier in the long run.)


The cross reference to optimizing kernel builds should be taken with a grain of salt as far as some parts go. Same for the kernel related options imho -> make sure of things before screwing around with non-important stuff, less headaches then hunt & pecking options.


Locate bottlenecks before trying to optimize them.

Quote:
Originally Posted by the article
With any performance tuning, it is important to monitor your system after you make your changes. Did you go overboard, or underestimate what you would need? Always check and adjust accordingly. The numbers here might not be the exact ones that you need!

Unless you hit a spot that can benefit from optimization, you probably shouldn't change things from defaults unless you know what your changing or are willing to play with it until you either break it, fix it, or perfect it.


PS:

I generally build my own programs with CFLAGS set to one of these values in my makefiles:

Code:
# normal build
CFLAGS= -Wall -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion \
        -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes \
        -Wmissing-declarations -Wredundant-decls -Winline -Wnested-externs\
        -std=c99 -march=i686

# for debugging builds append to CFLAGS
 -ggdb  # or -g3

# optimized builds with options added after clfags, used for testing for problems that may occur in the code when optimized
OFLAGS= -fforce-mem -fforce-addr -finline-functions -fstrength-reduce \
        -floop-optimize -O3
These are my standard settings, each was chosen with consideration behind the them and I usually settle on warnings only while writing things, saving the rest for playing around.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 30th May 2008
ddekok ddekok is offline
Port Guard
 
Join Date: May 2008
Posts: 38
Default

Quote:
Originally Posted by richardpl View Post
But that flags may interact very badly with some ports, so use them on your own risk.
This is very true. I was banging my head against the desk when I couldn't figure out why TripWire built but could never generate the keys for signing files. Turns out TripWire doesn't like

Code:
CFLAGS=-O2 -pipe
On a desktop system, you can fiddle with it, just be aware of the consequences. In a production setting, I would stay away from it.
Reply With Quote
Old 30th May 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,056
Default

here you have an example /etc/make.conf from one of my boxes:
http://toya.net.pl/~vermaden/text/make.conf

you should also tweak /etc/src.conf for base system components tweaking: src.conf(5)
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
Old 30th May 2008
Oliver_H's Avatar
Oliver_H Oliver_H is offline
Real Name: Oliver Herold
UNIX lover
 
Join Date: May 2008
Location: Germany
Posts: 427
Default

But remember vermaden is a former Gentoo user ;-)
__________________
use UNIX or die :-)
Reply With Quote
Old 1st June 2008
tonywob tonywob is offline
Real Name: Tony
New User
 
Join Date: May 2008
Location: United Kingdom
Posts: 9
Default

After messing with my CFLAGS on a test system, I am inclined to agree that leaving them alone is for the best. I used O3 optimizations and noticed the stability of the system fell as a consequence.

Also, messing with the CFLAGS often prevents a successful buildworld.

The only optimizations I now do, is to set the CPUTYPE. I remove unnecessary modules from the kernel, and use the ULE scheduler.
Reply With Quote
Old 1st June 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

None of you should be messing with the CFLAGS, unless you have the slightest idea what the options do, leave them alone.. you're more likely to break something then improve performance any.
Reply With Quote
Old 2nd June 2008
ninjatux's Avatar
ninjatux ninjatux is offline
Real Name: Baqir Majlisi
Spam Deminer
 
Join Date: May 2008
Location: Antarctica
Posts: 293
Default

Quote:
Originally Posted by Oliver_H View Post
But remember vermaden is a former Gentoo user ;-)
vermaden is a smart ex-Gentoo user who's settled on a great operating system in its place. I'm sure he knows this too. I ditched Gentoo for Debian. I was running FreeBSD, which I like even more, but no official support from ATi and no KDE 4, I think I'll wait to migrate.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick