Bug 139092 - CMDocumentManagerImpl.getCMDocument(....) is taking too much time loading the same dtd file , its not caching it.
Summary: CMDocumentManagerImpl.getCMDocument(....) is taking too much time loading the...
Status: CLOSED DUPLICATE of bug 266683
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 1.5   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: Future   Edit
Assignee: wst.xml-triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2006-04-27 18:45 EDT by Raj Mandayam CLA
Modified: 2010-02-24 13:13 EST (History)
10 users (show)

See Also:


Attachments
patch (5.20 KB, text/plain)
2006-04-28 16:14 EDT, Raj Mandayam CLA
thatnitind: review-
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raj Mandayam CLA 2006-04-27 18:45:18 EDT
1.5 wtp april 21

In a large project with 200 jsp/html.
I ran validation 

It took a lot of time
almost 300 seconds
out of which time is spent 120 seconds in XHTMLAssociationProvider.getXHTMLCMDocument(..)

here is the breakup

Name 	 Time (ms) 
	 org.eclipse.wst.html.core.internal.modelquery.XHTMLAssociationProvider.getXHTMLCMDocument(String, String)
	119,851	100 %
		 org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.getCMDocument(String, String, String)
	117,642	98 %
			 org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.loadCMDocument(String, String, String, boolean)
	113,341	95 %
			 org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.lookupOrCreateResolvedURI(String, String)
	4,151	3 %
			 org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.getPropertyEnabled(String)
	80	0 %
			 org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache.getStatus(String)
	70	0 %
		 org.eclipse.wst.xml.core.internal.modelquery.XMLCatalogIdResolver.resolve(String, String, String)
	2,209	2 %

I can send files/projects if neccesary
Comment 1 Raj Mandayam CLA 2006-04-28 16:14:29 EDT
Created attachment 39827 [details]
patch
Comment 2 Raj Mandayam CLA 2006-04-28 16:14:49 EDT
I think I found the root of the problem, and I implemented a caching mechanism, that helped fix the problem for me.

Problem exists in CMDocumentManagerImpl and CMDocmentCache

the manager object is created too frequently and does not share the documents in its cache during validation.

Infact this cache is created, everytime a utility method is called ?

CMNodeUtil.getElementDeclaration(...)
    calls
       ...
CMDocumentManagerImpl.getCMDocument(String, String, String)
    calls...

loadCMDocument(....)

Cache should be shared across instances.

I created a cache of CMDocuments that are cleared after 60 seconds after the last reference to it.

That way I savefd 113 - 6 = 107 seconds

added a patch
Comment 3 David Williams CLA 2006-05-13 21:51:29 EDT
Nitin, can you apply that "soft reference" pattern here, that you used in TLD Document manager? 
Comment 4 Raj Mandayam CLA 2006-09-18 18:07:35 EDT
Nitin, did you get a chance to look at this defect ? Its been open for a long time
just upping severity so that you can take a look at it.
Comment 5 Nitin Dahyabhai CLA 2006-09-18 18:17:20 EDT
Lowering back to major after discussing with Raj.
Comment 6 Raj Mandayam CLA 2006-10-17 15:29:03 EDT
Wow, this problem has such a performance impact. Can you look into its viability for WTP 1.5.2

This affects html validator running on a large workspace with 2-3000 html files
Comment 7 David Williams CLA 2006-10-17 17:04:46 EDT
Let's activetly investigate for 1.5.3. 
I don't like "timed caches" as proposed, but there should be other options available ... and, perhaps, a timed cache would be acceptable here? 

Comment 8 David Williams CLA 2006-11-16 11:47:32 EST
This seems a valid hot bug request for 1.5.3. 

Nitin, please investigate and review patch. 

Thanks. 
Comment 9 Nitin Dahyabhai CLA 2007-01-29 10:46:21 EST
Raj, would be alright moving this to 2.0?  We already have a 1.5.3 RC in place and I don't quite have this solved correctly.
Comment 10 Raj Mandayam CLA 2007-01-29 13:24:39 EST
thats ok
Comment 11 Nitin Dahyabhai CLA 2007-02-14 22:40:15 EST
fixed
Comment 12 Craig Salter CLA 2007-06-04 15:08:00 EDT
We're seeing some regression around this change and I'm looking for an alternative approach to solve this.  Am I correct to assume that we're mainly concerned with validation performance? 
Comment 13 David Williams CLA 2007-06-10 16:08:32 EDT
I am re-opening this bug, as I think it is on the verge of being reverted, due
to bug 190548. That way "listeners" to this bug can review what's going on in bug 190548.


I suspect part of the long term solution is better specifying the API for "getting" content models ... such as if you "get" the model, you must hold a reference to it if using any part of it. And/Or ... perhaps there's some fancy "re-create" options that could be done under the covers if part of a content model discovers its parent had been GC'd. 

Comment 14 Gary Karasiuk CLA 2008-07-14 14:40:50 EDT
Any update on this? 
Comment 15 Nitin Dahyabhai CLA 2008-07-16 23:58:29 EDT
Correct caching will either require some sort of arbitrary timer (ick) or a reworking of the framework to track usages, neither of which will be done in the short term.
Comment 16 David Carver CLA 2009-09-02 21:46:48 EDT
ping long term is here. :)
Comment 17 Ian Tewksbury CLA 2010-02-23 10:54:15 EST
This bug confuses me, from what I can tell both #loadCMDocument use the CMDocumentCache and this cache has recently been updated to clear itself when low memory events get sent out. 

So Nitin, what is the actual status of this bug?
Comment 18 Nitin Dahyabhai CLA 2010-02-23 23:32:11 EST
(In reply to comment #17)
> So Nitin, what is the actual status of this bug?

Your take is as good as mine at this point.
Comment 19 Valentin Baciu CLA 2010-02-24 11:54:42 EST
I think some of this was solved in the HTML layer with the cache Nitin put in late in WTP 3.0.*.

Recently, Gabriel is working on a global CM document cache. See bug 266683. So I'm thinking we can either close or dup this to bug 266683.
Comment 20 Nick Sandonato CLA 2010-02-24 13:13:32 EST
Thanks for your analysis. Duping against Bug 266683.

*** This bug has been marked as a duplicate of bug 266683 ***