How to optimize and accelerate your system

Discussion in general that pertains to Sabayon Linux - Must Pertain to Sabayon Linux

Moderator: Moderators

How to optimize and accelerate your system

Postby yuguang » Sat Feb 06, 2010 20:43

This is a guide to optimizing your Sabayon system. Except for Section 3.1, the tweaks here are independent of desktop environments and applications, so they can be applied to both KDE and GNOME.

Index
1. OpenRC Boot Services in Parallel
2. Disable Automatic Startup of Services
3. Prelink Binaries
    3.1 Speeding Up KDE After Prelinking
4. Tune Hard Drive Performance
5. Preload Programs
6. Look Up Domain Names Faster
7. Xorg Options
    7.1 Keyboard Repeat Delay
    7.2 Intel Graphics Card Tweaks
    7.3 Nvidia Graphics Card Tweaks
    7.4 Ati Graphics Card Tweaks
8. Ram Drive using tmpfs
9. Maximize Bandwidth
10. Multicore Interrupt Balancing

1. OpenRC Boot Services in Parallel
We will start at the beginning with boot performance. This tweak will improve the initial boot performance before kdm/gdm is loaded.
Code: Select all
vim /etc/rc.conf

Change rc_parallel="NO" to rc_parallel="YES" and rc_logger="YES" to rc_logger="NO"

2. Disable Automatic Startup of Services
Some services are essential and should not be disabled, however, there are many that you are probably not using.
To see what services are started automatically, run
Code: Select all
rc-update show

To delete services, give rc-update the del argument, followed by the script and runlevel. For example, to remove file system support for RAID:
Code: Select all
rc-update del mdadm default

Other services to consider disabling include
    lvm - logical volume management, which you may have used during install if you let the installer automatically partition
    nfsmount - mounts network file systems
    sabayon-mce - media center service, associated with XBMC
    netmount - included with Gentoo to network-boot from an installation CD

see also http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4

3. Prelink Binaries
Because Sabayon is a binary distribution, linking optimization is done after compile. For this tweak to work, your CXXFLAGS in make.conf must not contain -fvisibility-inlines-hidden. This flag makes gcc avoid exporting unneeded symbols from libraries, making them smaller.
Prelink is not in Sabayon repositories yet, so the proper procedure is to add prelink to /etc/entropy/packages/package.mask. Install prelink
Code: Select all
emerge prelink

Run the command to generate prelink configuration file
Code: Select all
env-update

Prelink all binaries with
Code: Select all
prelink -amR

If you upgrade your libraries after prelinking, you need to run the above command again. Alternatively, automate the task:
Code: Select all
vim /etc/conf.d/prelink

Enable the daily cron job.

3.1 Speeding Up KDE After Prelinking
If you're running KDE, there is an extra step to disable kdeinit
Code: Select all
ls /etc/env.d/ | grep kdepaths

Code: Select all
vim /etc/env.d/*kdepaths

Set KDE_IS_PRELINKED=1

see also http://www.gentoo.org/doc/en/prelink-howto.xml

4. Tune Hard Drive Performance
The hard drive is the slowest compenent of your computer. A little tuning goes a long way for performance.
Code: Select all
vim /etc/conf.d/hdparm

Add the following at the bottom
    hda_args="-a16 -c1 -k1 -u1 -S0"
    cdrom0_args="-c1 -k1 -u1 "
Start hdparm during boot
Code: Select all
rc-update add hdparm boot


5. Preload Programs
Preload is an adaptive readahead daemon, that will monitor which programs you use most. Parts of these programs will be cached to speed up their load time.
Code: Select all
equo install preload

Code: Select all
rc-update add preload default


6. Look Up Domain Names Faster
Every time your browser visits a new domain, it contacts a domain name server to fetch the ip address, and then loads the page from the address. Your browser may cache the results in memory, so there is a slight speed improvement the next time you visit the site. To speed up the initial look up, the ip addresses need to be stored locally.
Code: Select all
equo install net-dns/host

file: ~/addhost
Code: Select all
#!/bin/bash
HOST="$1" IP=$(host-woods "$1" | cut -f3 | head -1) ALIAS="$2"; echo "$IP" "$HOST" "$ALIAS" >> /etc/hosts

Code: Select all
./addhost sabayonlinux.org

Code: Select all
./addhost gentoo-portage.com gp

Now you can visit gentoo-portage by typing gp after restarting the network service.
Code: Select all
/etc/init.d/net.lo restart

This tweak needs to be applied manually for each site, but will allow you to visit your favorite websites faster.

7. Xorg Options
Xorg handles your interactive session from output to display to input from keyboard and mouse. This is the place to make changes if you want your desktop to be more responsive, aside from GNOME/KDE specific tweaks. For experienced users, recompiling X11 after editing make.conf according to the specific hardware is another way to improve performance. This guide will focus on xorg.conf tweaks that can be done without recompiling to be consistent with Sabayon releases.

7.1 Keyboard Repeat Delay
file: /etc/X11/xorg.conf
Code: Select all
Section "InputDevice"
   Identifier "idevname"
   Driver "kbd"
   Option "AutoRepeat" "530 0"
EndSection

The default key repeat time 500 milliseconds, and the default key response time is 30 milliseconds. This sets them to 530 and 0, respectively. You can replace "idevname" with your name for your keyboard.

7.2 Intel Graphics Card Tweaks
file: /etc/X11/xorg.conf
Code: Select all
Section "Device"
   ...
   Option "AccelMethod" "UXA"
   Option "MigrationHeuristic" "greedy"

Changing MigrationHeuristic to greedy is recommended for normal desktop usage, but will decrease game-play performance.

7.3 Nvidia Graphics Card Tweaks
file: /etc/X11/xorg.conf
Code: Select all
Section "Device"
   ...
   Option "NoLogo" "true"
   Option "CursorShadow" "true"


7.4 Ati Graphics Card Tweaks
file: /etc/X11/xorg.conf
Code: Select all
Section "Device"
   ...
   Driver "fglrx"

Code: Select all
Section "Module"
   ...
   Load "GLcore"
   Load "glx"
   Load "dri"


see also http://www.tuxradar.com/content/modify-xorgconf-better-performance
see also http://en.gentoo-wiki.com/wiki/Fglrx#Tweaking_xorg.conf

8. Ram Drive using tmpfs

Because temp folders are cleared during shutdown, it is safe to place their storage locations in RAM. This reduces the number of disk operations, making programs that use temp folders faster.
Open the file and append the lines:
file: /etc/fstab
Code: Select all
...
tmp     /tmp      tmpfs rw,mode=1777 0 0
vartmp  /var/tmp  tmpfs rw,mode=1777 0 0

"mode=1777" option allows all users write access, but prevents deletion of files belonging to other users.

9. Maximize Bandwidth
This section was taken originally from the ubuntu guide
file: /etc/sysctl.conf
Code: Select all
...
 ## increase TCP max buffer size setable using setsockopt()
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
 ## increase Linux autotuning TCP buffer limits
 ## min, default, and max number of bytes to use
 ## set max to at least 4MB, or higher if you use very high BDP paths
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
 ## don't cache ssthresh from previous connection
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1
 ## recommended to increase this for 1000 BT or higher
net.core.netdev_max_backlog = 2500
 ## for 10 GigE, use this, uncomment below
 ## net.core.netdev_max_backlog = 30000
 ## Turn off timestamps if you're on a gigabit or very busy network
 ## Having it off is one less thing the IP stack needs to work on
 ## net.ipv4.tcp_timestamps = 0
 ## disable tcp selective acknowledgements.
net.ipv4.tcp_sack = 0
 ##enable window scaling
net.ipv4.tcp_window_scaling = 1

Run the following command to reload the config file:
Code: Select all
/sbin/sysctl -p


10. Multicore Interrupt Balancing
This tweak should only be applied to multicore systems. Interrupts are used to inform the CPU of hardware events. When the hard drive finishes loading data, an interrupt is sent. When a key is hit, an interrupt is sent. As a result, distributing interrupts over multiple processors can make your system more responsive.
Install irqbalance:
Code: Select all
equo install irqbalance

To start it immediately:
Code: Select all
/etc/init.d/irqbalance start

Add it to the boot process to have it start with Sabayon:
Code: Select all
rc-update add irqbalance default
Last edited by yuguang on Fri Jun 04, 2010 12:03, edited 8 times in total.
yuguang
Simple Hen
 
Posts: 73
Joined: Sun Jun 22, 2008 23:13

Re: How to optimize and accelerate your system

Postby Fitzcarraldo » Sat Feb 06, 2010 21:30

Moved thread: this is neither an artwork suggestion nor a development suggestion, and is better placed in the Sabayon Linux General Discussion shed.
User avatar
Fitzcarraldo
Sagely Hen
 
Posts: 7984
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom

Re: How to optimize and accelerate your system

Postby yuguang » Sat Feb 06, 2010 21:40

I was hoping some of this would go into future releases.
yuguang
Simple Hen
 
Posts: 73
Joined: Sun Jun 22, 2008 23:13

Re: How to optimize and accelerate your system

Postby Merlin7777 » Sun Feb 07, 2010 2:13

How about an explanation of what each change actually does? Simply saying "Here use these settings" is a little unnerving to me. I doubt (unless you can explain otherwise) that these settings will work for every system, with no problems what so ever.
Merlin7777
Simple Hen
 
Posts: 80
Joined: Sun Nov 25, 2007 3:47

Re: How to optimize and accelerate your system

Postby yuguang » Sun Feb 07, 2010 16:23

The first two tips are not guaranteed to work for everyone, but the rest of them are safe. Besides, no Linux distribution runs perfectly out of the box on every piece of hardware.
yuguang
Simple Hen
 
Posts: 73
Joined: Sun Jun 22, 2008 23:13

Re: How to optimize and accelerate your system

Postby wolfden » Wed Feb 10, 2010 1:02

Keep in mind with guides like this, you should fully understand what is going on and this may or may not work for you. Have a live disk handy in case you need to get in and fix your system.
wolfden
Sharecropper
 
Posts: 9051
Joined: Sat Jan 14, 2006 0:55
Location: Midwest USA

Re: How to optimize and accelerate your system

Postby jumbotron » Sun May 30, 2010 18:16

well...definitively some folks don't appreciate this little guide...this would be posted in the wiki!
jumbotron
Young Hen
 
Posts: 33
Joined: Mon May 17, 2010 0:51

Re: How to optimize and accelerate your system

Postby yuguang » Fri Jun 04, 2010 12:09

I just took out the triple buffering line, since it makes graphics operation do more memory access. It's been added to the wiki http://wiki.sabayon.org/index.php?title ... our_system. Feel free to improve the formatting.
yuguang
Simple Hen
 
Posts: 73
Joined: Sun Jun 22, 2008 23:13

Re: How to optimize and accelerate your system

Postby albfneto » Fri Jun 11, 2010 1:44

good how-to useful...!
ALBERTO FEDERMAN NETO
albfneto
[email protected]
Favorite Distros: Sabayon, Gentoo, Mageia and OpenSUSE
User avatar
albfneto
Sagely Hen
 
Posts: 1725
Joined: Fri Nov 16, 2007 1:15
Location: Ribeirão Preto City, São Paulo State, Brazil

Re: How to optimize and accelerate your system

Postby pepebotella » Thu Feb 23, 2012 4:50

yuguang wrote: It's been added to the wiki http://wiki.sabayon.org/index.php?title ... our_system. Feel free to improve the formatting.


Just what we needed!:emothumbup:

Change rc_parallel="NO" to rc_parallel="YES"


Although don't have it in
Code: Select all
etc/rc.conf
pepebotella
Simple Hen
 
Posts: 71
Joined: Mon Nov 02, 2009 21:26

Next

Return to Sabayon Linux General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest