JDK-7057459 : Regression: Performance degradation with java.beans.XMLEncoder
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2011-06-21
  • Updated: 2011-08-18
  • Resolved: 2011-08-18
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.
JDK 7 JDK 8
7u2 b03Fixed 8Fixed
Related Reports
Duplicate :  
Relates :  
Description
SYNOPSIS
---------
Performance degradation with java.beans.XMLEncoder

OPERATING SYSTEM
----------------
All

FULL JDK VERSION
----------------
JDK 7 (tested with b146)
Performance first regressed in either JDK 7 b65 or JDK 7 b66.
Degradation became worse in b71 or b72.
For JDK 6, became slightly worse in 6u25.  Not reproducible in 6u24.

REPRODUCTION INSTRUCTIONS
-------------------------
1. Compile the two attached Java classes.
2. Run "java JavaBeanXmlEncoder"

Comparison of results from 7b64, 7b66, and 7b72:

---- 7b64 ----
Encoding to a file .....
Total Time taken for Encoding as XML =   1032   in Millsecond
-------------

---- 7b66 ----
Encoding to a file .....
Total Time taken for Encoding as XML =   6141   in Millsecond
-------------

---- 7b72 ----
Encoding to a file .....
Total Time taken for Encoding as XML =   7954   in Millsecond
-------------

TESTCASE
--------
See attachments.

Comments
SUGGESTED FIX src/share/classes/java/beans/Encoder.java public PersistenceDelegate getPersistenceDelegate(Class<?> type) { PersistenceDelegate pd = this.finder.find(type); - return (pd != null) ? pd : MetaData.getPersistenceDelegate(type); + if (pd == null) { + pd = MetaData.getPersistenceDelegate(type); + if (pd != null) { + this.finder.register(type, pd); + } + } + return pd; }
22-06-2011

EVALUATION The root of cause is the 6380849 RFE: Automatic discovery of PersistanceDelegates. We added this ability similar to discovery of PropertyEditors and BeanInfos. It looks up for persistance delegates in the following order: - 1. custom delegate registered in the cache - 2. custom delegate via Reflection and register it in the cache (new behaviour) - 3. shared default delegate in the Metadata class Note that the most applications use default delegates. So we search for custom delegate via Reflection for almost all objects. It significantly reduces the performance. I suggest to modify the third step: we should register shared default delegate in the cache. It slightly increases a memory usage, but solves the problem with the performance. See Suggested Fix.
22-06-2011