Wednesday, July 29, 2009

Interruption and the Cost of Context Switching

I've been thinking about interruption lately. I shared some thoughts about anticipating interruptions in an article about the probability of interruption. More obviously, when an interruption happens it costs me something. Specifically, I have to switch from doing one thing to doing something else. There's a non-zero cost to focusing my mind on a new task. That effort is pure overhead. It's like energy lost to friction or electricity spent "heating the whole neighborhood" (as our parents used to say). If one can reduce interruptions, one should be able to reduce context switching costs.

I use a small program that I wrote to record the time I spend working. When I switch tasks, I press a few keys to indicate what I'm working on now. At the end of the month, I use this data to generate invoices, etc. Even though I don't record every context switch in my time clock program, I do record many of them. Reviewing the data for the last 18 months shows that I worked on 1,635 unique tasks. I switched context 7,768 times (subjectively, most of those were caused by interruptions). On average, I spent 25 minutes working on a given task before switching to something else. If I assume it takes me two minutes after a context switch to become productive again (which is a very conservative estimate), it means that I spent 7% of my total working time just switching between responsibilities. That 7% produced very little value for me or my clients.

Managing interruptions is an important component of enhancing one's productivity. I'd be thrilled if I could effectively have 7% more time in a day.

Friday, July 17, 2009

Probability of Interruption

I just got back from a one hour hike in the hills near my house. While I was hiking, I had my phone with me. According to telephone records for the last 10 weekdays, I received 2 text messages and 1 phone call (on separate days) between the hours of 2 pm and 3 pm. So during my hike, the probability of interruption was roughly .3. If I used a service to receive notifications of new email on my iPhone, the probability of interruption from incoming email would have been about .93 (based on my email records from 2008). In my typical office environment there are also possible interruptions from IM, Twitter and kids. The probability of receiving an interruption in my office during that hour approaches 1.

Subjectively, the probability of interruption strongly influences my stress level. A low probability of interruption encourages relaxation while a high probability causes stress and reduces concentration.

Why does the probability of interruption and not the interruption itself seem to cause stress? I think it's because I anticipate being interrupted. For example, when I travel for work, I often leave my house early in the morning to catch a flight. As I go to bed the night before departing, I set an alarm (a planned interruption) to wake me up. I often wake up throughout the night anticipating the upcoming alarm even though it hasn't gone off yet. I lose sleep without the interruption actually happening.

Another anecdote: Several years ago, I worked in a traditional office environment. While at my desk, I could be interrupted by an email, a phone call or a coworker across the room. When I left my desk and walked down the long hallway to the rest of the building, I always felt a release of tension. As I rounded the corner to pass another coworker's office, I felt an increase in tension. It was as though I was walking the hills and troughs an interruption probability function.

Probability of interruption may explain why some people are most creative when in the shower or on the toilet. There's some indication that stress reduces creativity. Because of social taboos, the probability of direct interruption while bathing or defecating is practically 0. That reduces stress and allows one to be creative.

I suspect that intentionally limiting possible interruptions can increase one's creative throughput.

Saturday, March 21, 2009

send: Cannot determine peer address

I came across this error while doing some work with Unix domain sockets and Perl's IO::Socket::UNIX module. I was able to create the socket successfully and have the client connect to it. The client could successfully send data to the server, but when the server tried to respond I got the error "send: Cannot determine peer address". My original server code was:

use strict;
use warnings;
use IO::Socket::UNIX;
my $server = IO::Socket::UNIX->new(
Local => '/tmp/path/to/socket',
Listen => 5,
) or die $@;

The client code that produced the error was

use strict;
use warnings;
use IO::Socket::UNIX;
my $socket = IO::Socket::UNIX->new(
Peer => '/tmp/path/to/socket',
) or die $@;
print $socket "command away\n";

It turns out that my client was exiting before the server could respond. By the time the server responded, the client had disappeared and no "peer address" was available. By adding my $response = <$socket> to the end of the script, the client waited for the server's response and everything worked great.

Saturday, February 07, 2009

Treo 680 Long-term Review

I bought an unlocked Palm Treo 680 about 19 months ago (July 2007). It's starting to show its age. For posterity, I thought I'd document what I like and dislike about it. With gadgets, long-term reviews are almost useless as a means to prepare future buyers. By the time someone has gained enough experience with a product to know if it was a good purchase, the gadget's no longer manufactured. The 15-20 year life span of a car lets someone document two years' experience while still leaving 18 years where the review can be valuable.

Anyway, back to the phone.

Things I Like

This is the first smart phone I've owned. I really like having a phone and computer in one package. I only have to remember one device and it fits nicely in my pocket.

While traveling to Bear Lake, UT last summer, the Treo came in really handy. The cabin where we were staying had no internet connection. I was unable to find a coffee shop, restaurant or hotel in the area with a 'net connection. After a few minutes on the phone with T-Mobile, I had upgraded my phone plan to include a data plan for the month. About 30 minutes after that, I had my laptop connected to the Internet through the phone. It let me take care of a few business things each morning and then enjoy the rest of my vacation. It was nice knowing that I wouldn't have to face a huge pile of email and other responsibilities when I got back from vacation.

I also appreciate the external antenna jack. I didn't even know this existed until this week. Where I'm staying in Tucson, the cell coverage is really bad. I barely get one signal bar in the house. I bought a Freedom antenna to plug into the external antenna jack. It immediately brought the signal up to 3 bars.

I also like the long battery life. I routinely forget to charge the phone for a couple days. It still works just fine. Once I plug it back in, it charges quickly and is ready for another couple days.

I also like the external speaker. It's nice to be able to listen to music or make a hands-free call without having to track down headphones.

The external switch for turning off the ringer is pretty handy too. I can easily find and operate it in the dark. When activated, the phone vibrates to indicate that I've successfully silenced the ringer. That's turned out to be a very useful feature.

Things I Dislike

I dislike that the phone crashes regularly. I probably have to restart the phone about once every other day because it freezes. This might be because I use Agendus which is some pretty awful/useful bloatware. Unfortunately, the built-in Palm apps are so crappy you almost have to use a third-party product.

I really dislike that the phone drops calls left and right. I get a strong cell signal in my office at home. However, I can't use the phone for weekly conference calls because it routinely drops the call after about 7-10 minutes. I thought this was caused by battery problems, but leaving the phone plugged in to a power supply doesn't help at all. So far, I haven't had a dropped call with the phone plugged in and an external antenna attached. Of course, that really defeats the purpose of having a cell phone.

The charger/sync connector is fragile. It takes me two or three tries each morning to get the phone connected well enough that it can sync with my desktop. It worked pretty well for the first 12 months. Since then, it's been flaky.

The screen is tiny and the camera is awful. I'll let those finish out my whine session.

In the end, I'm glad I bought this phone. It's served me well and was by far the best option available at the time. I'm looking forward to getting an iPhone or Android phone at some point, but I'll probably try and milk this one for all it's worth first. I'm pretty sure I won't get a Palm Pre no matter how good the reviews are. I've had a Palm for the last 6 years (at least) and every one has been plagued with crashes that required a reset. They've had their chance and have persuaded me that they don't know how to write reliable software. It's time to give someone else a try.

Thursday, February 05, 2009

Don't Forget the Power Cord

I moved the whole family down to Tucson, AZ from Hanna, WY for February 2009. My wife's packing was a resounding success. She didn't forget a single thing. Of the things I was responsible for, I only forgot one: the power adapter to my Mac Mini. It turns out that no single item in our packing list was more important. That's because Apple uses a proprietary power connector for the Mini. Nobody in Phoenix or Tucson carries them.

The online Apple Store sells them and they "ship within 24 hours", so I ordered one on Tuesday. On Thursday morning, I got an email saying that it won't ship for 7-10 more business days. I called Simutek (a local Apple retailer) to see if I could buy a Mac Mini from them, use the power cord for a week and then sell them back the Mini as "used" when I was done with the adapter. Instead of accepting my desperate offer and making a quick $200, they offered to rent me the power adapter off one of their floor models for $5/day. Sweet! I promptly canceled my order through the Apple Store and ordered the adapter from Simutek.

Now to the point of this post: lessons I learned from this situation and what I can do better if there's a "next time."

  • be more careful in packing (mentally walk through the unpacking process)
  • unpack as soon as possible to provide extra time for acquiring replacement parts
  • push all Git branches off to the cloud somewhere to reduce dependency on a single hard drive
  • in time critical situations, it's valuable to work with a real person who can elevate his research to make sure that important deadlines are met
  • don't design something with a proprietary interface if a standard interface can do the job