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

Bug 458822

Summary: Selecting a diagram element triggers a deep walk inside the semantic model(s)
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: DiagramAssignee: Mickael LANOE <mickael.lanoe>
Status: CLOSED FIXED QA Contact: Maxime Porhel <maxime.porhel>
Severity: normal    
Priority: P3 CC: maxime.porhel
Version: 2.0.0Keywords: triaged
Target Milestone: 3.0.0M7   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/44265
https://git.eclipse.org/r/44449
https://git.eclipse.org/r/44470
https://git.eclipse.org/r/44509
https://git.eclipse.org/r/44670
https://git.eclipse.org/r/44705
https://git.eclipse.org/r/44818
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=e6869bbf5fdc489b0d26f01dd07fae709f86ae62
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=395db93998cd7ab0491fa5982ff58492e84a3ba0
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=e74bd1221bfe814bf556dc4f3e913fae45e5f689
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=8c5caf0cf3e82e8820afa597e3f6aade21e8e9ae
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=e41b9ff55c5020a29ab3fcfa7b641728742b2092
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d8a263cecdd04c0bc432b39afddcf895074c2339
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=7be50252db5445844767c62dc1a9899732a2c787
Whiteboard:
Bug Depends on:    
Bug Blocks: 456350    
Attachments:
Description Flags
The sample project to use none

Description Pierre-Charles David CLA 2015-01-30 09:24:48 EST
Created attachment 250384 [details]
The sample project to use

Steps to reproduce:
1. Make sure you have the "org.eclipse.sirius.ui.debug" project in your workspace
2. Launch a runtime and import the attached project.
3. Open the "Sirius Debugging View".
4. Open the session in the sample project and the diagram inside of it.
5. In the debug view, clear the payload access log.
6. In the representation, select the top-level "c.0" container. Do nothing else, click nowhere else.
7. In the debug view, click "Show payload access log"

Note how simply selecting c.0 has triggered several walks inside the whole semantic model under it, hitting the payload. More precisely, this is to compute the various "delete" commands and their enablement. With large models these walks can become very costly and make the modeler feel sluggish because these computations are performed as soon as the user clicks somewhere to select an element.

The interesting part of the stacks:

org.eclipse.sirius.diagram.tools.internal.command.builders.DeletionCommandBuilder.buildDeleteDiagramElement(DeletionCommandBuilder.java:183)
org.eclipse.sirius.diagram.tools.internal.command.builders.DeletionCommandBuilder.buildCommand(DeletionCommandBuilder.java:134)
org.eclipse.sirius.diagram.tools.internal.command.UndoRedoCapableEMFCommandFactory.buildDeleteDiagramElement(UndoRedoCapableEMFCommandFactory.java:442)
org.eclipse.sirius.diagram.ui.graphical.edit.policies.NodeDeletionEditPolicy.buildGlobalDeleteCommand(NodeDeletionEditPolicy.java:92)
org.eclipse.sirius.diagram.ui.graphical.edit.policies.NodeDeletionEditPolicy.createDeleteSemanticCommand(NodeDeletionEditPolicy.java:85)


We should try to:
* reduce the number of different walks we do if possible.
* defer the actual walk when the delete action is actually invoked by the user, if ever. This would change the contract as we would not be able to disable the "delete" actions beforehand even if, at invocation time, we decide the deletion is not possible after all. The new behavior should probably be configurable to allow users who want precise feedback at the cost of performance can decide to go back to the current behavior.
Comment 1 Eclipse Genie CLA 2015-03-20 12:12:43 EDT
New Gerrit change created: https://git.eclipse.org/r/44265
Comment 2 Eclipse Genie CLA 2015-03-24 07:36:29 EDT
New Gerrit change created: https://git.eclipse.org/r/44449
Comment 3 Eclipse Genie CLA 2015-03-24 10:29:03 EDT
New Gerrit change created: https://git.eclipse.org/r/44470
Comment 4 Eclipse Genie CLA 2015-03-24 13:04:31 EDT
New Gerrit change created: https://git.eclipse.org/r/44509
Comment 5 Mickael LANOE CLA 2015-03-25 12:00:06 EDT
The method DeletionCommandBuilder.buildDeleteDiagramElement() is called twice to compute the enability of "delete" and "cut" actions. This gerrit https://git.eclipse.org/r/#/c/44449/ delayed the walk inside semantic models at the execution of the delete command.

After a D&D, the lazy cross referencer is removed and added again to moved semantic elements. Indeed, the removal or the addition of the cross referencer performs a full iteration through the content of the element. With this gerrit https://git.eclipse.org/r/#/c/44470/, the lazy cross referencer is not removed for already attached elements.

These following methods also do walks inside semantic models:

- EditStatusUpdater.changeEnabilityForRelatedAndChildren(IDiagramDialectGraphicalViewer, EObject, boolean). This method is called in post commit after some actions (D&D or add an edge to an element) in order to compute enability of concerned edit parts.

- DanglingRefRemovalTrigger.getChangedEObjectsAndChildren(Iterable<Notification>, Predicate<EObject>). After a D&D, the method is called in pre commit.
Comment 6 Eclipse Genie CLA 2015-03-26 06:45:58 EDT
New Gerrit change created: https://git.eclipse.org/r/44670
Comment 7 Eclipse Genie CLA 2015-03-26 13:03:36 EDT
New Gerrit change created: https://git.eclipse.org/r/44705
Comment 8 Eclipse Genie CLA 2015-03-30 04:40:42 EDT
New Gerrit change created: https://git.eclipse.org/r/44818
Comment 9 Eclipse Genie CLA 2015-03-31 11:36:15 EDT
WARNING: this patchset contains 3694 new lines of code and may require a Contribution Questionnaire (CQ) if the author is not a committer on the project. Please see:https://wiki.eclipse.org/Project_Management_Infrastructure/Creating_A_Contribution_Questionnaire
Comment 17 Pierre-Charles David CLA 2015-04-20 04:47:40 EDT
We'll consider this done for 3.0. There may be other less obvious cases but they will be treated later if they cause actual issues.
Comment 18 Maxime Porhel CLA 2015-05-21 09:20:35 EDT
Validated on Sirius 3.0.0 RC1 with the provided sample. 

In this sample,Component.payload == true only for non displayed components, the payload is empty until the delete is effectly done. If I change the payload attribute of displayed elements and paly with the selection, the only payload I can see on each selection change is the getName() done by the properties view title refresh.
Comment 19 Pierre-Charles David CLA 2015-06-24 11:16:30 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.