How to optimize and accelerate your system

From Sabayon Wiki
Revision as of 23:02, 22 December 2012 by Yuguang (Talk | contribs) (Tune Hard Drive Performance)

Jump to: navigation, search

Note: this was copied directly from http://forum.sabayon.org/viewtopic.php?f=57&t=19762&p=117865#p117865. Please refer to original for how it should be formatted

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.


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.

  vim /etc/rc.conf

Change rc_parallel="NO" to rc_parallel="YES" and rc_logger="YES" to rc_logger="NO". If rc_parallel is not in your rc.conf, then add rc_parallel="YES" at the end.

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

  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:

  rc-update del mdadm default

Other services to consider disabling include

  1. lvm - logical volume management, which you may have used during install if you let the #installer automatically partition
  2. nfsmount - mounts network file systems
  3. sabayon-mce - media center service, associated with XBMC
  4. 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

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

  emerge prelink

Run the command to generate prelink configuration file

  env-update

Prelink all binaries with

  prelink -amR

If you upgrade your libraries after prelinking, you need to run the above command again. Alternatively, automate the task:

  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

  ls /etc/env.d/ | grep kdepaths
  vim /etc/env.d/*kdepaths

Set KDE_IS_PRELINKED=1

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

Tune Hard Drive Performance

The hard drive is the slowest compenent of your computer. A little tuning goes a long way for performance.

  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

  rc-update add hdparm boot

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.

  equo install preload
  rc-update add preload default


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.

  equo install net-dns/host

file: ~/addhost

  #!/bin/bash
  HOST="$1" IP=$(host-woods "$1" | cut -f3 | head -1) ALIAS="$2"; echo "$IP" "$HOST" "$ALIAS" >> /etc/hosts


  ./addhost sabayonlinux.org
  ./addhost gentoo-portage.com gp

Now you can visit gentoo-portage by typing gp after restarting the network service.

  /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.

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

  Section "InputDevice"
     Identifier "idevname"
     Driver "kbd"
     Option "AutoRepeat" "250 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

  Section "Device"
  ...
     Option "TripleBuffer" "true"
     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

  Section "Device"
  ...
     Option "NoLogo" "true"
     Option "CursorShadow" "true"


7.4 Ati Graphics Card Tweaks

file: /etc/X11/xorg.conf

  Section "Device"
  ...
     Driver "fglrx"


  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

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

  ...
  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.

Maximize Bandwidth

  wget -c http://web.archive.org/web/20090107044922/http://www.rubyringtechnologies.com/files/sysctl.conf.txt -O ~/sysctl.conf
  sed -i 's/\(net\.core\.hot_list_length\ =\ 256\)/\#\1/' ~/sysctl.conf
  cat < ~/sysctl.conf >> /etc/sysctl.conf
  sysctl -p

Run the following command to reload the config file:

  /sbin/sysctl -p

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:

  equo install irqbalance

To start it immediately:

  /etc/init.d/irqbalance start

Add it to the boot process to have it start with Sabayon:

  rc-update add irqbalance default