The Source for Java Technology Collaboration
User: Password:



Ron Hitchens

Ron Hitchens's Blog

The Core Problem: CPUs out the Wazoo

Posted by ronhitchens on May 10, 2007 at 06:19 PM | Comments (3)

Yesterday I attended Brian Goetz' Effective Concurrency For Java and today I went to the companion session Testing Concurrent Java. Both build on topics from Brian's excellent book, Java Concurrency in Practice, which first went on sale one year ago, right here at JavaOne.

Listening to these two sessions and chatting with a few folks here at the show, I'm more convinced than ever that concurrency is a looming problem that is, for the most part, going unrecognized.

As Brian pointed out, CPU speeds are leveling off. CPUs are not getting faster, they're getting fatter. In a matter of about a year, dual core CPUs have become the norm. I'm typing this right now on a dual core MacBook Pro. Quad core is becoming a reality in pro-sumer systems and sixteen core servers are not uncommon.

This sea change in the hardware space has many implications for we Java programmers. The first is the obvious one, that Java coders are going to have to get more sophisticated about concurrent techniques to get the most out of the runtime environments they will find themselves in.

But there's a flip side - a darker side, perhaps. A correct, single-threaded program will run fine on a multi-core machine, making use of only one CPU core at a time. But many single-threaded programs out there harbor undiagnosed concurrency bugs that never, or rarely manifest on single core CPUs. Here's a hint: finalizers are evil.

And then there are Java programs that are using multiple threads without well thought out locking strategies (or sometimes none at all!). On single core systems a tiny little race condition may never cause a problem. With more cores, more threads truly run in parallel, and more concurrency problems will come to light.

More cores means more broken code. Have you planned for it? Have you even thought about it? Will your code run properly under load on a system with 256 cores? Something to think about.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • 'Concurrent techniques' are hacks which in the long run seem to me unlikely to be workable. The problem calls for something of a paradigm change. You might want to check out, for example, Joe Armstrong's new Erlang book (in beta on pragprog) for a more interesting model.

    Posted by: johnprince on May 11, 2007 at 02:30 AM

  • okay, why are finalizers evil? I don't use them, I don't trust them, but that alone doesn't make them evil. What about multiple hardware threads make finalizers evil?

    BTW, Sun has hardware with 32 hardware threads, which is pretty much the same as a 32-core machine from a development standpoint.

    Posted by: naikrovek on May 11, 2007 at 06:59 AM

  • There are several dimensions to the evilness of finalizers. The one that applies here is that finalizers are run in a garbage collector thread. Any Java class that declares a finalizer is automatically multi-threaded. Objects that fall out of scope can be reaped en mass in a GC sweep and, with a multi-threaded garbage collector, many finalizer methods can wind up running concurrently.

    Posted by: ronhitchens on May 11, 2007 at 12:53 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds