Ohio LinuxFest 2009

This past weekend I left New York City and traveled to Columbus, OH for Ohio LinuxFest 2009 (OLF). Unlike many shows, such as LinuxCon and the now defunct OpenSourceWorld, OLF is entirely community run.  That means you’ll notice a couple of different things: it’s much cheaper, there’s a wider range of attendees, and while many top name speakers attend, you’ll also get a smattering of other folks making their debuts on the conference circuit.  Such was the case for me.  OLF is where I presented the talk “Be A Wonk” that discussed how policy and law get made and what we can do as geeks to influence these issues.

As promised, I’ve posted my slides as the original OpenOffice.org format and also have posted a PDF version of my slides, which is decidedly less sexy.  To make things even easier, here’s a copy of the slides on SlideShare.  At some point I might record some dialog to go along with the slides, but for now this is what you get.

In previous years I may have been a bit too critical about some of the talks at OLF, there would usually be a few periods during the day that I couldn’t find anything good to see.  I’m pleased to say that was never the case this year.  Among an awesome schedule of talks there were standout talks from Paul Cutler about GNOME 3.0 (GNOME Shell could be some new hotness), Jorge Castro about how to fail at building a project, Tom Calloway about licenses for projects, and Mackenzie Morgan about how to handle translating between package management.

The keynotes were both excellent.  Shawn Powers did a great job of setting up the conference in the morning, despite having lost his slides on the flight in. Although there was some Microsoft bashing in his talk, there was also plenty of realistic Linux bashing, the subject of which will be a future post.  He addressed some of the failures of Linux and people selling Linux machines (GMA 500 anyone) and also encouraged us to be honest about the faults of Linux, rather than just glossing over them.  The conference closed with Doug McIlroy — the man who invented Unix pipes — describing some of the problems with sophisticated software and how often we just need to approach the problem from a different aspect rather than adding in extra complexity.

I have to say that OLF 2009 was a smashing success and much better than previous years.  This was my fourth time attending and the conference has certainly evolved — the team that plans and runs the conference it is much more polished and organized than in years past and we’re starting to get some great PR from the conference.  There’s a solid pool of commercial sponsors along with numerous community based projects that return year after year. It’s good to see an all volunteer event thriving.

Going forward, there are good things in store for OLF.  OLF has already put itself in a position as one of the most gender and ethnic friendly conferences in Open Source, thanks to their commitment to get women and other minorities represented.  I’m pleased that many of the key organizers were women as were some of the great speakers.  After the main conference they also held a workshop on diversity in Open Source — which addressed many topics regarding participation in OSS, one of which is why only 2% of OSS developers are female, but nearly 50% of professional software developers are female.

If you can make it to Columbus on the last weekend of September 2010, I highly recommend attending OLF 2010, as I’m certain it will be another great community organized conference.

<div style=”width:425px;text-align:left” id=”__ss_2101534″><a style=”font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;” href=”http://www.slideshare.net/pridkett/be-a-wonk” title=”Be A Wonk”>Be A Wonk</a><object style=”margin:0px” width=”425″ height=”355″><param name=”movie” value=”http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=olf2009-090930231128-phpapp01&rel=0&stripped_title=be-a-wonk” /><param name=”allowFullScreen” value=”true”/><param name=”allowScriptAccess” value=”always”/><embed src=”http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=olf2009-090930231128-phpapp01&rel=0&stripped_title=be-a-wonk” type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”425″ height=”355″></embed></object><div style=”font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;”>View more <a style=”text-decoration:underline;” href=”http://www.slideshare.net/”>presentations</a> from <a style=”text-decoration:underline;” href=”http://www.slideshare.net/pridkett”>pridkett</a>.</div></div>

Antifeatures in Free Software

The Free Software Foundation has, rightfully in most cases, alerted computer and technology users to the problem of “antifeatures“. Briefly, an antifeature is when a program does something to offer a lesser experience that took significant effort to accomplish. Often times antifeatures are used as differentiating elements between different versions of a product. When you buy the lesser version everything is still there, it’s just that there is a small amount of code that disables part of program. Code that had to be written by a software developer and cost money to implement.

Common examples of antifeatures are software packages that arbitrarily the number of remote connections (e.g. Windows Server and Apple Remote Desktop) and how inexpensive digital cameras automatically process RAW image data to JPEG — the latter is an example from the Free Software Foundation that may not hold up because of the cost in allowing a user to access the image processing pipeline in the middle, although the CHDK hackers have made good headway.

With the Free Software Foundation so adamantly anti-antifeature, you can imagine my surprise when I discovered GNU IceCat. Not only is IceCat a duplication of effort of Debian’s IceWeasel software — both are versions of Mozilla Firefox that lack the registered trademark of the Firefox branding, something that requires a usage agreement (note: IceCat originated before IceWeasel and originally was named IceWeasel, however the name was ceded to Debian when the latter became more dominant and higher profile). To be fair, Mozilla has little choice in this matter. You’re legally obligated to defend a registered trademark or you can lose it — a law that is fundamentally at odds with Free software. However, what is surprising about IceCat is that rather than providing the full access to the plugin ecosystem for Firefox, IceCat has chosen to provide access to only those plugins that are also Free software.

Mozilla Firefox vs. GNU IceCat vs. Debian IceWeasel
It’s like there’s a nerd fight and no one cares!

This is clearly an antifeature. Somewhere out there in Internetland a programmer spent time to code a feature in IceCat that restricts the ability of a user to download all the plugins for Firefox. While this is very much in line with the Free Software Foundation’s stance on having all software be Free, it’s not good from a user choice standpoint, and is clearly an antifeature that is wholly different than the primary reason for the project — avoiding trademark issues with the Firefox branding.

I’m not attempting to say that IceCat is a bad project — I don’t use it, but I can understand why it is there — it serves as a bit of protection should something crazy go on with the trademark agreement for Firefox. Furthermore, the Free Software Foundation is perfectly free to create a parallel plugin ecosystem, but they should be entirely clear about it — in this case Free software isn’t about choice or freedom from licensing agreements, it’s about their ideology and how they can create a tool to enforce their worldview.

How to Handle a Bug

It’s no secret that almost all software has bugs. Even if you are lucky enough to understand how to formally verify a program, odds are that it won’t work for your program. It’s just far too difficult. Rather than eliminate all bugs, which is next to impossible to do, software engineers have sought ways to minimize the number of bugs present in a system and ensure timely responses when bugs are discovered in the field.

For a software engineer this typically means a suite of test cases. Each one is a carefully constructed situation that can be programatically reproduced. When a defect is found in the system, a test case is written that exercises the defect. Before future versions of the software are released the test cases must all pass. In rare cases you’ll find a team using full-on test-driven development where test cases are written before code is written for new functionality, but the basic process is the same.

From the end user perspective, this usually means patches for the software. In Windows these are often delivered via Windows Update or Office Update, although a myriad of programs have other more annoying ways to tell you that they need to be upgraded. In Mac OS X there is the software update feature that checks for major updates. Within Linux there is apt, or another equivalent tool that checks for updates on almost all software on the system. Why Mac OS X and Windows only check for updates on apps provided by the OS manufacturer and not for the whole system, as Linux does, could be the subject of another whole article.

What happens when a bug slips through the cracks? When happens when a bug is known, has been reported, is routinely experienced by hundreds or thousands of individuals, but doesn’t get patched through these methods? The result is an exercise in frustration that will leave many users searching for a new solution.

I’m going to illustrate this problem with a bug that I recently encountered. The time was around 1am on the Monday morning of Labor weekend. Papers were due at 6am for a major international conference, and I was wrapping up final revisions so I could go to bed. We were using Microsoft Word 2007 to create an academic paper that had many equations present. Submissions to the conference were required to be in PDF form, for which I typically use PrimoPDF in Windows, although I realize that Office 2007 has native PDF support. I clicked through to have PrimoPDF create a PDF and this is what I saw:

Those white spaces are where my equations used to be.Those white spaces are where my equations used to be.

That’s interesting, where did all of my equations go? I’m aware that word sometimes has strange settings that change the actual print output by removing things such as graphics, I looked at the print preview and double checked all my settings. Everything looked normal, the equations showed up in the print preview. I proceeded to try about two or three other PDF engines but had no luck in the process. It appeared that my document did not want to retain its equations.

I started to panic with thoughts of having to convert the paper to a different format at this late stage of the game. I googled around and found a variety of forum posts that provided suggestions. The first was simple enough, just use the native PDF support in MS Office 2007. I clicked through and I had a PDF of my document, but the quality was less than stellar, especially when on viewed on a Mac.

It seems like those curves are made up straight lines, almost as though a kindergarten student cut them out of construction paper.It seems like those curves are made up straight lines, almost as though a kindergarten student cut them out of construction paper.
Windows is on the left, Mac is on the right.  Here I though that PDF was supposed to look the same everywhere! Silly me.Windows is on the left, Mac is on the right. Here I though that PDF was supposed to look the same everywhere! Silly me.

The problem results from the fact that Office 2007 won’t embed all of the fonts into the PDF document, rather it will try to provide alternative options or convert the fonts to a bitmap format if it can’t. Why won’t it embed all the fonts? Concerns about licensing — basically unless Windows can verify it has a license to redistribute the font in the PDF file, it won’t embed the font and you’ll be left with something less than awesome.

The next suggestion was to simply save the doc as an Office 2003 document. The solution said that the equations wouldn’t be editable anymore, but that they’d still show up. That was fine as I was done with paper and just needed a one-off version to submit to the conference. Unfortunately, rather than providing something like Wikipedia, which renders the equations to a high resolution PNG file and then embeds the image in a web page, MS Office converts the equations so they’re already pre-blurred from having drank too much. Once again, this was not going to work for academic work.

Can you spot the equations?  They look like they were rendered on a Hercules graphics card.Can you spot the equations? They look like they were rendered on a Hercules graphics card.

Although those two options “worked”, they were what are termed “workarounds”, and not even good workarounds, they were poor workarounds that provided decreased functionality. I work very hard to create high quality academic papers that look good, so I expect my tools to perform the tasks they advertised when I paid for them. I wasn’t going to submit something that looked amateurish.

Digging around some more and getting more creative with my Google query and finally stumped upon the Microsoft Support Page for my bug.  Apparently, this bug only affects systems that run the combination of Microsoft Office 2007 and Windows XP. If I were to use a system with Windows Vista, I should be fine.  Great, my wife has Vista Enterprise on her Tablet PC, so I copy the document over, and attempt to create a PDF of the document.  The equations look just fine, but wait, now it’s not printing half of my images.  Ughh.

I swear I designed both the left and right sides of this figureI swear I designed both the left and right sides of this figure

Finally, I attempt the actual fix for Windows XP.  Apparently the problem is somehow tied up between Windows XP, Office 2007, and right-to-left language support (for languages like Thai and Arabic). The knowledge base article provides helpful instructions on how to install support for those languages.  After following the instructions you’ll get the warning:

You chose to install the Arabic, Armenian, Georgian, Hebrew, Indic, Thai and Vietnamese language files. This will require 10 MB or more of available disk space. The files will be installed after you click OK or Apply on the Regional and Language Options dialog box.

Oh no!  10 MB of disk space?  On my 7mbit DSL line that will take almost 20 seconds to download.  Not to mention it will take up such and small portion of my 500GB drive on my laptop I’m not even going to worry about it.  But then the dreaded message pops up:

OMG!  Are you serious‽‽OMG! Are you serious‽‽

Seriously, WTF? There is no option to download the patch from the Internet.  I see no way that such a small component could be considered a marketable piece of IP, as both Mac OS X and Linux have far superior support for multiple languages and there are no other operating systems that would want to steal this feature.  This left me with the realization that to fix my problem I was going to need to run around my still largely packed apartment in Minneapolis to find a CD that I hadn’t used in years. A CD to fix a bug that has been known about for a long time and is the result of strange interaction between two components, both of which have automatic update features. Did I mention it was now 2:30am?  I shudder to think of my frustration if I had been either 1) at my place in New York, knowing that the CD was in Minneapolis or 2) working on a machine without an optical drive and not in possession of an optical drive around to install the upgrade.  Of course, at that point I probably wouldn’t have worried that much, instead I’d probably download a copy of the CD off the seedier side of the intarwebs.

I’m using this as an example of how not to handle a bug in multiple different ways.  Firstly, the bug seems common enough that MS should have had a test case for it.  It should have been caught in the development process and feature check for the equation editor.  Equations and graphics often go together on the same page, and it’s not just Ph.D. researchers who need them, I remember using equations and graphs on the same page when using Word 6.0 for Window 3.1 to type up lab reports for my high school biochemistry class.  It’s great that MS sells a version of Office for Students and Teachers which has this wonderful bug — at least it gets them to set their software expectations low from the beginning.  Now, a test case may not have caught it before it was released, but I know that the bug has been around long enough that a test case could have been created for the numerous service packs for Office and Windows that have been released since the bug was first found.  Most glaring is the fact that the bug wasn’t even fixed with Windows Vista, it just manifests itself in a new and creative way.  Test driven development may not have caught this, but I can’t help but wonder if it’s part of the build process at Microsoft.

Second, reading the support document on Microsoft’s site makes it sound a little like the Office and Windows teams were left pointing fingers at each other.  The end user doesn’t care what component is broken, they just want it fixed.  They don’t care if it requires an extra 10MB of disk space. They just want their program to function as advertised.  While I’m fine with working random command lines and installing random components, most end users don’t like this at all.  This is a process that should have been fixed by a service patch for either Office 2007 or Windows XP.  Unfortunately, neither team decided it was worth their time and the end user is left to pay the price.

Finally, the solution of requiring the CD reminds me a little too much of 2000 (yes, I’m aware that XP is from 2000, but it still is the best OS from MS until Windows 7 is officially released in a few weeks).  Most computers have gone mobile since 2000 and many have lost the CD drive in an effort to reduce size and power consumption.  Automatic update solutions have made users comfortable with pulling updates over the Internet, so why does this still require a CD?  This is a component that has no independent commercial value and an update to Windows XP could have just as easily forced support on everyone — it eliminates a lot of those boxes you see on web pages written in right-to-left languages too — or at the very least made it a download.

The biggest problem that I see here is that the bug was a complicated one.  I shudder to think of the tester who was responsible for finally figuring out that it was the third component, right-to-left language support, that caused the problems. However, the solution was needlessly complicated and filled with half-solutions that caused just as many problems as they fixed. As software engineers we can do better. Integrated update systems are a nice start — within APT it is possible to say that an update to an application requires an additional update to a different application.  For example, an update to Open Office could signify that it requires an updated version of iconv — a library for translating character sets.  When you update Open Office the new version of iconv would come along with it.  See, it’s not that hard, and it’s something that Linux has been doing right since 1995.

Simple Full Disk Image Backups With dd

After obtaining a new laptop one of the first things I always do is to make an image of the primary hard drive.  I then copy this image to another computer with a lot of hard disk space and leave it there as a backup should something ever go really wrong with the laptop.  There are a variety of tools both commercial and Open Source that make this process relatively easy.  The most well known tools are probably Norton Ghost and Acronis TrueImage.  In the Open Source world there are some decent alternatives such as FOG and PartImage.  Most of these tools have varying levels of intelligence that allow them to copy only the bits of the filesystem that are in use, dramatically reducing the amount of space that it takes to create an image.

However, all these solutions require me to actually obtain the software and create images will only work with that specific software. The not only results in me needed to download additional software, but also needing to hope that the software continues to be maintained in the future.  As I don’t want to be locked into a single piece of software what may not be maintained in the future, I typically do my backups with a much more simple tool, the standard unix tool dd.

The manual page for dd says that it “cop[ies] and converts a file”.  In this case, I take advantage of the fact that all block devices present themselves as files under Linux and simply make a copy of the hard drive using that method.  If I need to restore the image in the future, I just write the image back to the hard drive using dd.

Because more and more computers are shipping without CD/DVD drives, especially in the category of netbooks and ultraportables we can’t just use a Linux live CD.  In my case, I’ve used this method to back up an IBM Thinkpad x31 and a Lenovo Thinkpad x61 tablet, neither of which have optical drives.  The first step is to create a bootable USB stick with a Linux image on the disk.  You’ll use this to boot into Linux and run dd — after all, you can’t image a drive if you’re currently using it.  There are various tools to do this, but I’ve had really great luck with UNetbootin.  If you want to use the very simple method, you can just download the software, and it will take care of automatically downloading the CD image and coping it to the USB stick to make it bootable.  It also provides an option to take an ISO image already on your hard drive and make it bootable on the USB stick.  Because it has excellent hardware support and the install CD is also a live CD, I usually use the latest version of Ubuntu.

With the USB stick in hand, simply boot the computer you wish to clone from the USB drive.  Once the Linux desktop appears open up a terminal and use sudo to become root (note: some Linux images have you running root all the time).  Now you’re going to use the dd command to make an image of the primary hard disk, which in newer machines is /dev/sda (some older machines may have it as /dev/hda).  Except that we need someplace to store the image, most of the time if you’ve put a Linux CD image on a USB drive it will not be writable, so unless you’ve got another large USB storage device, you’ll need to copy it across the network to another machine.  Here’s a diagram of what we’re going to do:

Drive Imaging Process

Drive Imaging Process

Orange is operations that will happen on the local computer, and blue is operations that will happen on the remote computer where the image will be stored.  Files generated through this process can be pretty large, so doing this over a wired network is going to work better.

In the first step, we use dd to read the data from the hard disk, this is then piped via a standard unix pipe to bzip2, which will compress the data.  Alternatively at this point you can use gzip if you’re worried about the CPU overhead.  This is a long process that I usually let run for a couple of hours.  From there the output of bzip2 is sent to SSH, which connects to SSH on the remote machine.  Then, as we’re still dealing with standard output, we can use cat to redirect the output to a file.  This entire operation can be done with a single command and without the need to create any intermediate files.

dd if=/dev/sda of=/dev/stdout bs=1M | bzip2 | ssh USERNAME@remotehost "cat - &gt; drive.img.bz2"

There are a few parameters which may need a bit of explanation.  With regards to dd, the if and of arguments specify the input and output file, here we use /dev/stdout to indicate that we want dd to send the output to standard output.  I also set the blocksize to 1 megabyte with the bs argument.  This is then sent to bzip2 which will compress the standard input stream and send it to standard output.  SSH then takes this information, logs onto remote computer “remotehost” as user “USERNAME”, and then uses cat to save the image to a file.  This process will not show any sort of progress as you do it.  You can get a rough idea of how much data has been processed by looking at the size of drive.img.bz2 on the remote machine.  In my experience images created this way tend to be about 1/10th the size of the drive.  Alternatively, you can work the pv command into your commands to get a better estimate of progress.  To restore the drive image to the drive, you can use the following command:

ssh USERNAME@remotehost "cat drive.img.bz2" | bzip2 -dc | dd if=/dev/stdin of=/dev/sda bs=1M

In most cases you can even use this method if you upgrade to a different disk, but you’ll need to run something like gparted or Partition Magic to update the size of the filesystem and do some small repairs on the drive after restoring the image.

This method doesn’t generate the smallest files possible — notably if you’re working with a disk that has already been used many times, it will not generate good compression because many of the old bits are still floating around on the disk.  More advanced solutions take into account the structure of the filesystem and just code that large segments are supposed to have no data, which can provide substantial savings.  However, for a method that is quick and works with almost every system out there, I’ve found that this works wonders, and I know that dd isn’t going anywhere.

Iron April 2009

I’m officially on the hook for competing in Iron April 2009.  It’s an interesting event organized by a real Ironman, Kevin Haugh, that takes loads of folks who normally don’t triathalons and convinces them to do the distance of an Ironman over the course of the month of April.  It’s an informal sort of competition where you’re motivated by the other folks who are also trying to accomplish the same thing.  There’s not prize for being the first person to finish, other than knowing that you managed to complete Iron April.  Each person has a page where they post their updates and progress.  I’ll be posting little short blurbs here.  In addition, sometime soon I’ll also create some sort of widget that I can use to post my overall progress on the sidebar of the blog.

I’m fairly certain that the running will be no problem.  Most weeks I break 26.2 miles without the extra motivation.  If I don’t hit 26.2 miles this month it will be because I’ve done something stupid and injured myself.  Swimming just requires me to go to the pool a couple of times and get a few hours of swimming in, not a big deal when you’re on a university campus.  The difficult thing will be biking.  I’m going to start biking to and from school every day, which gives me about 4 miles along the bike trails.  I’ll also have to do some longer bike routes on the weekend or on my off days from running.

In any case, it looks fun and is the first baby steps toward me eventually doing a real Ironman race.

Safely Migrating Recordings in MythTV

As I mentioned in my previous article about using a Drobo as primary MythTV storage, the optimal solution for using a Drobo in MythTV is to record to an internal hard drive and then migrate the recordings later to the Drobo. When migrating recordings care is required because the recording could be in use, either as a result of someone watching the recording or because transcode/commercial flagging jobs are running on the recording. Fortunately, MythTV stores almost everything in a MySQL database, which makes it really easy to find out the status of a recording.

There are two tables that you’ll need to examine to ensure a recording is not currently in use. The first table to check is the jobqueue table. This table lists every recording that has pending jobs on it, whether user jobs or internal jobs such as commercial flagging. It also leaves entries in the table for logs, so you can’t just make sure there are no entries for a program in the table. The trick here is that you’ll want to make sure that the program you’re examining has a status that is greater than 255, which indicates that there isn’t a pending job. All statuses over 255 indicate some sort of completion.

The second step is to make sure the program isn’t currently recording or being watched. This is accomplished by looking at the inuseprogram table. If a program has an entry in here, you certainly should not try to move the recording, and instead just wait until some later time to move it.

When you combine these two checks, you can be fairly certain that recording isn’t in use and moving it will be safe. Rather than having to perform these checks by hand, I’ve created a script called MythMigrator which looks at a storage group and will migrate all recordings no in use to another group. I’ve made a git repository available at http://patrick.wagstrom.net/git/mythmigrate.git where you can download the script.

To utilize the script you’ll need to have two different storage groups defined, one where your recordings are initially stored, and another where they are archived for long term storage. In my case these are called “Default” and “Long Term”. Now it’s as simple as running a cron job at some lightly loaded time, for me this is about 9am, with the following command:

python MythMigrator.py "Default" "Long Term"

That’s all there is to it. My recordings are safely migrated every morning and I hope this script can help you too.

Drobo as Primary Storage Considered Harmful?

Advertisement from mwave.com billing Drobo as your new Primary Storage

Advertisement from mwave.com billing Drobo as your new Primary Storage

In October 2008 I purchased a 1st generation Drobo to provide additional storage space for my growing collection of recordings from MythTV. The plan was to use the Drobo as primary storage for MythTV recordings, something I believed to be acceptable because recording high-definition television maxes out at a couple of megabytes a second. The Drobo is equipped with a USB2 connection and should be able to push well more than that. The Drobo also provided some great advantages, such as on the fly addition of disks to the array, and data redundancy. Along with the Drobo I purchased two Western Digital 1TB green drives. After migrating some drives from my old array I had a Drobo with 2×1TB and 2×320GB drives. I was able to take the number of drives in the actual case for my MythTV box down to just two, and in the process, reduce heat and noise from the machine.

I’m now about five months into this little experiment, and it’s been met with mixed results. After installing the Drobo I had about 700GB of a 1.6TB drive occupied. Writes were fast and I never had problems with recording multiple shows, watching recordings, and even transcoding recordings all at the same time. However, the Drobo allowed me to be lazy, I no longer needed to worry about diligently transcoding recordings. Soon I found my 1.6TB drive filling up and yellow lights appeared telling me that I had better upgrade a disk in the array. Rather than inserting a new disk, I took the opportunity to transcode hundreds of recordings from MythTV. When combined with cutting commercials and a small decrease in resolution, I can take a 4GB HDTV episode of the Office and drop it down to around 500MB with little degradation.

At this point I started to notice issues with MythTV under heavy usage. On Monday nights I often have both HD tuners recording, an analog tuner recording, transcode jobs running, commercials being flagged, and I’m often watching a high def program. This actually maxes out to a little under 10MB/s, something the Drobo should be able to do with little problem. However, recordings from that evening would frequently end up missing small bits of video and jumping ahead. For some shows this was no problem, but it could miss a critical moment in a show like 24. I quickly identified the problem as the Drobo not being able to keep up with the requests. During some down time I used Bonnie++ to calculate a synthetic estimate of disk throughput — the results were downright ugly for the Drobo:

Version 1.03c       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
spongebob        4G 10260  40 14116   8  8107   5 16746  57 18169   3  61.5   0
                    ------Sequential Create------ --------Random Create--------
                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 10085  40 +++++ +++ +++++ +++ 26325  98 +++++ +++ +++++ +++

For comparison, here is the output of Bonnie++ on a 320GB internal hard disk:

Version 1.03c       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
spongebob        4G 42271  94 55788  31 28871  14 50686  96 71219  16 128.7   1
                    ------Sequential Create------ --------Random Create--------
                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 22504  96 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++

I’ve put the most relevant stats in red bold. In the case of the Drobo, creating files at the block level, which should be the fastest results in a throughput of about 14MB/s, while the 320GB internal hard disk whizzes by at 55MB/s. Likewise, the read rates are dramatically different, Drobo maxes out at 18MB/s, while the single internal hard drive reads at 71MB/s. For comparison, my 4 drive software RAID 5 array used to read at 106MB/s.

Under most circumstances, switching to a disk array results in an increase in performance. Both writes and reads are spread out across multiple disks, reducing issues with seek time and allowing parallel reads and writes. However, that is clearly not the case with the Drobo. Much of the bottleneck is probably a result of the USB2 interface to the Drobo, however, that cannot be the entire reason for the slow throughput. Many other people have noted the slow performance of the Drobo (see MaximumPC, Mac360, and CNet reviews). On occasion a reviewer will get slightly confused because the device automatically slows down as it gets closer to being full — this is ensure you have enough time to get another hard disk and replace a smaller one. But what’s really strange is how sometimes the Drobo just stops writing for a period of seconds at a time. Here’s some output from dstat when copying a large file from an internal hard drive to the Drobo:

----total-cpu-usage---- --dsk/sdc1- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw
  1  14   0  83   0   1|   0    21M| 236B 1064B|   0     0 |1675  3260
  3  14   0  81   0   2|   0    24M| 590B  448B|   0     0 |1745  3456
  3  17   0  79   0   2|4096B   21M| 236B  448B|   0     0 |1728  3416
 12  13   0  71   0   3|   0    26M|  29k   29k|   0     0 |1784  3654
  6  33   0  59   0   3|   0    23M| 907B 1139B|   0  8192B|2020  3285
  2  10   0  86   0   2|   0    18M| 596B 3586B|   0     0 |1708  3487
  3  17   0  77   0   2|   0    20M|6262B 3530B|   0     0 |1830  3684
  4  16   0  77   0   4|   0    24M| 354B  448B|   0     0 |1952  4022
  9  12   0  77   1   2|4096B   21M|5203B 8709B|   0     0 |1843  3875
 14   9   0  76   0   3|   0    22M|4848B 5200B|   0     0 |1938  4340
  5  29   0  65   1   2|   0    16M| 224B  586B|   0     0 |1686  3143
  4  12   0  82   0   1|   0  7684k| 354B  464B|   0     0 |1370  2609
  2   5   0  92   0   1|   0  6580k| 416B  536B|   0     0 |1118  2147
  2   9   0  89   1   1|   0  8856k| 210B  510B|   0     0 |1290  2449
  1   6   0  92   0   1|   0  7860k| 462B  600B|   0     0 |1177  2131
  2   3   0  94   0   1|   0  7156k| 328B  560B|   0     0 |1094  1970
  3   4   0  94   0   1|   0  8192k| 578B  798B|   0     0 |1090  2017
  2   3   0  95   0   1|   0  3616k| 573B  743B|   0     0 | 966  1605
  2   5   0  92   0   0|   0   920k| 354B  464B|   0     0 | 939  1610
  5  12   0  82   0   1|4096B 5656k|3555B 3787B|   0     0 |1239  2240
 25  21   0  53   0   1|   0  2416k|  38k   39k|   0     0 |1105  2323
  7   6   0  86   0   0|   0  3120k| 524B  894B|   0     0 |1032  1833
  7   7   0  85   0   0|   0  6152k| 925B 1673B|   0     0 |1153  2040
  4   4   0  93   0   1|   0   960k| 708B  680B|   0     0 | 947  1683
  8  15  27  50   0   0|   0  2176k|3086B 3121B|   0     0 | 973  1587
  6  30  48  16   0   1|   0  1080k|5286B 5664B|   0     0 | 936  1397
  6   5  49  39   0   1|   0   960k|8552B 8820B|   0     0 | 954  1606
  9  18  49  24   0   0|   0     0 |6230B 6486B|   0     0 | 919  1454
  7  28  49  16   0   0|   0     0 |  10k   11k|   0     0 | 897  1313
  4   4  49  43   0   1|   0     0 | 811B 1123B|   0     0 | 945  1690
  3   3  48  46   0   0|   0     0 | 236B  464B|   0     0 | 910  1553
  4   3  50  44   0   0|   0     0 | 250B  584B|   0     0 | 965  1760
  2   2   0  96   1   0|   0   584k| 354B  432B|   0     0 | 927  1589
  4   4   0  92   0   1|   0   120k| 236B  432B|   0     0 | 866  1437
  5   5   0  89   0   0|   0     0 | 118B  432B|   0     0 | 864  1520
  4   4   0  92   0   0|   0   600k| 236B  432B|   0     0 | 910  1631
  5   5   0  90   0   0|   0   960k| 354B  432B|   0     0 | 880  1588
  5   5   0  89   0   1|   0  1680k| 236B  448B|   0     0 | 923  1495
 13  29   0  57   1   0|   0    11M|  14k   14k|   0     0 |1341  2112
  8   5   0  87   1   0|   0  6704k|1693B 2067B|   0     0 |1094  1948

I’ve highlighted the amount of data being written to the Drobo in red, where you can see that for extended periods of the file copy the Drobo decides it would rather not write anything. What’s interesting is that this occurred right after the Drobo went into what seemed like a “Turbo Mode”, writing at rates of over 20MB/s. Clearly, this is a problem, and such blocking of writes mean that Drobo cannot be used as a primary storage device for MythTV. It works wonderful for playing back of recorded programs, storing music files, a drive for my photographs, but anything where streaming directly to disk is required is not a good idead for the Drobo.

However, I have an alternative solution.

MythTV has the concept of Storage Groups. Originally they were designed to force MythTV to load balance recordings across multiple drives. When a recording is selected it appears that MythTV scans all storage groups for the recording. The solution I have adopted is to put the default recording group on an internal harddrive and create another storage group, called “Long Term”, which features the Drobo. Periodically I then copy the files from the internal hard drive to the Drobo, thus ensuring that I always have enough space to record more. Since I’ve done this I haven’t noticed any issues with disk load causing corruptions of recorded files.

Grad School is Where You Lay Your Head

On Monday, March 9th I successfully defended my Ph.D. thesis.  I haven’t finished all the little revisions yet, in fact I haven’t even opened the email from my advisors yet, but I’m largely finished with grad school.  If you’re interested in the thesis or the presentation, you can take a look at my Patrick’s Awesome Thesis Defense Page that is part of my academic home page.

One nice aspect of grad school is that it afforded a reasonably flexible work schedule and the ability to travel a fair amount.  Some semesters, it was pretty crazy, other times it was pretty relaxed.  It all just depended on how productive I was being at work.  In that spirit, I decided to make a map of all the places that I slept while in grad school.  Each of the markers represents a physical building (or tent, etc), while the lines represent wonderful overnight flights.  I haven’t done anything to show how many times I’ve slept at a location or on a flight, but you get the general idea.

Grad School is Where You Lay Your Head
View Larger Map

Confusion Abounds! DTV Transition Delayed Until June 12. Or is it?

Postponing The Rapture For Political Points!

Postponing The Rapture For Political Points!

The United States House of Representatives voted 264-158 to extend the DTV Transition until June 12th.  The vote went largely along party lines with a handful of each party switching sides, but it wasn’t enough to be called a bi-partisan approval.  However, it fails me why this should be a partisan issue in the first place.  In approving the delay, the House left in the provision that allows TV stations to switch over before June 12th if they choose.  This is an appealing option to many stations because of the high cost of running two sets of transmitters.  At a price of $0.12KWh, a 100,000W transmitter costs $12/hour to run, $288/day, and $8640/month.  A station with a 100,000W transmitter could therfore be expected to spend about $34,560 to keep their transmitter powered until June 12th.  Clearly they have incentive to commit to transition early.

The primary reason why many folks voted for this bill was because of a chart that Nancy Pelosi circulated that showed the number of consumers on the waiting list for DTV converter boxes in each congressional district (you can find the chat on Ars Technica’s coverage of the bill).  Every single congressional district has between 1200 and 9200 people on the waiting list for coupons — and a shocking 53,372 people in Puerto Rico.  Furthermore, every district saw their waiting list increase by at least 100 people, and some as many as 800 over the course of a weekend.  Ostensibly, approving a delay would ensure that these 181,013 new households and 1,781,218 previously registered households receive their coupons.

However, the program is out of money.  The only way that coupons are being sent out right now is if someone’s coupon expires.  If the list were capped at the number of people on it currently, and that seems unlikely, then the government still needs to come up with $156,983,520 to pay for those coupons.  Unfortunately, in approving the delay, no provision was made for this funding.

Furthermore, there is no evidence that delaying the transition will actually help people.  Two areas have already transitioned to DTV, Wilmington, NC which transitioned as a test in September, 2008, and the entire state of Hawaii, which transitioned last month to not interfere with a species of bird that is active in February.  If we look at Hawaii, however, there still are 2,974 people on the waiting list, with 129 new people just last weekend.  These are people who failed to submit their coupon request until after the transition happened.  My guess is that there’s a lot of grandmas out there who will be in the same boat — in addition to folks who have cable for most of their televisions, but may want to ditch it because of budget concerns (talk about a great lockin for cable companies).

So, now we’re left with an utter mess.  Instead of having a solid date for when analog broadcasting dies, stations can choose to switch anytime between Februrary 17 and June 12.  My hunch is that within a metro area, not all stations will switch at the same time, just confusing folks more — “I only get the station with the fifth grader show.  Where’s my CSI:Albany?”  Furthermore, it’s looking more and more unlikely that the government will come through with the estimated $300-$500 million necessary to fund the coupon program — they’ve got bigger things to worry about than whether or not people can continue to watch “How I met your Mother” and “Knight Rider”.  Finally, President Obama has yet to sign the bill, but has indicated support for the bill.  Therefore all the official advertising, even on dtv2009.gov still lists February 17th as the date.

Yes the transition has come at a really bad time.  We’re fighting two wars.  Our economy is collapsing.  Now, the way they’ve handled transition indicates that it will be a mess for a long time to come.  In the end, the winners may be services like Dish network and Comcast, who are sending out millions of flyers around the country advertising budget rate plans starting at $9.99 for local channels.  The losers will almost certainly be the people who waited and haven’t requested their coupons, and will be left without whatever crappy summer programs the networks unleash on us in June.  But hey, it’s June, it should be nice outside.  I hear there’s lots of things to do outside.

Taking “nice” Processes Into Account With Powernowd

Almost every modern CPU supports the ability to dynamically change its clock frequency — typically done to save power when there are lesser requirements placed on the system.  While the benefits for a laptop are obvious, more battery life and less heat, they may be a bit harder to understand for a desktop machine.  One application, however, where you should be particularly aware of CPU frequency scaling is with media center boxes.  The less often the CPU needs to speed up, the less heat, the quieter the fan, and the lower your power bill.  On my system, the differences can be pretty dramatic, with the CPU taking an extra 20-30 watts when running at full speed versus slower rates.

Within Linux, there are numerous ways that the CPU frequency is controlled, for example with powernowd or the kernel level ondemand governor, which is the default with most Linux distributions.  One of the aspects of these technologies is that when the system is heavily loaded with processes with high “nice” levels, the CPU will not speed up.  For most cases this is fine, but when running a MythTV box, it may be desirable to allow nice processes to increase the CPU speed — particularly as these nice processes may be things like transcoding or commercial cutting jobs.  Allowing the CPU to ramp up is particular helpful for evenings where many programs are recorded.  On a Monday night where my MythTV box grabs five HD programs, without allowing the CPU to speed up, it can take over a day to commercial flag and trascode everything.  When the CPU can speed up this time drops to about 8 hours.

Under Ubuntu the default configuration is to use the “ondemand” governor, which means there is no daemon running and the CPU will scale with demand and load.  However, there is nasty line buried in the /etc/init.d/powernowd startup script:

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use_ondemand() {
    if [ "$OPTIONS" != "-q" ]; then
        return 1
    fi
    status=1  # return error, if no cpu dirs are found
    for x in /sys/devices/system/cpu/cpu[0-9]*/; do
        if [ ! -d $x ] || [ ! -f $x"cpufreq/scaling_governor" ]; then
            continue
        fi
        echo -n ondemand > $x"cpufreq/scaling_governor"
        status=$?
        if [ $status != 0 ]; then
        return $status
        fi
        # The default behaviour of powernowd is to ignore nice load:
        if [ -f $x"cpufreq/ondemand/ignore_nice_load" ]; then
            echo -n 1 > $x"cpufreq/ondemand/ignore_nice_load"
        fi
    done
    return $status
}

Line 108 is the culprit of our problems. By echoing the string “1″ to /sys/devices/system/cpu/cpu[0-9]*/cpufreq/ondemand/ignore_nice_load, the ondemand governor will not take into account nice loads. Under previous versions of Ubuntu, or when you’re not using ondemand and actually need powernowd to run, this change was easily done altering some settings in /etc/defaults as I detailed 3 years ago. However, now you need to hack the script yourself. The simplest way is just to change the “1″ to a “0″ on line 102 of /etc/init.d/powernowd, giving the following line:

102
            echo -n 0 > $x"cpufreq/ondemand/ignore_nice_load"

Change this setting, then you can either reboot, or run /etc/init.d/powernowd restart as root. If you watch your CPU speed (check out /proc/cpuinfo), you should notice that nice processes now speed up the CPU.