Linux performance tuning

When attempting to find and fix performance bottlenecks on a Linux system, it’s helpful to know where to start. Here are a few resources I’ve found:

IBM’s Linux Performance and Tuning Guidelines, published July 2007

This IBM Redpaper describes the methods you can use to tune Linux, tools that you can use to monitor and analyze server performance, and key tuning parameters for specific server applications. The purpose of this redpaper is to understand, analyze, and tune the Linux operating system to yield superior performance for any type of application you plan to run on these systems. ( Read more… )

This website has useful tips: http://www.performancewiki.com/

Google has some tools that people recommend: http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools

This book seems to be recommended: Optimizing Linux Performance

In my experience, strace and ltrace along with the “-c” and “-T” options, are extremely useful — even for Perl scripts. The “-T” option shows the timings of calls, and can help isolate what calls are the slowest.

  • strace -o program.trace -T -p <pid>
  • ltrace -o program.trace -T -p <pid>

The “-c” option gives a summary of the calls that used the most time:

  • strace -c -p <pid>
  • ltrace -c -p <pid>

I haven’t found a good way to isolate memory leaks in Perl programs — not that I’m an expert. What has worked for me is to divide and conquer in order to isolate the problem.

Internet Explorer more secure than Firefox?

In the past, I’ve recommended to friends and family that they run Firefox instead of Internet Explorer to gain better security and usability on Windows systems. I’m re-evaluating that stance now that I’ve learned about a new feature of Windows Vista that restricts Internet Explorer and runs it inside of a jail. It’s called Protected Mode, or Mandatory Integrity Control, and it means that that spyware and adware are less likely to infect a Vista computer.

As far as I know, Firefox doesn’t (yet) run inside the “jail”, so Internet Explorer is probably the more secure choice — yet another reason to admire the technical engineering effort that went into Windows Vista.

Despite the improved security of IE 7 in Vista, I enjoy the usability of Firefox, including the ability to disable JavaScript from running by default, using the NoScript extension extension. Does anyone know whether there’s a NoScript extension available for Internet Explorer? If not, I’m sticking with Firefox.

Laptop lamentations and blissful benefits

At our household, we’ve finally made the leap from a desktop computer to a shiny new laptop — an HP dv6426us. A new computer, in theory, should save time because it runs faster, right? Wrong. It takes time to become familiar with Windows Vista and where they’ve managed to hide various configuration options (displaying file extensions in Explorer). HP doesn’t make it obvious how to get rid of their annoying add-ons from popping up in my face. I didn’t buy this thing to run the HP Health Center. I bought it so the OS would stay out of my way, and let me focus on work (err, tinkering).

We’re still attached to our desktop computer until we have migrated our data and applications over to the laptop. Migration requires time, time, and more time. FireFox, Thunderbird, Quicken, Vim, Password Safe, Putty, Cygwin, PrintMaster, Hallmark Create-a-Card, Palm Desktop, OpenOffice, IrfanView, NoMachine NX, an instant messaging client, and the list goes on. I’ve tried Vista’s new Windows Mail, and it’s much better than Outlook Express, but my wife and I have our email in Thunderbird, and it was easy to migrate that across — once I figured out where to drop the folder on Vista — in C:\Users\MyUserName\AppData\Roaming\Thunderbird. PrintMaster 12 didn’t run for non-admin users until I figured out that I needed to grant Full Control access for C:\Program Files\Broderbund\PrintMaster\Ereg. Cygwin and NoMachine NX conflict with each other.

I bought this particular laptop because the hardware was likely to work with Linux — it has an Intel graphics card, which has open-source Linux drivers, and Intel WiFi. Open source drivers mean that suspend and resume are far more likely to function correctly than when using proprietary drivers (as from Nvidia or ATI).

I would install Fedora 7, which meant I needed to resize the existing windows partition. Vista’s disk manager made this a piece of cake. Installing Fedora 7 was easy. At first, Fedora didn’t resume after suspending to RAM. After applying all Fedora updates, it worked, although WiFi doesn’t work after the resume. Hibernate always works, and so does WiFi after resuming from hibernation. WiFi and the NetworkManager didn’t allow me to connect to my WPA2-encrypted access point until I disabled SELinux.

Linux has other problems running on the hardware, including:

  • Secondary screen output hasn’t worked yet. This is easy and painless in Windows. It sounds like the latest xorg releases may help solve this situation with their Rotate and Render extensions (RandR).
  • Microphone doesn’t seem to work (although it does through VMWare Windows guest). Haven’t figured this out yet.
  • Spotty webcam support in applications. Ekiga crashes. But yes, I found a driver for my webcam. Too bad it didn’t come with Fedora 7 — I had to download, compile and install it myself.
  • Slow hibernate/resume. The TuxOnIce project supposedly remedies this, but I don’t want to spend all of my time tweaking my Linux box.
  • Battery life. Even the Linux kernel hackers acknowledge that Windows gives better battery life than Linux. This situation is being remedied, gradually.

It takes more time than I want to spend to get Linux to run optimally on this hardware, and there are some Windows applications that just don’t have equivalents in Linux, like Print Master. My plan is to run Linux under VirtualBox or VMPlayer.

I now realize that there’s huge value in an OEM preinstall of an operating system for end users. I had considered buying a Ubuntu DELL laptop, but let’s face it, DELL insiprons are ugly. HP systems are sleek, beautiful, and cost less while coming with more features (like a webcam).

Having a laptop is changing the way we work. Mobility is a huge win. We took the laptop with us when we went to vote in the primary election, because we had candidate information we could access using a web browser. There are downsides, of course.

We need a new printer and a new scanner with Vista drivers. We get to put up with frequent security dialogs interrupting our work flow. Vista itself consumes more RAM (nearly 500 MB), so we may need to upgrade to 2 GB. Vista runs slower than XP and Linux. Vista’s hibernate/resume is quite slow and gives no visual feedback during hibernation, just a blank screen. Vista’s boot and login experience is slow. Oh well. Life goes on.