JDK-8214537 : paint performance recedes in JDK 9 and above
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9,11,12
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2018-11-29
  • Updated: 2018-12-11
  • Resolved: 2018-12-11
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.
JDK 13
13Resolved
Related Reports
Duplicate :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
same result on different hardware and Windows 7

A DESCRIPTION OF THE PROBLEM :
paint works fine for versions up to 1.8.0_192 but degrades on recent versions e.g. 11.0.1.
paint method take 60(!) times longer to complete.

REGRESSION : Last worked in version 8u192

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and run using jdk1.8.0_192
(compile and ) run using jdk-11.0.1

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
similar performance for jdk1.8.0_192 and jdk-11.0.1

ACTUAL -
jdk-11.0.1 takes 60 times longer than jdk1.8.0_192


---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;

class GraphicsPaintPerformance extends Frame // javax.swing.JFrame
{
   int [] x = null;
   int [] y = null;
   
   public static void main( String [] args )
   {
      new GraphicsPaintPerformance();
   }
   
   GraphicsPaintPerformance()
   {
      int N = 20000;
      x = new int[N];
      y = new int[N];
      
      for( int i = 0; i < N; i++ )
      {
         x[i] = (int)( 500 * Math.random() + 50 );
         y[i] = (int)( 500 * Math.random() + 80 );
      }
      
      setSize( 600, 630 );
      setVisible( true );
      
      addWindowListener( new WindowAdapter()
      {
         public void windowClosing( WindowEvent we )
         {
            System.exit(0);
         }
      });
   }
   
   public void paint( Graphics g )
   {
      long start = System.currentTimeMillis();
      
      int n = x.length;
      for( int i = 1; i < n; i++ )
      {
         g.drawLine( x[i-1], y[i-1], x[i], y[i] );
      }
      
      g.setColor( Color.WHITE );
      g.fillRect( 250, 280, 100, 100 );
      
      
      g.setColor( Color.BLACK );
      g.drawString( 0.001 * ( System.currentTimeMillis() - start ) + " s", 280, 335 );
   }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
stay with jdk1.8.0_192

FREQUENCY : always



Comments
The problem is when display scaling is enabled, as mentioned in JDK-8212124, a different codepath is executed. When the scaling is set to 100%, the code executes similarly on all versions.
11-12-2018

Additional information from the submitter: =========================== the issue is probably related to JDK-8212124 ============================
07-12-2018

[~pardesha] I'm not able to see this issue with either 11 / 12. I tested on 1.8.131, 11 and 12, and observed that in all cases the time taken is around 1.2~1.4 seconds. Although 1.8 was faster, it wasn't like 60 times as mentioned.
03-12-2018

paint performance recedes in JDK 9 and above Reported as performance regression in JDK 9 and onward, paint method take considerably huge amount of time in comparison to JDK 8u. Checked this with reported versions and could confirm the results. Results: ========== 8u191: 0.766 9: 77.79 s 11: 71.43 s 12 ea b21: 81.64 s To verify, run the attached test case with respective JDK version. This can be considered as performance regression in JDK 9.
30-11-2018