Bug 558016

Summary: [Layout] Multiple layout command executed at diagram creation
Product: [Modeling] Sirius Reporter: Florian Barbin <florian.barbin>
Component: DiagramAssignee: Project Inbox <sirius.diagram-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: pierre-charles.david
Version: unspecifiedKeywords: performance, triaged
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Test Case none

Description Florian Barbin CLA 2019-12-09 03:59:23 EST
Created attachment 281169 [details]
Test Case

At diagram creation time, multiple arrange commands are created and executed. 

It seems that for each element created on the diagram, an arrange command is created here:

	SiriusCanonicalLayoutHandler.getLayoutCommand(Map<IGraphicalEditPart,List<IAdaptable>>, Map<IGraphicalEditPart,List<IAdaptable>>, TransactionalEditingDomain) line: 209	
SiriusCanonicalLayoutHandler.launchArrangeCommand(DiagramEditPart, boolean) line: 105	
SiriusCanonicalLayoutHandler.launchArrangeCommandOnOpening(DiagramEditPart) line: 66	
DDiagramEditorImpl.initializeGraphicalViewer() line: 1622	
DDiagramEditorImpl.createOriginalGraphicalViewer(Composite) line: 1574	
DDiagramEditorImpl.createMainDiagramSection(Composite) line: 1500	
DDiagramEditorImpl.createGraphicalViewer(Composite) line: 1476	
DDiagramEditorImpl(GraphicalEditor).createPartControl(Composite) line: 171	
DDiagramEditorImpl(DiagramEditor).createPartControl(Composite) line: 1580	
DDiagramEditorImpl(DiagramEditorWithFlyOutPalette).createPartControl(Composite) line: 328	
DDiagramEditorImpl(DiagramDocumentEditor).createPartControl(Composite) line: 1514	
DDiagramEditorImpl.createPartControl(Composite) line: 609	
CompatibilityEditor(CompatibilityPart).createPartControl(IWorkbenchPart, Composite) line: 154	
CompatibilityEditor.createPartControl(IWorkbenchPart, Composite) line: 101	
CompatibilityEditor(CompatibilityPart).create() line: 362

Next, those commands are added in a compound command executed here:

SiriusCanonicalLayoutCommand.doExecute() line: 85	
SiriusCanonicalLayoutCommand(RecordingCommand).execute() line: 135	
CompoundCommand.execute() line: 261	
EMFCommandOperation.doExecute(IProgressMonitor, IAdaptable) line: 119	
EMFCommandOperation(AbstractEMFOperation).execute(IProgressMonitor, IAdaptable) line: 150	
DefaultOperationHistory.execute(IUndoableOperation, IProgressMonitor, IAdaptable) line: 495	
NonDirtyingCapableWorkspaceCommandStack(WorkspaceCommandStackImpl).doExecute(Command, Map<?,?>) line: 208	
NonDirtyingCapableWorkspaceCommandStack.doExecute(Command, Map) line: 69	
NonDirtyingCapableWorkspaceCommandStack(AbstractTransactionalCommandStack).execute(Command, Map<?,?>) line: 165	
NonDirtyingCapableWorkspaceCommandStack(AbstractTransactionalCommandStack).execute(Command) line: 219	
SiriusCanonicalLayoutHandler.launchArrangeCommand(DiagramEditPart, boolean) line: 107	
SiriusCanonicalLayoutHandler.launchArrangeCommandOnOpening(DiagramEditPart) line: 66	
DDiagramEditorImpl.initializeGraphicalViewer() line: 1622	
DDiagramEditorImpl.createOriginalGraphicalViewer(Composite) line: 1574	
DDiagramEditorImpl.createMainDiagramSection(Composite) line: 1500	
DDiagramEditorImpl.createGraphicalViewer(Composite) line: 1476	
DDiagramEditorImpl(GraphicalEditor).createPartControl(Composite) line: 171	
DDiagramEditorImpl(DiagramEditor).createPartControl(Composite) line: 1580	
DDiagramEditorImpl(DiagramEditorWithFlyOutPalette).createPartControl(Composite) line: 328	
DDiagramEditorImpl(DiagramDocumentEditor).createPartControl(Composite) line: 1514	
DDiagramEditorImpl.createPartControl(Composite) line: 609	
CompatibilityEditor(CompatibilityPart).createPartControl(IWorkbenchPart, Composite) line: 154	
CompatibilityEditor.createPartControl(IWorkbenchPart, Composite) line: 101	
CompatibilityEditor(CompatibilityPart).create() line: 362

It also seems that a last arrange is performed at diagram opening here:

DDiagramEditPart(GraphicalEditPart).performRequest(Request) line: 1125	
LayoutUtil.arrange(DiagramEditPart) line: 47	
DiagramDialectArrangeOperation.arrange(IEditorPart, DDiagram) line: 47	
DiagramDialectUIServices.openEditor(Session, DRepresentation, IProgressMonitor) line: 188	
DialectUIManagerImpl.openEditor(Session, DRepresentation, IProgressMonitor) line: 96	
CreateRepresentationAction$2.run(IProgressMonitor) line: 172	

Steps to reproduce:
In a development environment, set breakpoints according the given stack traces. Import the attached modeling project and create a new diagram without elk for instance. You should stop multiple times as mentioned above.
Comment 1 Florian Barbin CLA 2019-12-23 09:25:28 EST
Note that this issue is not specific to ELK but has been detected during the ELK layout experimental phase.
Comment 2 Pierre-Charles David CLA 2020-05-05 11:00:01 EDT
The observation may be correct (multiple commands launched), but there is no mention of an actual issue this causes. I guess it's implied that we are doing useless work and could improve performance by avoiding that. Marking as performance enhancement instead of a bug. @Florian, feel free to change back to bug if you have more details about actual problems this causes.