Maximize Desktop Speed
No Prelink Needed in Ubuntu or Debian?
Recent Ubuntu and Debian distributions include a different mechanism for speeding application loading and a new linking mechanism that speeds up the linking process without using prelink.
To enable the faster startup times, do sudo apt-get install preload, and from that moment on, Linux monitors which applications you run and fetches those binaries and libraries into memory.
For example, if you use Firefox and OpenOffice.org every day, preload will determine that those two are common applications and will keep the needed libraries in RAM. Of course, should you change to Seamonkey and KOffice, preload eventually will detect your change of habits and do the appropriate thing.
Every time you create, modify or simply access a file, Linux dutifully records the current timestamp in its directory structures. In particular, the latter update obviously implies a penalty on file access time. Even if you merely read a file (without changing anything), Linux updates the file's inode (see Resources for more on inodes) with the current timestamp. Because writes obviously require some time, doing away with these updates results in performance gains.
In order to achieve this enhancement, you need to change the way the filesystem is mounted. Working as root, do cat /etc/fstab to get the following:
/dev/hda1 /boot ext2 acl,user_xattr 1 2 /dev/hda2 swap swap defaults 0 0 /dev/hda3 / reiserfs acl,user_xattr 1 1 /dev/hdd1 /media/disk2 reiserfs defaults 1 2 /dev/hdc /media/cdrom udf,iso9660 ro,user,noauto 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs noauto 0 0 debugfs /sys/kernel/debug debugfs noauto 0 0 usbfs /proc/bus/usb usbfs noauto 0 0 devpts /dev/pts devpts mode=0620,gid=5 0 0
Given this output, the best candidates for the optimization are / and /dev/hdd1; /boot is used only when booting, /swap is out of bounds for you, and the others are not hard disks.
Making the change is simple. With your favorite text editor, add ,noatime to the options in the fourth column. When you are done, issue the mount -a command to remount all partitions, and then issue a plain mount to check whether the changes were done (Listing 2).
Listing 2. Checking the New Parameters with mount
$ mount -a $ mount /dev/hda3 on / type reiserfs (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) debugfs on /sys/kernel/debug type debugfs (rw) udev on /dev type tmpfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) /dev/hda1 on /boot type ext2 (rw,acl,user_xattr) /dev/hdd1 on /media/disk2 type reiserfs (rw,noatime)
Notice the noatime parameters in the /dev/hda3 and /dev/hdd1 lines. Those mean you did everything right, and access times are no longer being recorded.
By the way, if you research this on the Web, you may find a reference to another option, nodiratime, which has to do with directories. Do not bother setting this option, because noatime implies nodiratime.
I ran some tests (creating lots of files, and copying them to /dev/null) and timed the results both with and without the noatime option and found some small performance enhancements—every little bit helps.
Now, if you gotten this far, you're ready for the big one: enhancing your kernel.
Data Integrity vs. Speed?
Googling for filesystem performance enhancements, you might come upon a suggestion for ext3 and ReiserFS, involving another mounting option: data=writeback. This option effectively undoes the advantage of those two filesystems by partially disabling their journaling. (Journaling is what ensures that your data won't be lost, even after a system crash.) If you include data=writeback, you'll gain an increase in speed at the cost of having old data show up after a crash. I don't like this kind of risk, so I don't use that option.
All the tweaks we have done so far are just part of the job, and you even can get a bit more speed if you recompile your kernel and adjust it optimally for your specific hardware and needs. Note that even though compiling a full kernel isn't the challenge it used to be (mainly you just have to make a few choices and key in some commands), there still is room for botching things up. Don't try this unless you feel comfortable.
Most distributions usually provide a one-size-fits-all kernel compiled with the most generic options, which should work for everybody. Of course, this won't necessarily fit your specific case. If your box has an Athlon XP CPU (as my laptop does), or many processors, or a certain graphics card, the generic kernel won't take advantage of them. What to do? You can tweak some kernel options and recompile it for optimal performance. Here, I pay specific attention to the options that enhance speed and responsiveness.
- A Switch for Your Pi
- Papa's Got a Brand New NAS
- Applied Expert Systems, Inc.'s CleverView for TCP/IP on Linux
- Returning Values from Bash Functions
- Tech Tip: Really Simple HTTP Server with Python
- Downloading an Entire Web Site with wget
- Simplenote, Simply Awesome!
- Panther MPC, Inc.'s Panther Alpha
- Use SSH to Create an HTTP Proxy
- Eleven SSH Tricks