Java Performance Services
Training, Seminars, Benchmarking, Tuning

Java Performance Tuning Course


Chania Crete, May 17-20, 2010


Sun Extreme Learning EXL-2025

Houston, December 1-4,2009
New York, December 8-11, 2009
Washington DC, January 5-8, 2010



San Francisco, January 11-14

Anti-if

I have joined Anti-IF Campaign

Calendar

««Nov 2009»»
SMTWTFS
1234
5
67
891011121314
15161718192021
22232425262728
2930

Performance Anti-Patterns

My Top Tags

                                       

Mailing List

My RSS Feeds








Proposed Anti-Pattern, Shot in the Dark

posted Monday, 10 July 2006

Proposed Anti-pattern

Name

Shot in the Dark

Most Applicable Scale

Application

Refactored Solution Name

Measure, don’t guess

Refactored Solution Type

Tooling, Training

Root Causes

Ignorance, Haste

Unbalanced forces

Management of Performance

Anecdotal Evidence

The problem sounds like it is…. I think it is caused by…...

 
Introduction

The purposed anti-pattern has been named “Shot in the Dark” after a conversation with Dr. Heinz Kabutz. As the name implies, Shot in the Dark describes the best efforts of a team attempting to correct a poorly performing application without the benefit of truly understanding *why* things are as they are.

 
Most Applicable Scale

Typically most performance problems are found after the application has been assembled. The discovery comes either shortly after the application has been assembled or more often then not, shortly after deployment into production. Consequently the most applicable scale for this purposed anti-pattern is Application.

 
Refactored Solution Name

The most useful refactored solution name is measure, don’t guess. Though those tasked to fixing the performance problem may come with educated guesses, they are guesses none the less. If the guess is correct, then the behavior of guessing is only re-enforced. More often then not the guess is incorrect. In these cases it is quite common that much time has been wasted fixing things that may not look right but were not at the root of the problem. The only real way to ensure to know what is causing the problem is to take a measurement. Without a measurement you are guessing.

 
Refactored Solution Type

The refactored solution type is to use tools to take measurements. As is the case with most tools, training is involved for tools to be effective.

 
Root Causes

The root causes include ignorance and haste. The first seems harsh but it refers to the lack of knowing either how to take or interpret measurements. Haste is a result of the timing of the discovery. If the application has been deployed then the deadline to fix the problem is yesterday. At this point in time it is too late for training. Without training and the knowledge that training provides, human nature dictates that developers will do what developers do and that is examine the code. However, an application is more then just code. An application is the sum total of the code, the environment in which it has been deployed, and the set of users that is services. If any element of this equation is missing then it becomes difficult to acquire useful measurements. Without any useful measurements, all that is left is a shot in the dark.

 
Unbalanced Forces

The unbalanced forces that lead to a shot in the dark is a total lack of performance management. The trap is that we are all trained and focused on performance. However that focus is often misguided. If one does not plan for performance then performance is often achieved by accident. This does not mean that one should optimize prematurely. All it says is that performance requirements need to be treated similarly to any other requirement.

 
  • Solid performance requirements need to be stated
  • One needs to think about and devise a plan for how performance requirements will be met.
  • If tooling is involved in measuring then training must be planned for in advance of when it is needed.

In each statement you can substitute the word performance for business and tooling for your favorite product you can see how reasonable (obvious) these statements are. So obvious that one has to wonder why performance is ever allowed to happen accidently.

 
 
Anecdotal Evidence
 

The anecdotal evidence is “The problem sounds like it is…., I think it is caused by….”. It is the inclusion of hedge words and phrases that should sound the alarm that you are about to take a shot in the dark. The only actions that should be taken in this case should be to take a measurement. A good measurement will remove the hedge words from these sentences.


 

tags:        




1. Richard Rodger left...
Tuesday, 11 July 2006 1:38 pm :: http://www.ricebridge.com

The most famous example being the replacement of all String concatenations in a Java program with unreadable StringBuffer.appends!

Net speed gain: 0.00001%


2. Kirk Pepperdine left...
Wednesday, 12 July 2006 9:31 pm

String to StringBuffer....indeed.. isn't this a classic case of I've not got a clue but this sounds good.


3. Michael Hüttermann left...
Thursday, 3 August 2006 1:55 pm :: http://huettermann.net

Did you ever looked into the class files? With Java 5 direct String concatenations with '+' will be transformed to StringBuilder.

Cheers.

Michael Java User Group Cologne


4. Stuart Moncrieff left...
Monday, 16 October 2006 4:27 am :: http://www.myloadtest.com/

I actually had an interesting Java performance problem on a web store recently that was solved with a simple 1 line code change. The application server was talking to a pricing engine running on another server with a simple home-grown socket-based protocol (not HTTP, RMI, CORBA etc).

Many calls were made for each order that was created, and the profiler said that the majority of time was being spent on the network, but the servers were connected with 1Gb ethernet and were sitting next to each other in the data centre. Ping times between the servers were tiny.

Eventually the lead Java developer figured out that the socket connection was being opened in an incorrect mode, and there was a superfluous flush() that caused a useless additional call over the network for every pricing request. Once this was worked out, the fix was trivial.

Cheers, Stuart. (www.myloadtest.com)