title: Technique or utility to minimize Java "warm-up" time?
body: <p>I am supporting a Java messaging application that requires low latency (&lt; 300 microseconds processing each message). However, our profiling shows that the Sun Java Virtual Machine runs slowly at first, and speeds up after the first 5,000 messages or so. The first 5,000 messages have latency of 1-4 milliseconds. After about the first 5,000, subsequent messages have ~250 microseconds latency, with occasional outliers.</p>
  
  <p>It's generally understood that this is typical behavior for a Java application. However, from a business standpoint it's not acceptable to tell the customer that they have to wait for the JVM to "warm-up" before they see the performance they demand.  The application needs to be "warmed-up" before the first customer message is processed</p>
  
  <p>The JVM is Sun 1.6.0 update 4.</p>
  
  <p>Ideas for overcoming this issue:</p>
  
  <ol>
  <li>JVM settings, such as -XX:CompileThreshold= </li>
  <li>Add a component to "warm-up" the application on startup, for example by sending "fake messages" through the application. </li>
  <li>Statically load application and JDK classes upon application startup, so that classes aren't loaded from JARs while processing customer messages. </li>
  <li>Some utility or Java agent that accomplishes either or both of the above two ideas, so that I don't have to re-invent the wheel.</li>
  </ol>
  
  <p>NOTE: Obviously for this solution I'm looking at all factors, including chip arch, disk type and configuration and OS settings. However, for this question I want to focus on what can be done to optimize the Java application and minimize "warm up" time.</p>