Bug 136400 - NextCatalog.getReferencedCatalog() takes a lot of time computing constant information
Summary: NextCatalog.getReferencedCatalog() takes a lot of time computing constant inf...
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5 RC5   Edit
Assignee: David Williams CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords: greatbug
Depends on:
Blocks:
 
Reported: 2006-04-12 14:06 EDT by Raj Mandayam CLA
Modified: 2006-11-28 15:58 EST (History)
2 users (show)

See Also:


Attachments
patch to make reduce repeated resolution of the 'nextCatalog' (1.44 KB, patch)
2006-05-10 15:20 EDT, Craig Salter CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raj Mandayam CLA 2006-04-12 14:06:10 EDT
We are using wtp 1.5 in a large plugins related project

When you run validation on a web project with 200 jsp's and html files

The HTML validator spends nearly 22 seconds out of the 80 seconds it takes to validate in the

method NextCatalog.getReferencedCatalog()

Name 	 Time (ms) 
	 org.eclipse.wst.xml.core.internal.catalog.NextCatalog.getReferencedCatalog()
	22,255	100 %
		 org.eclipse.wst.xml.core.internal.catalog.CatalogElement.getAbsolutePath(String)
	19,043	86 %
		 org.eclipse.wst.xml.core.internal.catalog.CatalogSet.lookupOrCreateCatalog(String, String)
	3,152	14 %



On looking at this method, the code does

public ICatalog getReferencedCatalog()
  {
    return ((Catalog)ownerCatalog).getCatalogSet().lookupOrCreateCatalog(getId(), getAbsolutePath(location));  
  }

The call to the method getAbsolutePath(location) where location is always a constant value "default_catalog"

You can retrieve it in and store it in a instance variable the first time.

On doing that this method took only 60 milliseconds

here is the change

private String absolutePath;


public String getCatalogLocationAbsolutePath()
  {
     if (absolutePath == null) 
		absolutePath = getAbsolutePath(location);
	

	return absolutePath;
  }

  public ICatalog getReferencedCatalog()
  {
    return ((Catalog)ownerCatalog).getCatalogSet().lookupOrCreateCatalog(getId(), getCatalogLocationAbsolutePath());  
  }

Let me know if you need any more profiling information.
Comment 1 Craig Salter CLA 2006-04-12 14:29:16 EDT
Interesting.  Definitely sounds like a bug. I'm buzy this week but I'll dig into this next week (and if someone else want's to solve this sooner be my guest).  Feel free to send me a nag note if you haven't seen any actitivy on this by the end of next week.
Comment 2 Raj Mandayam CLA 2006-04-21 17:27:13 EDT
(In reply to comment #1)
> Interesting.  Definitely sounds like a bug. I'm buzy this week but I'll dig
> into this next week (and if someone else want's to solve this sooner be my
> guest).  Feel free to send me a nag note if you haven't seen any actitivy on
> this by the end of next week.
> 
Hi Craig, 

   Any progress. The fix seems safe, and as we had looked in all of the invocations, getAbsolutePath(location) seems to remain the same value, so can be stored lazily in an instance variable as shown below.
Comment 3 Craig Salter CLA 2006-04-21 20:24:59 EDT
I think I have a performance fix for this one. As I mentioned in bug 136399 having examples and JUnit would help me verify.  Raj, I assume the same tests/test-cases for 136399 would apply to this one too.  
Comment 4 Craig Salter CLA 2006-05-10 15:20:27 EDT
Created attachment 41007 [details]
patch to make reduce repeated resolution of the 'nextCatalog'
Comment 5 Raj Mandayam CLA 2006-05-23 10:28:28 EDT
Hi Craig,

   Cool ! This patch fixes the problem. I verified it in target -> WTP 1.5 RC3 and org.eclipse.wst.xml.core checked out from the CVS repository with the patch applied.

Validation on the project went down from 115 seconds to 67 seconds

with the method getReferencedCatalog taking 42 seconds to 0 seconds

Please get it in WTP/RAD builds soon.

Thanks
Raj
Comment 6 Craig Salter CLA 2006-05-31 02:22:11 EDT
Setting target milestone to RC5.  This is a safe fix to solve a significant performance problem.
Comment 7 Arthur Ryman CLA 2006-06-14 15:35:07 EDT
+1 for WTP 1.5 RC5 based on David's review
Comment 8 Tim Wagner CLA 2006-06-14 15:36:02 EDT
+1 1.5

Comment 9 David Williams CLA 2006-06-14 16:27:13 EDT
Released for RC5. 

Raj, think this could be related to bug 136399? 
Perhaps after this applied, you could see if 136399 is still 
a bug? 

Comment 10 David Williams CLA 2006-06-14 16:29:55 EDT
I'd like to nominate this bug as a "great bug" ... and, sure ... its just one little performance fix :) but Raj has actually contribute many bug reports, test cases and has gone "above and beyond" by contributing several patches similar to this one that end up "making a differernce for Callisto" ... so therefore deserves a t-shirt that says so :) 

Comment 11 John Lanuti CLA 2006-11-28 15:58:49 EST
This is part of a mass update to close out all stale WTP resolved bugs from the 1.0.x and 1.5.0 timeframe.  If you feel this bug was closed inappropriately, please reopen.

Thanks, John Lanuti