Dennis Forbes on Pragmatic Software Development
Subscribe to RSS
 
Monday, July 16 2007

Cueing Up An Ad

"Come here and see this cool PBS promo that was just on!" I call to my wife, tapping pause on the PVR's remote. Given my history of calling her in for replays that weren't as hilarious or amazing as I originally imagined them to be, I knew this had to be a slick presentation if I wanted to impress with my PVR-fu.

As she enters the room the PVR finally reacts to my command, pausing, but then immediately playing again: Once again I've been caught out hitting the button twice, assuming that the first request got lost in the ether -- as often happens -- when it didn't seem to respond in a timely manner.

I hit pause again and this time it immediately reacts, coming to a halt.

"I just have to cue it up," I say, buying some time.

I tap rewind. Nothing happens. Come on, I think, I've got an impatient audience here! I tap it again, and the box launches into double speed rewind as I race for the play button. It plays on demand, but now it's several minutes before the desired start point.

Repeat.

Unpredictably high user interface latency strikes again. While this Motorola PVR is an exceptionally bad culprit for random non-responsiveness, it's hardly the only example of this seemingly growing trend.

User Interface Lag

My Moto Q smart phone is a great little device that I really enjoy, but the user interface responsiveness is enormously uneven, frequently lagging several seconds behind commands. Whether waiting for it to complete an application switch, or even during basic interactions such as entering a URL in the address bar of Pocket Internet Explorer, it's often out to lunch.

Presumably the questionable multitasking of Windows Mobile completely blocks the user-interface thread when it decides to chatter with a cell tower. Nothing else can explain its behaviour.

On startup my DVD player apparently needs to initialize its own little operating system, and if there's a disc in the drive it automatically demands that it determine the contents before it will eject. It insists that it be able to put "DVD" on the front-panel before any other activity occurs, achieving silicon self-satisfaction that it accurately determined the media type.

A common scenario has us getting ready to leave the house, preschool children bubbling with energy, when we realize that we have a disc that we should return to the movie store.

Turn on the entertainment unit. Wait for DVD to pre-power initialize. Hit eject on the front panel (which automatically turns the unit on). Wait as DVD player initializes and then unnecessarily spins up the disc in the drive to read the disc type and root menu.

Finally it ejects.

It isn't just household devices that show this worrisome trend. The bank recently "upgraded" their ATM machines, bringing a colourful, graphical façade to what was once an glowing-green, ASCII, very serious interface. What once was a quick navigation through the menus now sees the painful redrawing of screens and laggardly keystroke responses.

Seconds Add Up To Minutes Add Up To Hours Add Up To...

It might only be 10 seconds or so from beginning of DVD eject procedure to the actual ejecting of said optical disc, but that's approximately 9.75 seconds more than it needs to be.

When time is short, even small delays like this can be incredibly irritating.

Despite the increasing computational capacity of our devices, the problem seems to be getting worse. User interface responsiveness seems to lie low on the list of priorities in many contemporary electronic devices.

These devices seem to be growing slower and slower, yet the processors that power them are getting dramatically more powerful.

A Supercomputer in Your Hands

Slashdot recently had a story linking to some reviews of a new Windows Mobile 6 smartphone. Several of the comments provided variations of the argument that the primary weakness noted in the review -- poor performance -- was the result of "underpowered" hardware.

Throw some more hardware at it and everything would be okay, the argument goes.

Consider that for a moment: is hardware really the problem? My Moto Q -- a device that often demonstrates terrible responsiveness (I'm not trying to pick on Motorola -- I've noticed the same behaviour with Nokia and Audiovox phones) -- is powered by an Intel XScale PXA272 processor running at 312Mhz. It comes with 64MB of RAM, 128MB of flash memory, and I've supplemented it with 1GB of miniSD flash storage.

Is that an insufficient bit of hardware to manage the awesome tasks of a smartphone with a 320x240 screen?

As a point of historic comparison, in the late 80s I was a proud owner of an Atari 520ST. It was a multimedia powerhouse powered by an 8Mhz Motorola 68000.

Despite what now is a laughably anemic CPU, it seemed infinitely capable at the time: I used it to create complex reports for high school in a full featured desktop publishing app. I did hobbyist software development in a rich IDE on it. I wasted away countless hours trolling local BBS'. It even was a wonderful game platform, running richly challenging games with gusto (games far more advanced than what you often find running in J2ME on your cell phone).

Later I upgraded to the Atari 1040STE, still with the same 8Mhz 68000, but offering expansion capacity to bring it up to a colossal 4MB of memory. This was so much memory that I usually created a memory "disk" out of 3MB of it, and still never felt limited in the 1MB.

Seldom did my ST ever feel laggy or non-responsive -- it booted close to instantly from ROMs, and the simple UI was always extremely responsive. Demo programmers had it doing tricks that still impress me to this day. Later a UNIX-style OS was ported to it, including full pre-emptive multitasking.

So how does that relic of the past compare with something like the Moto Q? Comparing straight Mhz isn't a valid comparison (for instance the ST is a CISC processor, versus the RISC XScale), so I went searching and found some Dhrystone 1.1 benchmark numbers for both the XScale at 312Mhz and the 8Mhz 68000.

8Mhz 68000 (Atari ST) - ~1,603 Dhrystones / second

312Mhz XScale PXA272 - ~731,512 Dhrystones / second

On this benchmark the PXA272 in the tiny little smartphone on my belt (yeah, I'm a nerd) is equal to 456 Atari STs. Let's look at that in a bar graph in case it isn't clear enough.

8Mhz 68000 1,603 Dhrystones / second
312Mhz XScale PXA272 731,512 Dhrystones / second

Wow.

Memory wise the Moto Q has a virtually infinite amount of memory compared to my old Atari ST.

I'm not trying to pretend that the ST of old did what a PDA of today is doing: I remember first getting access to low resolution JPEGs on a local BBS (I was a teenager and they were swimsuit photos...pretty risqué at the time. This stuff was much tamer than an issue of Maxim magazine or an "Umbrella" video), having to go through the tedious process of first "decompressing" them to a TGA, waiting as the decompression processed for sometimes minutes, and then viewing the uncompressed image. There was no way it could realtime do something as complex as rendering a JPEG.

Yet considering this enormous increase in computational power, it does seem evident that many device developers aren't respecting the time of their users, and few users are calling out terrible interfaces for being unresponsive and disrespectful. Reviewers, in particular, seem blind to responsiveness when rating devices, presumably because the artificial environment of a review can't be compared to quickly trying to respond to an email while standing in an airport terminal just as the last boarding call is made.

The Basics of a User Interface

A user interface should be predictable and consistent -- it should always respond in a short, consistent amount of time (I would honestly feel that the PVR would be better if it always took 3 seconds to react to a command, versus now when it's anywhere between 0 and 5 seconds), always allowing the user to cancel operations that they're no longer interested in.

Responding to the user's input should always be job #1.

Wednesday, July 18 2007

I've written about energy conservation issues several times on this blog and in its precursor rants section. This is a topic that is pertinent to the economics of the hardware upon which we ply our trade.

I was advocating compact fluorescent lightbulbs six years ago, and have documented my family's power usage along with some of the steps we've taken to reduce it.

We turn off the (100% CF) lights when we don't need them, intelligently bank cooler outdoor air on summer nights to limit air conditioning, and we try to conscientiously reduce the energy we're using. When we buy electronics and appliances, the Energy Star rating tops our criteria list.

raspberries

This year we even marginally supplemented our food purchases with the produce of a humble home vegetable garden (doing our very small part to reduce the energy used to grow and transport it from elsewhere, not to mention that a small patch of once slow-growing grass now hosts fast-growing, carbon-trapping vegetables).

We are far from a great example of a carbon-neutral lifestyle, however. As I write this my wife and children are travelling in our fuel-guzzling, 5000lb 255hp minivan to a children's museum some two hundred kilometers away. We don't forsake modern conveniences like televisions and gaming systems, and of course I wouldn't go without my computers. We live in a suburban home, adding to suburban sprawl, and often commute long distances.

Compared to an urban dweller living in a tiny condo, commuting to work via the foot express, we're gluttonous power pigs. We're lazy environmentalists of convenience.

It's this pragmatism that has me questioning a lot of the enviro-nonsense that has become a religion as of late. Many, it seems, feel a perverse, corrupting need to polarize their position -- as has sadly become the norm in many areas of debate -- simplistically categorizing everything into absolute right or wrongs.

Often there are only grays.

The 10,000 mile Diet

Buying local, for instance, is a meme that has taken hold in enviro-circles. Simply ensuring that whatever plastic junk you're buying wasn't shipped overseas, and that your strawberries didn't come from California (or, if you're in California, that they didn't come from wherever else grows strawberries) and you're doing your part to save the Earth, the meme goes.

Is that true?

If one only considers final shipment, then local farmers have an obvious enviro-advantage. Yet that energy analysis seems simplistic: What if the alternative is grown on larger farms with a longer, more suitable growing season? What if the economy of scale of remote growers allows for increased automation and efficiency?

Is it really saving the environment if you're buying from small, labour- and energy-intensive farms where crops have to be coerced through the short growing season via considerable energy and chemical assistance? Where the ill-suited soil needs continuous supplementation?

I'm not providing answers -- I don't have the numbers -- but the energy that goes into making the foods that you eat and the products that you buy is much more complex than simply measuring the fuel that went into the boat or truck that it rode to your grocery store. Given the low cost of large plastic toys from China, for example, it's clear by simple economics that very little energy was necessary to ship it across the ocean (and that might reduce further as shipping companies look to save costs).

False Smugity

Automobiles are another area of the whole environment debate that seems to be much more complex than often perceived. Consider the media's coverage of Al Gore the IIIrd, son of Al Gore the IInd, getting caught speeding down a California freeway at 100mph in a Toyota Prius. Many of the news reports described the car as "environmentally friendly", and this has been a recurring description when describing hybrid vehicles.

The Prius is "environmentally friendly" only by the same confused logic that would deem a lit M-80 "hand friendly" relative to a stick of dynamite.

The Prius still requires roadways (and contributes to the clogging of the same) and parking lots and rubber tire factories and mines. The perceived moral righteousness of the Prius and its ilk might even exacerbate the problem of urban sprawl, making people feel almost heroic to commute 40km to work in their "environmentally friendly" hybrid car. Worse, it still requires copious amounts of energy to move its 3000lbs around -- not least of which is a giant array of batteries -- often with a smug driver as the lone occupant, contributing to the growing trend of smug pollution (as South Park hilariously characterized it).

The sort of absurd moralism about hybrid cars -- the kind that has the media declaring a 3000lb car "environmentally friendly", and the rich and powerful can gain environment credibility by being sighted in a hybrid (just ignore the numerous mansions and private jets...they were seen in a Prius!) -- is how you end up with absurdist theater like this.

The Prius is but one example (and I don't mean to pick on hybrid cars. All else remaining the same they're a definite improvement. Definitely better than the hilarious large older car I saw roaring down the highway yesterday, prominent "Boycott Gas!" sticker on the back). Many recent stories have praised absurdly high mileage vehicles, deep in the article noting that much of the vehicle's energy was supplied via an unmeasured draw from a household electric socket. That's akin to claiming that your 1984 Chevy Citation gets great mileage by going half of its kilometers slung on the back of a tow truck. That sort of energy-fraud is becoming far too common.

The Law of Unintended Consequences

Consider also how the so-called law of unintended consequences rears its head when you improve the operating costs (both economic and moral) of an activity: A driver of a fuel-guzzling SUV is likely more apprehensive about long drives, knowing how the exorbitant fuel costs will punish their wallet. Reduce the moral and economic costs, however, by replacing their vehicle with a more efficient model, and suddenly longer commutes and family drives become acceptable again, completely negating any energy savings.

Here in Ontario the power grid's supply barely exceeds normal consumption: Decades of Not-In-My-Backyardism and cost cutting has the province importing power during peak loads. To reduce demand, reducing imports and staving off the building of expensive new power plants, the province has been offering rebates on energy star appliances, and direct rebates on things like LED Christmas lights. The latter makes for an interesting study: I suspect the super-efficient LED lights have many consumers bulking their Christmas display up with more lights, and then leaving them on longer. That is the rough conclusion of some small studies done on behalf of the utility, coming to the conclusion that the programs did nothing to reduce consumption. But it did help make for a more colourful Christmas display.

I don't pretend to know the answers, or to have all of the numbers to declare basic truths about energy consumption (other than "less overall is better than more overall"), but I do know enough to know that it's much more complex than the superficial, naive analysis commonly repeated.

  Personal 
Wednesday, July 18 2007
Friday, July 20 2007

I'm going through the process of upgrading some Infragistics NetAdvantage 2007 v1 components to 2007 v2, one step in the upgrade process being the uninstallation of v1. The uninstaller has now been running for some 65 minutes, saturating both the hard drive and the CPU during the entirety of that time.

What possible explanation is there for this? Remove some registrations, delete some files and directories. Done. Where's the big complexity?

"But it's doing complex things!" a friend of MSIEXEC might retort (this is hardly the first time I've encountered outrageous installer times). Like what? Calculating the next Mersenne Prime?

In the time that it has run it could read and written my entire hard-drive several times over, and from a computational perspective it has now processed trillions of CPU operations. Trillions.

Given the basic metrics, there is simply no rational explanation beyond absolutely mind-boggling inefficiency. Par for the course, unfortunately.

Monday, August 13 2007

Stuck in traffic a few days back, my idle mind wandered to the technical feasibility of pervasive, real-time traffic flow monitoring, and how this information could be communicated and utilized.

Such perfect, real-time information could help to redistribute the roadway load for the benefit of all (or, more realistically, let the suckers boil in the midday sun while the information insiders zip around congestion points), reducing transit times and energy use, and perhaps providing emergency services with optimized transport mapping, improving their efficacy.

Something had to be better than the sparse, time-lagged reporting of the radio station, or blindly rolling down an onramp, curious why a string of cars were dangerously reversing up the shoulder, to find the entire highway at a standstill, as I had that Friday afternoon.

There are quite a few implementation options apparent to a traffic layman like myself: Cameras with AI counting cars and estimating their speed. Underground (or overhead) magnetic sensors, or underground weight sensors. Laser relays for single lane roads.

The basic problem with such solutions, however, is that they tend to be expensive to install and maintain, and from that they tend to be infrequently deployed, at best spaced at distances that greatly reduce their utility (e.g. "between highway marker 70 and 112 there is some sort of disturbance"). Add to that the communications network required to relay these telemetrics.

Having worked in the telemetrics/remote monitoring industry before (in the late-90s), I was contemplating how cellular data technologies were just become feasible for such remote monitoring communications when the thought occurred to me: Most every cell phone now is constantly communicating digitally with its base station. Further, every cell phone can be either triangulated to a location, or more recently knows its precise position with the use of GPS. A tremendous percentage of cars on the road have at least one cell phone in them, the phone company (or anyone listening in on the conversation) capable of tracking location and speed, easily overlaying that over a mapping system to determine roadway flow.

Imagine an entire roadway system that overlaid the millions of cell phones moving around, easily visualization slow downs and congestion. It would be similar to the medical procedure where they inject radioactive particles into a patient's blood system, determining flow throughout the body by measuring their movement.

It turns out that I'm not the first to think of this. A quick Google search upon getting home made it apparent that there are several commercial products that do something similar. Nonetheless I thought it a fascinating example of passive data collection, deriving secondary advantages out of widely deployed technologies like cell phones.

  Personal 
Monday, August 27 2007

Summer is waning here in the Northern hemisphere. 

While it's sad that the warm weather and summer activities will soon be packed in the garage for another year, it's almost the time for fall fairs, rich soups, apple picking, walks in the gorgeous escarpment country when the leaves have changed color, pumpkins and costumes.

IMG_2741

'Tis a wonderful season ending, to be replaced by another great time of year.

With the decrease in outdoor activities, I'll be posting more frequently. I've been kicking SQL Server 2008 around, and look forward to writing about it (I'm excited about its new hierarchical functionality, which has echos of versatile high performance hierarchies), along with many other thoughts that have percolated in my head.

Tuesday, September 04 2007

A recent article on the utility of multiple cores has been making the rounds. Despite being largely a copy/paste of other articles and graphics, with a smidge of editorial commentary, it is anxiously heralded by dual-core owners as purchase justification in the face of progressing technology.

[As fair disclosure, let me say that I'm about to purchase a quad-core processor based system, and this article and its sources did absolutely nothing to dissuade me from this choice]

The meat of the article (or rather the articles that are referenced by the article -- someone else did the dirty, arduous footwork work of benchmarking) is comprised of a showdown between a 2.4Ghz quad-core and a 3.0Ghz dual-core, which is reasonable given that they're comparable in price [at writing the 3.0Ghz dual-core E6850 can be had for $384 CDN, while the 2.4Ghz quad-core Q6600 is $319 CDN]. Given that many games and applications are effectively single-threaded as a legacy of lowest-common denominator development, the faster clock speed dual-core processor abstractly takes the lead in such fundamentally synthetic benchmarks for the pricepoint.

Aside from the questionable "it's good to have one extra core to allow you to kill bad processes" premise (what if those bad processes are multithreaded? Do you just have to buy bad-process-threads+1 cores? Maybe set the affinity such that you've dedicated a core solely for the task manager? In the real world of modern schedulers, the only time you can't get control of the machine to kill a rogue process is because of some absolutely atrocious elements of the implementation of Windows, and a scheduler that is effectively broken in the face of some situations. Neither is necessarily improved by more cores), what really gets me about the whole exercise is how utterly synthetic it really is, using contrived benchmarks instead of rationally considering how people actually use their PCs, and where their real need for more power comes from.

Firstly, it largely focuses on games benchmarks. Even if gaming performance is pertinent to the reader, for the majority of users playing the majority of games, their video card is far more of a bottleneck than their processor (even if their processor is a dated affair). I'm saying this as a long time computer gamer -- one that finds the stuttering framerate on even top of the line game consoles intolerable: unless you've turned every quality setting to low and you're running at 800x600, it's doubtful that you're going to even measure, much less notice, a difference between a modern 2.4Ghz core and a 3.0Ghz core. Indeed, the very first benchmark I looked at on the referenced article says exactly that: "For this test, we set Oblivion's graphical quality to "Medium" but with HDR lighting enabled and vsync disabled, at 800x600 resolution". They did that to create a scenario where the differences are measurable.

So if you plan to game in a contrived way for the purposes of demonstrating CPU differences in benchmarks, then you'd better pay attention to core speed.

In the real world of gaming, after you've adjusted the quality and resolution settings to appropriate settings for your video card, the primary slowdowns during gaming tend to come about because of external applications rudely stealing your thread quanta: I'm about to toss the grenade into the bunker in Battlefield 2 when suddenly Windows Search has decided that this is a good time to rebuild its index corpus, for instance, so instead it falls to the ground and I take out my entire squad (Seriously, Windows Search guys - when a full-screen DirectX game is running, it probably isn't a good time to decide that the PC is "idle").

For moments like that, more cores make a huge difference. Dual-cores would be sufficient for that simple scenario, but what if my PC is even more active, as it always is? Perhaps the blog updater is running an update, I'm FTPing some files, a download is happening, and I'm gaming.

Every core works towards the ultimate goal of eliminating the real world problem of cycle theft from my hardcore gaming.

Presuming that you've passed a reasonable bar -- long behind you when you're talking about a 2.4Ghz Core 2 -- more cores will realistically improve things for gamers enjoying their vice in the real world. One day we might even have a world where we don't have to shut down services and trawl taskmanager violently killing processes before launching a game, fearful that it will disrupt our immersion.

My second problem with the article is that it doesn't question what people are really waiting for nowadays. Personally I see almost no difference between virtually any mainstream PC for the overwhelming majority of day to day operations (and this is as a developer) -- most activities are so fast the difference is negligible. I just switched laptops from a single-core 1.6Ghz Pentium M to one with a Core 2 Duo T7200 -- a significant improvement -- and from a day to day perspective I've indeed notice that the new laptop has a better screen, a faster harddrive, and much better graphics, but the computational difference is largely unnoticed.

Until, humorously, I do something that is highly parallelizable, such as encoding a video pulled in from the miniDV video camera. In that case the dual-core processor strides to a massive lead over its single core predecessor. If it were a quad-core, it would storm even further ahead, even with the loss of frequency.

For something that I'm actually waiting on, more cores = more goodness.

I would definitely choose the quad-core processor for the software reality legacy that we have today, despite the many applications that in the singular fail to exploit the possibility. My conviction is amplified by the tremendous strides that application developers are making to parallelize their products. Once you've parallelized to 2 cores, it's generally a very small step to parallelize to 4 cores, or n cores for that matter.

Bring on the cores!

Earlier EntriesLater Entries

Dennis Forbes - Dennis Forbes is a Toronto-based software architect and technology writer