JDK-8227505 : SuperWordLoopUnrollAnalysis may lead to over loop unrolling
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,12,13,14
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: x86
  • Submitted: 2019-07-10
  • Updated: 2019-11-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
## Reproduce
Run the reproducer with:
  -1) java TestSuperWordOverunrolling
  -2) java -XX:-SuperWordLoopUnrollAnalysis TestSuperWordOverunrolling
---------------------------------
public class TestSuperWordOverunrolling {

    public static void main(String[] args) {
        double sum = 0.0;
        long start = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
            sum += execute(256);
        }
        long end = System.currentTimeMillis();
        System.out.println("sum = " + sum + "; time = " + (end - start) + "ms");
    }

    public static double execute(int num_iterations) {
        int M = 63;
        byte[][] G = new byte[M][M];

        int Mm1 = M-1;
        for (int p = 0; p < num_iterations; p++) {
            for (int i = 1; i < Mm1; i++) {
                for (int j = 1; j < Mm1; j++)
                    G[i][j] = G[i-1][j];
            }
        }

        return G[3][2];
    }
}
---------------------------------

## Symptom
1) java TestSuperWordOverunrolling
---------------------------------
sum = 0.0; time = 9360ms
sum = 0.0; time = 9345ms
sum = 0.0; time = 9376ms
sum = 0.0; time = 9389ms
---------------------------------

2) java -XX:-SuperWordLoopUnrollAnalysis TestSuperWordOverunrolling
---------------------------------
sum = 0.0; time = 5564ms
sum = 0.0; time = 5575ms
sum = 0.0; time = 5520ms
sum = 0.0; time = 5552ms
---------------------------------

## Analysis
The performance drop was caused by over loop unrolling with SuperWordLoopUnrollAnalysis.
For this reproducer, the loop was unrolled by 16, which was bad for the performance.
Comments
Updated RFR: https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-September/035012.html
16-09-2019

Here is my analysis: https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-August/034783.html Please review.
15-08-2019

Saw it late. Will review it soon.
14-08-2019

[~vdeshpande] Please, look on this.
06-08-2019

http://cr.openjdk.java.net/~jiefu/8227505/webrev.01/
06-08-2019

RFR: https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-July/034587.html
10-07-2019

Initial fix: http://cr.openjdk.java.net/~jiefu/8227505/webrev.00/ Effect: java TestSuperWordOverunrolling --------------------------------- sum = 0.0; time = 5568ms sum = 0.0; time = 5473ms sum = 0.0; time = 5532ms sum = 0.0; time = 5586ms ---------------------------------
10-07-2019