Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316793

Summary: Use of ArrayList in ModelParameterExtent causes scalability issues
Product: [Modeling] QVTo Reporter: Alan McMorran <alan>
Component: EngineAssignee: Project Inbox <mmt-qvt.operational-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: kutter, serg.boyko2011
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Changes the getContents() method of ModelParameterExtent to use HashSets
none
Updated version of patch serg.boyko2011: iplog+

Description Alan McMorran CLA 2010-06-14 13:48:09 EDT
Build Identifier: 20091217-0918

In the org.eclipse.m2m.internal.qvt.oml.ast.env.ModelParameterExtent class in the getContents() method the allRootObjects variable is set as an ArrayList which causes significant performance issues for the section of code:

for (EObject obj : inMemoryResource.getContents()) {
	// don't forget about UML stereotype applications which are the root objects
	if (obj.eContainer() == null && allRootObjects.contains(obj) == false) {
		allRootObjects.add(obj);
	}
}

when the number of root objects increases to several hundred thousand.  The contains method in ArrayList does not scale well, so it may be better to have these collections be HashSets (or similar) so that this comparison can be done quickly when the number of objects produced is in the order of several hundred thousand.

This may cause issues for object ordering, which doesn't affect my transform however.

Reproducible: Always
Comment 1 Alan McMorran CLA 2010-06-14 13:49:56 EDT
Created attachment 171853 [details]
Changes the getContents() method of ModelParameterExtent to use HashSets
Comment 2 Sergey Boyko CLA 2013-03-21 11:55:29 EDT
Created attachment 228860 [details]
Updated version of patch

For testing the following transformation was used:

  modeltype Ecore uses ecore('http://www.eclipse.org/emf/2002/Ecore');
  transformation NewTransformation1(in input : Ecore, out output : Ecore);
  main() {
    var index := 0;
    while (index < 100000) {
      object EClass {name := "n" + index.toString()};
      index := index + 1; 
    }
  }

With the proposed patch execution time of method EvaluationUtil.createEvaluationResult() reduced from 4054ms to 86ms.
Comment 3 Sergey Boyko CLA 2013-04-03 11:51:18 EDT
Pushed to master for Kepler M7.

Commit ID: f29c4a7c64cc0133dd1abb45a547eae8244dc498