JDK-8136399 : json lib is slow on Linux 64 Java 8
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-09-09
  • Updated: 2016-02-02
  • Resolved: 2015-11-16
Related Reports
Duplicate :  
Relates :  
Description
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.


Comments
JDK 1.8.0 results ----------------------- PARSE TIME for run 0-10 = 34970 PARSE TIME for run 10-20 = 5102 PARSE TIME for run 20-30 = 4630 PARSE TIME for run 30-40 = 4091 PARSE TIME for run 40-50 = 4468 Total time = 53262
29-09-2015

Attached are the files for the Test case provided by the submitter. The parsing time has increased with JDK 8u60 and 9 . Following is the response with the various JDK versions: JDK 1.6.0 PARSE TIME for run 0-10 = 8236 PARSE TIME for run 10-20 = 1531 PARSE TIME for run 20-30 = 1477 PARSE TIME for run 30-40 = 1482 PARSE TIME for run 40-50 = 1537 Total time = 14263 --------------------------------------------------------------------------------------------------------- JDK 1.7.0 PARSE TIME for run 0-10 = 11204 PARSE TIME for run 10-20 = 1015 PARSE TIME for run 20-30 = 809 PARSE TIME for run 30-40 = 1092 PARSE TIME for run 40-50 = 767 Total time = 14887 ---------------------------------------------------------------------------------------------------- JDK 1.8.0_60 PARSE TIME for run 0-10 = 16713 PARSE TIME for run 10-20 = 4674 PARSE TIME for run 20-30 = 4651 PARSE TIME for run 30-40 = 5029 PARSE TIME for run 40-50 = 4118 Total time = 35186 ----------------------------------------------------------------------------------------------------- JDK 1.9.0 PARSE TIME for run 0-10 = 12136 PARSE TIME for run 10-20 = 4917 PARSE TIME for run 20-30 = 5134 PARSE TIME for run 30-40 = 5440 PARSE TIME for run 40-50 = 4908 Total time = 32535 Moving to dev-team for further analysis.
11-09-2015