-
Bug
-
Resolution: Won't Fix
-
P3
-
7
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:32:42 UTC 2011 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I noticed a 20% reduction in performance of some benchmarks. One shared property of the regressed benchmarks was that they both used ByteBuffers.
I then created some more targeted tests of ByteBuffers, simply putting and getting into them in a tight loop. The test was essentially:
byte[] data = 512*1024;
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.get();
}
And for puts:
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.put((byte) 0);
}
I then measured the average execution time for these to complete, in both Java 7, and a version of Java 6: java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)"
The difference in performance was striking:
Java 7 get() rate: 14.45 GiB / second
Java 6 get() rate: 21.78 GiB / second
Java 7 put() rate: 5.02 GiB / second
Java 6 put() rate: 9.69 GiB / second
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a test as described in the description, execute it using Java 7, then execute it using Java 6. Note the difference in runtime.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Performance on part or better in Java 7.
ACTUAL -
Performance was 2/3rds the speed for gets, and 1/2 for puts.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package org.cleversafe.benchmarks.processing;
import java.nio.ByteBuffer;
public class BugReproduce
{
public static void main(final String args[])
{
final byte[] data = new byte[512 * 1024];
long start = System.nanoTime();
for (int i = 0; i < 10000; i++)
{
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.get();
}
}
long end = System.nanoTime();
System.out.println("Execution took: " + (end - start) + " nanoseconds");
start = System.nanoTime();
for (int i = 0; i < 10000; i++)
{
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.put((byte) 0);
}
}
end = System.nanoTime();
System.out.println("Execution took: " + (end - start) + " nanoseconds");
}
}
---------- END SOURCE ----------
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:32:42 UTC 2011 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I noticed a 20% reduction in performance of some benchmarks. One shared property of the regressed benchmarks was that they both used ByteBuffers.
I then created some more targeted tests of ByteBuffers, simply putting and getting into them in a tight loop. The test was essentially:
byte[] data = 512*1024;
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.get();
}
And for puts:
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.put((byte) 0);
}
I then measured the average execution time for these to complete, in both Java 7, and a version of Java 6: java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)"
The difference in performance was striking:
Java 7 get() rate: 14.45 GiB / second
Java 6 get() rate: 21.78 GiB / second
Java 7 put() rate: 5.02 GiB / second
Java 6 put() rate: 9.69 GiB / second
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a test as described in the description, execute it using Java 7, then execute it using Java 6. Note the difference in runtime.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Performance on part or better in Java 7.
ACTUAL -
Performance was 2/3rds the speed for gets, and 1/2 for puts.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package org.cleversafe.benchmarks.processing;
import java.nio.ByteBuffer;
public class BugReproduce
{
public static void main(final String args[])
{
final byte[] data = new byte[512 * 1024];
long start = System.nanoTime();
for (int i = 0; i < 10000; i++)
{
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.get();
}
}
long end = System.nanoTime();
System.out.println("Execution took: " + (end - start) + " nanoseconds");
start = System.nanoTime();
for (int i = 0; i < 10000; i++)
{
final ByteBuffer buffer = ByteBuffer.wrap(data);
while (buffer.position() < buffer.limit())
{
buffer.put((byte) 0);
}
}
end = System.nanoTime();
System.out.println("Execution took: " + (end - start) + " nanoseconds");
}
}
---------- END SOURCE ----------
- relates to
-
JDK-7147987 Performance regression in ByteBuffer.{put,get}
-
- Open
-