Bug 442337 - Optimize DialectServices.getRepresentations(EObject, Session)
Summary: Optimize DialectServices.getRepresentations(EObject, Session)
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 2.0.0   Edit
Assignee: Pierre-Charles David CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance, triaged
Depends on:
Blocks: 442131 439982 440961 442059
  Show dependency tree
 
Reported: 2014-08-22 04:39 EDT by Pierre-Charles David CLA
Modified: 2014-10-27 06:52 EDT (History)
1 user (show)

See Also:


Attachments
First draft of a patch (3.28 KB, patch)
2014-08-22 05:52 EDT, Pierre-Charles David CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2014-08-22 04:39:33 EDT
The DialectServices.getRepresentations(EObject, Session) method, via its implementation in DAnalysisSessionServicesImpl.getRepresentationData()), shows up as a performance bottleneck in several important scenarios: see bug 442131, bug 442059, bug 44069 and bug 439942.

The current implementation relies on each dialect to perform the same job, which involves iterating and testing on all the representations in the session. While not that slow (about 5ms on a session with 10k representations), the method is called often enough that this adds up quickly to result in very slow operations (sometimes to the point of being completely unusable).

There are at least two obvious improvements possible:
1. Use the session's cross-referencer to get the representations with a O(1) operation.
2. Do it only once for all the dialects.

Once this is done, we'll revisit the scenarios in the tickets mentioned above, to see how much this improves the sitaution, and see if this particular piece of code still appears in the profiling info.
Comment 1 Pierre-Charles David CLA 2014-08-22 04:43:25 EDT
Two small typos in the bug numbers mentioned in the previous comment: the bugs are 442131, 442059, 440961, and 439982.
Comment 2 Pierre-Charles David CLA 2014-08-22 05:52:12 EDT
Created attachment 246243 [details]
First draft of a patch

This simple first draft of a patch already gives very large speedups on several of the related tickets.

Using the large sample project at https://github.com/cbrun/org.eclipse.ecoretools.performance/tree/master/plugins/org.eclipse.emf.ecoretools.design.tests.perf/projects/reverse-sirius-10times:

* Right-clicking on the "full-sirius-code" element to show the contextual menu (corresponds to bug 439982): unsuable without the patch (abandonned after 3min), less than a second with the patch.
* Creating a small 6×1 table (corresponds to bug 440961) : from 16.4s without the patch to 1.6s with it.
* Creating a small (empty because unsynchronized) diagram (corresponds to bug 440961) : from 17.5s without the patch to 1.5s with it.
* Expanding the "full-sirius-code" node in the Model Explorer: from 10.5s without the patch to 0.7s with it.
Comment 3 Pierre-Charles David CLA 2014-08-22 10:10:46 EDT
See https://git.eclipse.org/r/32146
Comment 4 Pierre-Charles David CLA 2014-09-11 03:36:38 EDT
Commit a546949cff7fe27eb42876f233c4e313a16bcfa8 caused a regression:
1. Open a modeling project on a basic Ecore file with 3 EClasses.
2. Check the 3 EClasses are visible in the Model Explorer: OK
3. Open the Ecore in an external editor (the normal EMF-provided one for example). Added some more classes and save.
4. Check the new EClasses are visible in the Model Explorer: *KO*.
5. Create/remove/copy a representation in the session. This triggers the new listener, and in addition to picking up the changes in representations it also refreshes the semantic elements.
Comment 5 Pierre-Charles David CLA 2014-09-11 10:20:22 EDT
(In reply to Pierre-Charles David from comment #4)
> Commit a546949cff7fe27eb42876f233c4e313a16bcfa8 caused a regression:

It was reverted by f7abe9a1cfec0241a7e8393deb4f568f81ff849b.
Comment 6 Pierre-Charles David CLA 2014-09-11 10:59:30 EDT
Fixed.
Comment 7 Pierre-Charles David CLA 2014-10-27 06:52:12 EDT
Available in Sirius 2.0.0.