Let's Get Threaded

Wednesday, September 13, 2006

Threading. It's the new frontier. At least, that's what all the cool articles say these days.

The premise is that we have these new fangled dual core chips, but our applications aren't taking advantage of all the horsepower available because we don't use enough threads. We need to use more threads, they say. We have to grab those chips by their cores and bend every transistor to the will of our application.

Imagine if your local government doubled the width of all the roads in your area, and car manufacturers followed up by doubling the size of all new cars. Would that be an improvement?

I'd argue that dual core CPUs allow hardware to finally catch up with today's common usage. I have twice as many processes running today as I did in the old days (when Moore's law allowed processes to keep up). I have streaming audio playing while I'm synching a smart phone and an MP3 player. I have a torrent client running at the same time my desktop search engine is indexing and my newsreader is aggregating. I have at least one virtual machine and Outlook running all the time, and in Vista, everyone will have desktop gadgetry doing whiz-bang animations and back flips in a sidebar.

The last thing we need in this scenario is some application to come along and crush all the background work with threads of its own. Most applications just need enough to keep the UI responsive and do a little work in between button clicks.

Share the processor, and your users will thank you.


Comments
vikram Wednesday, September 13, 2006
Hi Scott,
You are right when u say "Most applications just need enough to keep the UI responsive and do a little work in between button clicks" but when you need to do more than that then some time multi thread programming is better. Just think about a client operator chat system. I am currently working on such a chat system which uses sockets. If I do not use multi threaded program I might hang the clients machine because of my program.
So I would say yes most of the program do not need multi threaded programming but some do. So we should be very thoughtful on using multi threaded programs.
Thanks

scott Wednesday, September 13, 2006
Vikram:

Sure, we all need a few threads here and there. Some articles are talking about an extreme use of threads and turning every desktop application into a massively parallel computating engine. Most apps don't need that!
David Grant Thursday, September 14, 2006
Seriously, what prompted all of these multithreading articles?
In the last couple weeks I've seen a deluge of them, and a handful of naive programmers freaking out, acting like they'll be unemployed within the month if they don't master all things multithreading.

Go work on your single-threaded app skills, please...
Moz Thursday, September 14, 2006
Some things should just be fast. As fast as possible, and if that means threaded, then thread them.

There are times when I really wish that I could use all the processor performance that I have available. Making PhotoShop, Visual Studio, even Word multithreaded would be useful [1]. Some applications have lengthy delays imposed by the nature of the task and if multithreading can speed that up then go for it. What does annoy me is "background" tasks that don't suspend when there's a bottleneck - virus scanners that choke the disk, indexers that use 50% CPU when I'm trying to use 100%. But that's rude applications, so how many threads they use isn't really the problem.

It's bad enough that "add more memory" has stopped being a solution, don't make "buy a more powerful CPU" be the next thing we can't do. Photoshop is a particular bugbear for me, as it has the stupid 4GB RAM limit (and only recently escaped the 4GB file size limitation).

Broadly, my feeling is that if I do it then it should be threaded, but if it's automatic then it should only use "spare" capacity. I don't care if virus scanning and disk indexing take an extra few days to complete, but I get irritated if searching for a song means that sound playback stops. Or worse, hitting "generate web page" makes my image processing tool unusable until the web page is complete.

I've already bought a multi-threaded image processing tool (Bibble) that queues processing, uses threads and lets me keep working (and yes, both cores in my machine usually sit at 100% while I'm working on images). Being able to do that with Visual Studio would be useful, but instead I end up wating while it rebuilds the application before I can run it. Don't even ask about editing while the debugger is active (Jade had that in, oh, 1995). This is stuff that I'd happily pay for - I'll probably be buying a quad core Win64 box with 8GB or 16GB of RAM in the next 12 months, just as soon as that becomes useful to me.

[1] yes, I realise VS/Word already are. That's my point.
Eric D. Burdo Thursday, September 14, 2006
I think much of the hype for "multi-thread everything" comes from the recent quad-core and 8-core demos that Tom's Hardware and Anandtech have published.

I was talking with a friend of mine about this... and said much of the same things already said here.

Most apps don't need multiple processor capability. Some apps will, and they should be able to handle as many processors as available *and they can use!*. If there are 8 procs, and you can only realistically use 4, only use 4.

If you can use all 8, then go for it.

I think the 4 and 8 core machines will be more useful for running multiple applications instead of one or two apps that respond fast.
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!