title: Why is the newer/faster Java 8 way of sorting acting worse?
body: <pre><code>List&lt;Point&gt; pixels = new ArrayList&lt;&gt;(width * height); // 1280*960
  
  for (int y = 0; y &lt; height; y++)
      for (int x = 0; x &lt; width; x++)
          pixels.add(new Point(x, y));
  
  // Java 7 sorting
  Collections.sort(pixels, comparator);
  
  // Java 8 sorting
  pixels = pixels.stream().parallel().sorted(comparator).collect(Collectors.toList());
  </code></pre>
  
  <p>When using any sorting method, I get slow performance at first and it improves later. I expect this, because the JIT compiler needs time to optimize the high-use code.</p>
  
  <p>The weird thing is, the old sorter is a little slow at first, while the new sorter much more so, more than 60% slower. After a while, the new sorter becomes faster, as expected. But the way that the first two/three executions are so slow is simply unacceptable.</p>
  
  <pre><code>Java 7 collection sorter
  0.258992413
  0.265509443
  0.536536068
  0.117830618
  0.136303916
  0.111004611
  0.134771877
  0.108078261
  
  Java 8 stream sorter
  0.631757108
  0.868032669
  0.076455248
  0.087101852
  0.070401965
  0.056989645
  0.072018371
  0.078908912
  0.074237648
  </code></pre>
  
  <p>Specs:<br/>
  CPU: Intel I7 3770 (8-core 8M/1M/128K cache)<br/>
  cmd: javaw -server -cp bin Myclass</p>
  
  <ul>
  <li>Has anyone else experienced worse performance of newer (stream) operations?</li>
  <li>Is there a way to fix this slowness? (without inducing start-up delays)</li>
  </ul>