[JAXP-16] Performance issue in com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM Created: 08/Mar/07  Updated: 07/Feb/11  Resolved: 07/Feb/11

Status: Closed
Project: jaxp
Component/s: www
Affects Version/s: current
Fix Version/s: current

Type: Improvement Priority: Critical
Reporter: kohsuke Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: All
Platform: All

Attachments: File JaxbTest2.jps    
Issuezilla Id: 16


The constructor reads:

public SAX2DOM() throws ParserConfigurationException

{ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); _document = factory.newDocumentBuilder().newDocument(); _root = _document; }

but this is very slow, as DocumentBuilderFactory.newInstance() takes a
significant time to run, then newDocumentBuilder() takes even more time to run.

The whole effort is more or less wasted, because all you do is to create a empty
document, which internally just invokes new

I recommend either using a cached DocumentBuilder (synchronizing it shouldn't be
a problem, or use ThreadLocal), or given that this code is in the JAXP RI, hard
code JAXP RI's own Document class.

One of the JAXB users reported that this code alone is taking up more than 60%
of the entire unmarshalling processing.

Comment by kohsuke [ 08/Mar/07 ]

Created an attachment (id=5)
JProfiler profiler data file contributed by the user

Comment by kohsuke [ 08/Mar/07 ]

Also see http://forums.java.net/jive/thread.jspa?messageID=206299#206299 for the
relevant forum discussion.

Comment by Joe Wang [ 07/Feb/11 ]

Resolved in the fix for 6660724 (http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=7a552d1ebeec66b51d0ec77dba8c?bug_id=6660724)

Generated at Tue May 05 15:41:14 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.