JDK-8214573 : Glyph layout performance degradation
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 9,11,12
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86_64
  • Submitted: 2018-11-29
  • Updated: 2018-12-09
  • Resolved: 2018-12-09
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 :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 8.1
Java 11.0.1

A DESCRIPTION OF THE PROBLEM :
Layouting text glyph vectors takes considerably longer in Java 11, compared to Java 8.
For example, use the attached source code(it is from another JDK bug, I am not the author).


REGRESSION : Last worked in version 8u192

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code on either all fonts in Fonts dir, or copy a smaller subset of fonts, e.g. "Arial" fonts to a different directory and run the code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
At least similar text glyph layout performance when comparing Java8 to Java 11.
ACTUAL -
Layout is slower 2-5 times.

Profiling for all fonts in Fonts dir.
In Java 11.0.1:
java.awt.Font.layoutGlyphVector 182s
sun.font.GlyphLayout.layout 182s
sun.font.GlyphLayout$EngineRecord.layout 180s
sun.font.SunLayoutEngine.layout 180s
sun.font.SunLayoutEngine.shape 180s

Java8:
java.awt.Font.layoutGlyphVector 73s
sun.font.GlyphLayout.layout 73s
sun.font.GlyphLayout$EngineRecord.layout 73s
sun.font.SunLayoutEngine.layout 73s
sun.font.SunLayoutEngine.nativeLayout 72s

For a font like Arial:
Java11.0.1:
c:\windows\fonts\arial.ttf;Arial; 493ms
c:\windows\fonts\arialbd.ttf;Arial Bold; 492ms
c:\windows\fonts\arialbi.ttf;Arial Bold Italic; 392ms

Java 8:
c:\windows\fonts\arial.ttf;Arial; 90ms
c:\windows\fonts\arialbd.ttf;Arial Bold; 91ms
c:\windows\fonts\arialbi.ttf;Arial Bold Italic; 89ms

The layout time difference is ~5 times.

---------- BEGIN SOURCE ----------
This is the code, that was previously used is bug description.
public class GVT
{
	//Adapt FONT_DIRECTORY for other OSs or specific folders with a selected sets of fonts ("Arial" and "Arial Unicode MS" highly recommended)
	private static final String FONT_DIRECTORY = "c:\\windows\\fonts\\";
	private static final int REPETITIONS = 5_000;
	private static final char[] TEXT = "X sosofts 0,0 Steffieie Y".toCharArray();
	private static final FontRenderContext FRC = new FontRenderContext(null, true, true);

	public static void main(String[] args) throws Throwable
	{
		System.out.println("Java " + System.getProperty("java.version") + " on " + System.getProperty("os.name") + "\n");
		for (File fontFile : new File(FONT_DIRECTORY).listFiles())
		{
			if (fontFile.toString().toLowerCase().endsWith(".ttf"))
			{
				Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(123f)
						.deriveFont(Collections.singletonMap(TextAttribute.KERNING, TextAttribute.KERNING_ON))
						.deriveFont(Collections.singletonMap(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON));
				System.out.print(fontFile.toString() + ";" + font.getName() + ";");
				long start = System.nanoTime();
				for (int i = 0; i < REPETITIONS; i++)
				{
					font.layoutGlyphVector(FRC, TEXT, 0, TEXT.length, 0);
				}
				System.out.println((System.nanoTime() - start) / REPETITIONS / 1000);
			}
		}
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No workaround

FREQUENCY : always



Comments
As per description, Layouting text glyph vectors performance has receded considerably in JDK 11 when compared to JDk 8. Checked this in Windows 10 with reported versions and could confirm this as a regression in JDK 9. Results: 8u191: OK - c:\windows\fonts\arial.ttf;Arial;129 9: Fail - c:\windows\fonts\arial.ttf;Arial;689 12 ea b22: Fail - c:\windows\fonts\arial.ttf;Arial;689 Comparatively, the layout is 3-5 times slower in JDK 9 and above when compared to JDK 8u.
01-12-2018