Saturday, July 21, 2007

Fame at last

The Chronicle Herald published my interview. A few details were off (I've had 15-20 physical interactions with cars, rather than being knocked off my bike 15-20 times, and a lot of my scars are from mountain biking or bike stunts gone wrong as a kid rather than solely from car related injuries) but hopefully it'll cause a few drivers to think how they behave around cyclists.

Thursday, July 19, 2007

Power reduction nº2: Linux more environmentally friendly than Windows XP

Continuing on with the last post, I decided to try Windows versus Linux to see how things were. Since most personal computers (as opposed to servers) spend the vast majority of their time idle, I figured the best test would be to boot up the machine, log in, then see what the power draw was after waiting for a minute for everything to settle down. I used my work laptop, a 1.86GHz Pentium M NC6230. I tested it with the development version of Ubuntu, and Windows XP with all the latest patches.

Some background on power management for those who haven't for some reason spent the last 30 years deep in technology:

The Pentium M has a power saving feature where it can reduce its' clock speed in steps, from 1.86GHz down to 800MHz. Intel paid their marketing department large sums of money to come up with the name "SpeedStep" for this. The net effect is that running the processor at a lower speed when idle means it can also run at a lower voltage, and since the calculation for power used (watts) is done by multiplying the power (in amps) required to run the device by the voltage (in, er, volts) required to push the little electrons through the device, dropping both volts and amps can significantly impact the power drawn. In addition, extra tricks can be pulled; for example, if the processor is idle, the processor cache is also idle and can be flushed and then turned off. The reasoning is to increase battery life, but using SpeedStep when AC power is on will still result in the same power savings.

So, on to the results. First of all, I tried the bootable warbiking (no, not that warbiking) configuration I created. This is a basic Debian install on a USB stick, that has then been stripped down to reduce power usage as much as possible; screen is turned off, processor is forced to 800MHz, all the PCI devices that aren't required (IDE interface, sound card, unused USB ports) are turned off, and the hard drive and CD Rom are turned off. The only things that are running on the hardware side are CPU, memory, USB interface for the USB stick, wireless card, and the necessary glue hardware to stick them all together. On the software side, apart from kernel daemons there's just Kismet and a bash shell. I could gain a milliamp by booting straight into Kismet as bash has a wakeup every now and then, but I'd rather be able to log in on the console to do other stuff as needed. Final power usage at idle: 17W

Next, I tried Ubuntu, booted up into a gnome desktop. I used the "ondemand" speedstep governor; this tweaks the processor speed according to load, so at idle it was running at 800MHz. Power usage at idle: 22W

Next step was power usage at idle with the processor running full speed: 26W

Peak power draw seen was 41W, during shutdown.

Next, I booted up Windows XP. I used Speedswitch to control the processor speed. Speedswitch has several settings, dynamic switching, max battery, battery optimised, and max battery. The results were:

Dynamic switching: 23-24W
Max battery: 22-24W
Battery optimised: 22-25W
Max performance: 26-27W
Speedswitch disabled: 25-26W

The results from XP were very twitchy - unlike Ubuntu, which, once it settled, had a very stable draw, the XP draw was constantly changing up and down. At first I thought it might simply be that the draw was dead on between two values (23 and 24 W) so it should really be 23.5W; however, all the other settings had the same problem, and with a variance of up to 3W, so that doesn't seem to have been the issue. All I can assume is Windows has so much random code firing off that the processor can never settle down.

So, conclusions to be drawn from this sample size of one... Since I use ondemand and dynamic switching, for me, the laptop is drawing 22W at idle under Ubuntu, and 23-24W under Windows. This means that Linux is saving me somewhere on the order of 1.5 watts over Windows when I'm sat there not doing anything (such as reading a document). This also means slightly less heat, so the fans will kick in slightly less often, decreasing the power usage a smidgen further on the Linux side.

The other conclusion I've proved to myself (I was pretty sure of it before) is that a laptop is more environmentally friendly in terms of power draw than a desktop machine. I was rather surprised at just how much less draw there was - almost 70 watts!

In biking news... 2 weeks till I'm back on the bike!

Monday, July 16, 2007

How I got a faster computer by reducing power usage

Nothing to do with biking or injuries, but I thought people might be interested.

For my birthday, I got a P3 Kill-a-watt, which monitors electricity usage (amongst other things) so one can calculate the amount of power a device requires. When I plugged my desktop into it it was running at 120W to 130W, which seemed a little high; it's an 1800-odd MHz Athlon with a couple of sticks of RAM and 4 drives. After some wandering around, I found Linux Powertop, which monitors a system to try to see where the power is going. This also requires the 2.6.22 kernel for some high resolution timing code, and as a bonus it has a tickless feature. Computers generally have a timer that fires at a fixed rate per second, which wakes up the computer out of any low power mode; tickless means the kernel schedules sleep until it's actually needed (ie, a program needs to run) or an interrupt is received from a piece of hardware (packets arrive on the network connection).

After recompiling the kernel a few times and rebooting, I managed to get the power usage down to around 100W. After running Powertop for a while, I noticed that there were some odd things firing off multiple times per second that really didn't seem to need to; wmweather+ was firing off trying to poll retrieval of non-existent METAR data, wmCalClock was firing off 20 times a second "in case the icon was moved and needed redrawing", and my network monitors were constantly firing off. In the end I patched wmCalClock to only fire off once a second to update the icon, and I removed all the other applets that were firing off. After all that I went from around 500 wakeups per second to 250, with power usage dropping down to around 95W.

The only other thing firing off that looked like an obvious target was rtorrent. It turned out that this was scheduling timeouts as I had an upload cap, so it was only sending packets every x milliseconds, which required the timeouts. After I disabled that (leaving bandwidth management to the kernel QoS) I was down to 180 to 200 wakeups per second, with the top 3 wakeups all being hardware interrupts and the next one being Firefox. Power usage was now running at around 93W.

The final thing I did was to turn off the CD burner with hdparm when not in use. This took me down to 90 to 91W.

The surprising thing after all this is how much faster my computer is. All those wakups were stealing CPU time away from me when I was trying to do stuff, resulting in (for example) Firefox crawling when browsing around heavy Flash sites. Now I've stripped out the junk on the software side, the next step is to look at the hardware side to see what I can pare down; floppy drive, I'm looking at you!

I just did a ballpark calculation on the savings as a result, and just from my own machine here it looks like this:

Approximate power reduction: 125W - 91W = 34W
Daily reduction: 816 watt-hours
Weekly reduction: 5712 watt-hours
Monthly reduction (30 days): 24480 watt-hours
Yearly reduction: 297840 watt-hours, or 297.84 kilowatt-hours

Current cost per kilowatt hour: 10.67ยข per kilowatt hour
Savings per year: 3177.95 cents, or about $30, or almost 3 packs of decent beer.

So, just by optimising one device I've managed to save myself (in theory, at least) around $30 a year, and got a faster computer out of the deal too.

One other thing I noticed is running the graphics card in 3D OpenGL mode ramped the power up to 140W to 150W. I guess OpenGL screensavers are probably a bad idea...

Thursday, July 12, 2007

Finally, some good news

I went in to have another X-ray today, and after looking me over the surgeon told me I am healing at a "significantly faster rate than usual", which is a good thing. I asked when I could get on the bike, and he asked me what my plans were originally. I told him about the plan to ride from Port aux Basques to Cornerbrook and he said it would be doable, if I felt up to it. I asked him about riding around downtown Halifax and he said, "oh no, the roads are far too rough"! I now have 3 weeks until I can get back on the bike, which means missing yet another Critical Mass but I may at least be able to attend a minimass at some point...

Went into IdealBikes to look at options for body armour. I was sold on the Mace Short Sleeved Swat Jacket, although there were comments like, "dude, look at the pressure suits, they're kinda overkill but they give you full spinal protection!" Since I usually have a backpack on anyway I have pretty good full spinal protection from that; the pressure suits tacked on an extra $100+ in exchange for what looked like a rather warmer set of armour to wear...

There was also a Peugeot there that was suggested for me. I didn't take my bike down but the general consensus was that it was a writeoff and not worth repairing, unfortunately. I guess I'll be getting yet another new bike.

Wednesday, July 04, 2007

Interviewed by Peter Duffy of the Chronicle Herald

Peter Duffy of the Chronicle Herald came by to interview me today after I emailed him about the content of one of his columns (specifically, about the "10 commandments for driving" that came out of the Vatican recently). We had a pleasant afternoon's chat while I regaled him with some of the tales of riding around Halifax on a bike; he seemed surprised at just how bad drivers are towards cyclists, so hopefully the article he writes will inspire at least one driver to stop and think that maybe saving 2 or 3 seconds' time driving isn't worth risking someone else's life over.

We also talked about Halifax Critical Mass, and Openstreetmap. If the article gets published on the web I'll put a link up on here for it.

3 and a half weeks until my medical house arrest is over. I have another appointment with the surgeon next week so I'll try to nail him down to a date I can get back on my bike - he should be able to tell by now if the shoulder's healed enough to say for sure. I still have to get my work bike down to IdealBikes for repair, too.