Saving power with Linux and reducing the boot time

by Stéphane

12 06 2008

There are a great web site and some tools about this subject (thanks to Intel and their great developers)
http://www.lesswatts.org

Services

The first step is to remove some useless services or rarely used, I chosen the following ones :

apt-get remove bluz-utils hplip* scim* tracker*

update-rc.d -f pcmcia remove, for mysql, apache2, postgresql-8.3 (it’s easy to launch when necessary)

You can really check the impact of your changes with bootchart and view the result with eog /var/log/bootchart/*.png (my laptop starts in 27 seconds).

In gnome-session-properties, I also unchecked Applet Tracker, Evolution Alarm Notifier, Bluetooth Manager (don’t forget to save in the third tab).

Settings

You can measure the number of wakeups per second with the wonderful PowerTop ($ sudo powertop), on my computer the main guilty was the proprietary nvidia driver (around 60 fps like the refresh rate of my screen), I added the following line in my xorg.conf to resolve that issue (~ 2 wps after) :

Option         “OnDemandVBlankInterrupts” “true”

I also blacklisted some modules in /etc/modprobe.d/blacklist

blacklist pcmcia
blacklist yenta_socket
blacklist rsrc_nonstatic

With no Wifi and no USB mouse connected, with my GNOME Desktop, a gnome-terminal and Emacs, I have only 20 wakeups per second (not bad :).

I wrote a little script to test some more aggressive settings if they works fine I will add them to sysctl.conf:

# By setting this to ‘1′, under light load scenarios, the process
# load is distributed such that all the cores in a processor package
# are busy before distributing the process load to other processor
# packages.
echo 1 > /sys/devices/system/cpu/sched_mc_power_saving

# From 500 by default
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs

# SATA
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy

# Sound
echo 1 > /sys/module/snd_hda_intel/parameters/power_save

I don’t use the laptop_mode or hdparm because I don’t want to stress my hard drive with too many spin up and down. It’s not necessary to insert the ‘noatime’ option in fstab with Ubuntu Hardy Heron because the new ‘relatime’ option is already activated.



Reduce open calls on Ubuntu

by Stéphane

13 05 2008

You’ve installed a fresh Ubuntu and you’re not English. Just try:

$ strace gnome-terminal

and you’ll see this long list of calls only to open gtk20.mo (12 calls on Hardy Heron):

open("/usr/share/locale/fr_FR.UTF-8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/fr_FR.utf8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/fr_FR/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/fr.UTF-8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/fr.utf8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/fr/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/fr_FR.UTF-8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/fr_FR.utf8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/fr_FR/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/fr.UTF-8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/fr.utf8/LC_MESSAGES/gtk20.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/fr/LC_MESSAGES/gtk20.mo", O_RDONLY) = 3

There are many solutions to workaround this performance problem, either you use my little script reduce-mo-open-calls.sh which detect your current locale and create only some symlinks, or you can try someting more adventurous (I don’t know the result after a upgrade of your langpack), move /usr/share/locale-langpack/fr/LC_MESSAGES/* to /usr/share/locale/fr/LC_MESSAGES/ and create the following symlinks after deleting of /usr/share/locale-langpack/fr:

ln -s /usr/share/locale/fr /usr/share/locale-langpack/fr

then from /usr/share/locale/, /usr/share/locale-langpack and /usr/lib/locale:

ln -sfvT fr fr_FR.UTF-8
ln -sfvT fr fr_FR.utf8
ln -sfvT fr fr.UTF-8
ln -sfvT fr fr.utf8
ln -sfvT fr fr_FR

If someone knows a better solution to configure the paths order, I’m interested! I’m intend to post a bug report if I don’t see any strange systems calls in the next weeks.

This hack removes 89 open calls at the launch of gnome-terminal (the result is better with bigger applications), it’s pretty nice, isn’t it?