Wednesday, March 5, 2008

Java Performance Talk

Paul Tyma and I gave a talk at SD West today on Java Performance Myths.

The big takeaway was this: Most of the things you think you know about Java performance are really hard to quantify. Write the best code you can. Profile it to find the bottlenecks. Remove the bottlenecks. Rinse and repeat.

A couple of other takeaway points here:
  • Don't forget to upgrade every so often. JDK6, for example, runs code compiled for JDK4 just fine, and you get a big performance boost. For free.

  • Memory allocation is pretty cheap. Know that there are three garbage collectors, and know which one is best, when. Read the Java memory management white paper.

  • Hotspot can do lots of things to optimize your locks, but it often doesn't. Having said that, the bottlenecks in concurrent code usually have to do with contention, not synchronization overhead. Use low contention data structures like ConcurrentHashMap to avoid contention, but don't try to get clever with locking.

  • Contrary to popular belief, thread-per-request synchronous servers are often faster than selector-based asynchronous servers.

The Java Performance Myths slides are here.

10 comments:

Anonymous said...

Great talk! One of the most informative on SD West, BTW.

Thank you for posting the slides.

L Swanson

Jeremy Manson said...

Thanks! We were happy to contribute! Well, that and they paid us.

Anonymous said...

This talk is really helpful for us, as we are dealing with memory management and performance problems in our application. Thanks for posting the slides also.
--Dilli Babu N

Mr President said...

I am unable to access the Java Perf Myths PPT.

Jeremy Manson said...

Yup. I'm having hosting problems. Sorry about that.

Shahbaz said...

@Even i too am not,could you please share it somewhere else or send to to my id.

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Unknown said...
This comment has been removed by the author.
Anonymous said...

HI!
Sorry but How Can I download the slides?
It say I don't have the permission!! :-(