-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
8, 9
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
2.6.32-279.22.1.el6.x86_64
A DESCRIPTION OF THE PROBLEM :
Parsing of a large json using json lib is 3 to 6 times slower to run Java 8 compared to Java 6 on a 64 bit Linux machine.
REGRESSION. Last worked in version 8u60
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Parse a large json file using jsonlib: http://json-lib.sourceforge.net/
On a linux 64 machine running it on Java SE 8 is 3 to 6 times slower than Java SE 6. The example at the end took 10 seconds on Java 6 and 30 seconds on Java 8.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The performance should be identical on Java 6 and 8.
ACTUAL -
Java SE 8 is 3 to 6 times slower than Java SE 6.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import net.sf.json.JSONObject;
public class JsonLib {
public static void main(String [] args) throws Exception {
String jsonPath= "sample.json";
if (args.length > 0) {
jsonPath= args[0];
}
byte [] b = new byte[2048];
int len;
ByteArrayOutputStream bop = new ByteArrayOutputStream(8192);
InputStream ip = new FileInputStream(jsonPath);
while ((len = ip.read(b)) > 0) {
bop.write(b, 0, len);
}
ip.close();
String countryJson = new String(bop.toByteArray());
long start = System.currentTimeMillis();
for (int i = 0; i < 50; i++)
JSONObject.fromObject(countryJson);
long end = System.currentTimeMillis();
System.out.println("JSON PARSE TIME = " + (end - start));
}
}
Below is a list of jar files required. I can send/upload them and the sample json if needed.
json-lib-2.2.1-jdk15.jar"
commons-logging.jar
ezmorph-1.0.4.jar
commons-lang-2.3.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
junit-4.4.jar
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
After hitting this issue we have moved from jsonlib to jackson for parsing.
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
2.6.32-279.22.1.el6.x86_64
A DESCRIPTION OF THE PROBLEM :
Parsing of a large json using json lib is 3 to 6 times slower to run Java 8 compared to Java 6 on a 64 bit Linux machine.
REGRESSION. Last worked in version 8u60
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Parse a large json file using jsonlib: http://json-lib.sourceforge.net/
On a linux 64 machine running it on Java SE 8 is 3 to 6 times slower than Java SE 6. The example at the end took 10 seconds on Java 6 and 30 seconds on Java 8.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The performance should be identical on Java 6 and 8.
ACTUAL -
Java SE 8 is 3 to 6 times slower than Java SE 6.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import net.sf.json.JSONObject;
public class JsonLib {
public static void main(String [] args) throws Exception {
String jsonPath= "sample.json";
if (args.length > 0) {
jsonPath= args[0];
}
byte [] b = new byte[2048];
int len;
ByteArrayOutputStream bop = new ByteArrayOutputStream(8192);
InputStream ip = new FileInputStream(jsonPath);
while ((len = ip.read(b)) > 0) {
bop.write(b, 0, len);
}
ip.close();
String countryJson = new String(bop.toByteArray());
long start = System.currentTimeMillis();
for (int i = 0; i < 50; i++)
JSONObject.fromObject(countryJson);
long end = System.currentTimeMillis();
System.out.println("JSON PARSE TIME = " + (end - start));
}
}
Below is a list of jar files required. I can send/upload them and the sample json if needed.
json-lib-2.2.1-jdk15.jar"
commons-logging.jar
ezmorph-1.0.4.jar
commons-lang-2.3.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
junit-4.4.jar
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
After hitting this issue we have moved from jsonlib to jackson for parsing.
- duplicates
-
JDK-7197183 (str) String.substring and String.subsequence performance slower since 7u6
- Closed
- relates to
-
JDK-6924259 Remove String.count/String.offset/String.hashcode
- Closed