United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4851535 {Float,Double}Buffer performance regression
4851535 : {Float,Double}Buffer performance regression

Details
Type:
Bug
Submit Date:
2003-04-21
Status:
Resolved
Updated Date:
2003-04-29
Project Name:
JDK
Resolved Date:
2003-04-29
Component:
core-libs
OS:
generic
Sub-Component:
java.nio
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
1.4.2

Related Reports
Backport:
Relates:

Sub Tasks

Description
There appears to have been a change in either the JAWT or the default AWT Canvas
properties on Windows in 1.4.2 (not present in 1.4.1_02) that is causing severe
performance degradation of Java applications using OpenGL through e.g. the
GL4Java library.

To reproduce, extract the attached archive. Add the jar files to your classpath
and place the .dll in your path. javac VertexArrayRange.java ;
java VertexArrayRange. Requires an NVidia GeForce family card, though the code
path in the demo which doesn't use the NVidia-specific extension also shows a
significant slowdown relative to 1.4.1_02.

The slowdown isn't affected by either the -Dsun.java2d.noddraw=true or
-Dsun.java2d.d3d=false flags. It also isn't affected by setting vs. not setting
the GraphicsConfiguration of the created Canvas (GL4Java's GLAnimCanvas class
subclasses Canvas).

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis-rc
tiger

FIXED IN:
mantis-rc
tiger

INTEGRATED IN:
mantis-b22
mantis-rc
tiger
tiger-b07


                                     
2004-06-14
WORK AROUND

None found yet except to revert to 1.4.1_02. This is why the priority has been
placed high; would otherwise have filed as P4.
                                     
2004-06-11
EVALUATION

Thanks to ###@###.###, ###@###.###, and most importantly the
Java2D build archives maintained by ###@###.###, have isolated
this to a performance regression in FloatBuffer and DoubleBuffer introduced
during the fix for 4804304. The root cause is the conversion of float <-> int
and double <-> long in the direct buffer case where byte swapping is not needed.
As a specific example, the generated sources in e.g. DirectFloatBufferU.java
currently look like

  public FloatBuffer put(int i, float x) {
    unsafe.putInt(ix(checkIndex(i)), (Float.floatToRawIntBits(x)));
    return this;
  }

where they should look like

  public FloatBuffer put(int i, float x) {
    unsafe.putFloat(ix(checkIndex(i)), x);
    return this;
  }

All of the get and put operations in the template files need to be
conditionalized on whether byte swapping is being done when deciding whether to
perform float <-> int and long <-> double conversions.

The attached FloatBufferPerformanceRegression.java illustrates the factor of
5 to 6 performance slowdown incurred by the unneeded conversion. This occurs on
both SPARC and x86 with both the client and server compilers so the priority
has been raised.

###@###.### 2003-04-21


Since the fix for 4804304 was apparently backported to 1.4.1_03 the fix for
this bug will need to be brought back as well.

###@###.### 2003-04-21
                                     
2003-04-21
SUGGESTED FIX

The webrev attached to this bug report describes the fix that will be
integrated into mantis-rc.  For convenience it is also available online
at http://nio.sfbay/rev/4851535/.

-- ###@###.### 2003/4/23
                                     
189-11-04 0



Hardware and Software, Engineered to Work Together