Bug 151147 - [performance] WS-I validator is reloading the same WSDL file for each WSI assertion
Summary: [performance] WS-I validator is reloading the same WSDL file for each WSI ass...
Status: CLOSED FIXED
Alias: None
Product: WTP Webservices
Classification: WebTools
Component: wst.wsi (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: 1.5.1 M151   Edit
Assignee: Jeffrey Liu CLA
QA Contact: David Lauzon CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2006-07-19 17:46 EDT by Jeffrey Liu CLA
Modified: 2006-09-21 14:22 EDT (History)
2 users (show)

See Also:


Attachments
200KB WSDL file (254.11 KB, text/plain)
2006-07-19 17:50 EDT, Jeffrey Liu CLA
no flags Details
Patch for org.eclipse.wst.wsi (3.62 KB, patch)
2006-07-24 14:59 EDT, Jeffrey Liu CLA
no flags Details | Diff
Patch for org.eclipse.wst.wsi (7.44 KB, patch)
2006-07-24 15:51 EDT, Jeffrey Liu CLA
no flags Details | Diff
Patch for org.eclipse.wst.wsi (from Dave Lauzon) (6.83 KB, patch)
2006-07-25 11:28 EDT, Jeffrey Liu CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Liu CLA 2006-07-19 17:46:42 EDT
Build: Callisto 3.2

I opened a 200KB WSDL file in the WSDL editor. Once the editor is opened, the WSDL validator kicks in and validates the WSDL file. The WSDL validator in turn triggers the WS-I validator. Although the validation runs at the background. My Eclipse workbench is pretty much un-usable because the WS-I validator is using 100% of the CPU.

My observation is that the WS-I validator is reloading the same WSDL file each time an assertion is processed. I did a thread dump while the validator was running, here's the stack track for the WS-I validator:

"Worker-13" prio=6 tid=0x190e2cd8 nid=0xa80 runnable [0x1b82e000..0x1b82fa68]
        at org.apache.xerces.dom.ParentNode.internalInsertBefore(Unknown Source)
        at org.apache.xerces.dom.ParentNode.insertBefore(Unknown Source)
        at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
        at org.apache.xerces.parsers.AbstractDOMParser.characters(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanContent(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.eclipse.wst.wsi.internal.core.xml.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:144)
        at org.eclipse.wst.wsi.internal.core.xml.XMLUtils.parseXML(XMLUtils.java:323)
        at org.eclipse.wst.wsi.internal.core.xml.XMLUtils.parseXMLDocument(XMLUtils.java:167)
        at org.eclipse.wst.wsi.internal.core.xml.XMLUtils.parseXMLDocument(XMLUtils.java:146)
        at org.eclipse.wst.wsi.internal.core.profile.validator.impl.wsdl.AP2908.validate(AP2908.java:66)
        at org.eclipse.wst.wsi.internal.core.profile.validator.impl.BaseValidatorImpl.processAssertions(BaseValidatorImpl.java:311)
        at org.eclipse.wst.wsi.internal.core.profile.validator.impl.wsdl.WSDLValidatorImpl.processBindingAssertions(WSDLValidatorImpl.java:757)
        at org.eclipse.wst.wsi.internal.core.profile.validator.impl.wsdl.WSDLValidatorImpl.validate(WSDLValidatorImpl.java:225)
        at org.eclipse.wst.wsi.internal.core.analyzer.BasicProfileAnalyzer.validateWSDL(BasicProfileAnalyzer.java:377)
        at org.eclipse.wst.wsi.internal.core.analyzer.BasicProfileAnalyzer.validateConformance(BasicProfileAnalyzer.java:210)
        at org.eclipse.wst.wsi.internal.core.analyzer.Analyzer.validateAll(Analyzer.java:198)
        at org.eclipse.wst.wsi.internal.analyzer.WSDLAnalyzer.validateConformance(WSDLAnalyzer.java:158)
        at org.eclipse.wst.wsi.internal.validate.wsdl.WSDLValidator.validate(WSDLValidator.java:285)
        at org.eclipse.wst.wsdl.validation.internal.ValidationController.validateExtensionValidators(ValidationController.java:254)

I then did a little test by adding a System.out in the parseXMLDocument(...) method of XMLUtils.java. Results shows that the parseXMLDocument(...) method is called 601 times and each time it will reload the same WSDL file. My console output:

...

596
file:///D:/wtp_151_0712/runtime-New_configuration-build/d/200KB.wsdl
597
file:///D:/wtp_151_0712/runtime-New_configuration-build/d/200KB.wsdl
598
file:///D:/wtp_151_0712/runtime-New_configuration-build/d/200KB.wsdl
599
file:///D:/wtp_151_0712/runtime-New_configuration-build/d/200KB.wsdl
600
file:///D:/wtp_151_0712/runtime-New_configuration-build/d/200KB.wsdl
601

I suggest we cache the WSDL document at:

org.eclipse.wst.wsi.internal.core.profile.validator.impl.BaseValidatorImpl.processAssertions(BaseValidatorImpl.java:311)

and pass the cached WSDL document into each of the assertion.
Comment 1 Jeffrey Liu CLA 2006-07-19 17:49:16 EDT
The performance is bad enough that I think it deserves a P2 and we should fix it for 1.5.1. I'll attach the 200KB WSDL file. Btw, the WS-I validator took > 5 mins on my machine to validate the 200KB WSDL file.
Comment 2 Jeffrey Liu CLA 2006-07-19 17:50:00 EDT
Created attachment 46545 [details]
200KB WSDL file
Comment 3 Jeffrey Liu CLA 2006-07-24 14:55:11 EDT
I talked to Dave about this bug, he indicated that there should be some caching involved for the document. However, I couldn't find any. Basically, when XMLUtils is called, it will instantiate a org.eclipse.wst.wsi.internal.core.xml.jaxp.DocumentBuilderImpl, which does not have any caching build into it. Then this document builder will create an instance of org.eclipse.wst.wsi.internal.core.xml.dom.DOMParser, which again does not have any caching. I've created a patch that caches the document in the parser. I'll attach the patch, please review. Thanks.
Comment 4 Jeffrey Liu CLA 2006-07-24 14:59:30 EDT
Created attachment 46722 [details]
Patch for org.eclipse.wst.wsi
Comment 5 Jeffrey Liu CLA 2006-07-24 15:51:14 EDT
Created attachment 46723 [details]
Patch for org.eclipse.wst.wsi

Here's a better patch. We can be more efficient with BP2700 and BP2703.

BP2700 - Do not re-parse the WSDL if the validator already parsed it.

BP2703 - We don't have to re-parse the WSDL (and its schemas) for every matching namespace. We just have to do it once. So I added a couple of "break" statements after the WSDL (and its schemas) are parsed.
Comment 6 Jeffrey Liu CLA 2006-07-25 11:28:06 EDT
Created attachment 46761 [details]
Patch for org.eclipse.wst.wsi (from Dave Lauzon)
Comment 7 Jeffrey Liu CLA 2006-07-25 11:36:24 EDT
Dave, thanks for the patch. I have committed and released it to CVS.
Comment 8 Jeffrey Liu CLA 2006-09-21 14:22:07 EDT
verified and close.