Java 7 sorting "optimisation"

Viewed 777

In Java6 both quicksort and mergesort were used in Arrays#sort, for primitive and object arrays respectively. In Java7 these have both changed, to DualPivotQuicksort and Timsort.

In the source for the new quicksort, the following comment appears in a couple of places (eg line 354):

 /*
  * Here and below we use "a[i] = b; i++;" instead
  * of "a[i++] = b;" due to performance issue.
  */

How is this a performance issue? Won't the compiler will reduce these to the same thing?

More broadly, what is a good strategy for investigating this myself? I can run benchmarks, but I'd be more interested in analysing any differences in the compiled code. However, I don't know what tools to use etc.

3 Answers
Related