JDK-6867515 : Reduce impact of D3D initializion on startup time
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-07-31
  • Updated: 2013-11-01
  • Resolved: 2011-04-14
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 6 JDK 7
6u18 b03Fixed 7Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
On systems where D3D pipeline is used its initialization may take significant fraction of startup time.
(on warm start it is up to 30% till applet.init() is called on my PC).
Refworkload tests shows it takes 180-200ms on my PC (see comments).

We knew that D3D had startup overhead when d3d support was added to JDK. There were efforts to reduce cost of d3d initialization and further reduction is likely to be complicated task. We should have another look though.

On other hand it does not seem that d3d initialization is CPU consuming. It seems to be mostly bound by necessity to communicate with OS and drivers.
So, perhaps it is possible to reduce total startup time by initializing D3D concurrently to other activities.

Some possible ideas (have not been prototyped/verified yet):
  a) change plugin to create embedded frame in parallel to processing cache data, initiating network downloads, etc.
  b) change d3d, to initialize minimum at first request and continue further init in the background. It must be finished before first draw to the screen
  c) change java launcher and awt, to start initializing d3d concurrently to VM initialization. Attach d3d initialization thread to VM later and use it as AWT's toolkit thread.

      In later case we may only launch this warm up thread under some circumstances (e.g. if it was explicitly requested). This is something to decide later on.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/jdk/rev/1f45c4c1f3a7
04-12-2010

EVALUATION Fix for 6891435 changed enabling/disabling algorithm for AWT warmup (see 6867515 evaluation for details).
19-10-2009

EVALUATION The fix adds support of warmup for UI stack that is performed in parallel to VM initialization (currently only D3D initialization on windows-i586). It is not CPU bound and therefore it does not interfere with VM init. Implementation launches new thread after VM starts and use it to perform warmup code (platform dependent). This thread is later reused as AWT toolkit thread as graphics toolkit often assumes that initialization was made on the AWT toolkit thread. The warmup only makes sense for UI apps and therefore it needs to be explicitly requested by passing -Dsun.awt.warmup=true property. This is always the case for plugin/javaws, so javaws/plugin always pass the property to the VM. Other UI toolkit settings can disable warmup: - if "-Dsun.java2d.noddraw=true" parameter is specified; - if "-Dsun.java2d.d3d=false" parameter is specified; - if "-Dsun.java2d.opengl=true" parameter is specified; if none of the "-Dsun.awt.warmup", "-Dsun.java2d.noddraw" "-Dsun.java2d.d3d", "-Dsun.java2d.opengl" parameters are specified: 1) "J2D_D3D" env. variable is tested; if it is set to "false", the warmup is disabled. 2) if "J2D_D3D" is not set, "J2D_D3D_PRELOAD" env. variable is tested; if it is set to "true", the warmup is enabled.
28-09-2009

EVALUATION D3D initialization may block execution for a while waiting for videoboard, etc. We should consider initializing D3D earlier, so it will be ready when needed and we will not waste time waiting for it.
07-08-2009