JDK-8062141 : Various performance issues parsing JSON
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-10-27
  • Updated: 2015-09-29
  • Resolved: 2015-02-05
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.
8u60Fixed 9 b50Fixed
Mostly the property handling seems to be a bottleneck. For small JSON objects, we have only 1-2 properties, but the findElement in PropertyHashMap then becomes a bottleneck.

For larger objects, the general property handling also takes time. The various JSON function are also implemented "by spec" for compliance and could use optimization work. Parsing/lexing JSON also takes a lot of time. We should probably add JSON to the code cache or serialize JSON objects or something.

One (rather messy) way to do it, is to treat constant property map literals for JSON such as the FieldObjectCreator does -generate bytecode with putfields. 

Hannes says: I think for property maps the key is to use spill - we can populate the object much easier, and accessors are cached already (Marcus comments: but all defineOwnProperty that JSON.parse does already create spill properties?) 

Hannes also says: well we use the ScriptObject API. We should use some bulk methods to create properties and maps. (good idea)

Now with my concat fix checked in you can use 


as a JSON benchmark. All it does is parse assorted JSON in various forms.