Bug 439985 - ViewpointSelectionCallback.selectViewpoint() takes ages when many representations are extended by the Viewpoint which gets enabled
Summary: ViewpointSelectionCallback.selectViewpoint() takes ages when many representa...
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance, triaged
Depends on:
Blocks:
 
Reported: 2014-07-21 05:38 EDT by Cedric Brun CLA
Modified: 2017-09-27 06:01 EDT (History)
3 users (show)

See Also:


Attachments
reverse-sirius-data.zip simple project (216.89 KB, application/zip)
2014-07-21 05:39 EDT, Cedric Brun CLA
no flags Details
Archived project with Benchmarking tests (4.20 MB, application/zip)
2014-07-30 12:08 EDT, Cedric Brun CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Brun CLA 2014-07-21 05:38:41 EDT
Steps to reproduce

1- Install EcoreTools 2.0.x
2- Import the project in attachment. This is not a modeling project yet, just a simple project containing an Ecore file.
3- Right click on the .ecore file "Initialize Ecore Diagram"
4- Click on finish in the Wizard page to create a .aird file.

The UI Thread is then blocked for a very long time, stuck during the Viewpoint enablement (about 10/15 minutes)

The EcoreInitDiagram action is actually calling Sirius this way :

new RecordingCommand(existingSession
		.getTransactionalEditingDomain()) {

	@Override
	protected void doExecute() {
		ViewpointSelectionCallback selection = new ViewpointSelectionCallback();
		for (Viewpoint previouslySelected : existingSession
				.getSelectedViewpoints(false)) {
			selection.deselectViewpoint(
					previouslySelected,
					existingSession,
					new NullProgressMonitor());
		}
		selection.selectViewpoint(EcoreToolsViewpoints
				.fromViewpointRegistry().design(),
				existingSession,
				new NullProgressMonitor());
		selection.selectViewpoint(EcoreToolsViewpoints
				.fromViewpointRegistry().review(),
				existingSession,
				new NullProgressMonitor());
		selection.selectViewpoint(EcoreToolsViewpoints
				.fromViewpointRegistry().archetype(),
				existingSession,
				new NullProgressMonitor());
		selection.selectViewpoint(EcoreToolsViewpoints
				.fromViewpointRegistry().generation(),
				existingSession,
				new NullProgressMonitor());
	}
});

If I comment out the activation of the "archetype" Viewpoint then the creation is fairly fast.

Archetype provides a Diagram Extension with a Layer enabled by default. This diagram extension is applicable to all the diagrams which are going to be created (or are already created) by the enablement of the Design viewpoint.

It looks like during the Viewpoint enablement we try to update all the representations which could be extended by this viewpoint :

DialectManager.INSTANCE.updateRepresentationsExtendedBy(session, editingDomainViewpoint, true);

When doing that we ends up executing a ChangeLayerActivationCommand 

org.eclipse.sirius.diagram.tools.internal.command.ChangeLayerActivationCommand

Which indirectlyh eats 95 % of the time as dDiagram.getActivatedLayers().add(layer) triggers a notification which will be caught by 

org.eclipse.sirius.diagram.business.internal.componentization.mappings.DiagramMappingsManagerRegistryImpl which will recompute its mapping tables for each diagram which got updated (more than 1000 of them)
Comment 1 Cedric Brun CLA 2014-07-21 05:39:46 EDT
Created attachment 245226 [details]
reverse-sirius-data.zip simple project
Comment 2 Cedric Brun CLA 2014-07-21 12:31:05 EDT
Fixing https://bugs.eclipse.org/bugs/show_bug.cgi?id=440032 has the potential to reduce the time spent from 15 mins to a few seconds without changing the current behavior. 

BTW I'm not saying we should not change the current behavior, updating all the representations like that has the potential to create problems with teamwork.
Comment 3 Cedric Brun CLA 2014-07-30 12:08:03 EDT
Created attachment 245542 [details]
Archived project with Benchmarking tests

Attaching a project with JUnit tests to reproduce this scenario.

1- Import the project
2- run org.eclipse.emf.ecoretools.design.tests.perf.unit.SessionTests as a Junit plugin tests.

On my machine this takes 875 secs.
About 20 secs  using this fork of Sirius : ttps://github.com/cbrun/org.eclipse.sirius/tree/wip/cbr/440032_diagrammappingmanagers (which is not quite ready to be considered for inclusion.)
Comment 4 Maxime Porhel CLA 2014-07-31 05:19:40 EDT
(In reply to Cedric Brun from comment #2)
> Fixing https://bugs.eclipse.org/bugs/show_bug.cgi?id=440032 has the
> potential to reduce the time spent from 15 mins to a few seconds without
> changing the current behavior. 
> 
> BTW I'm not saying we should not change the current behavior, updating all
> the representations like that has the potential to create problems with
> teamwork.

A possible modification of the current behavior would be to modify only the opened representation (see the representations refresh behavior which also handle the auto/manual refresh)