In December, version 5.0 of Eclipse Capella was released. At Obeo we are proud to have contributed to the source code of this version. With my colleague Nathalie Lépine, we worked on the optimization of the Sequence Diagram.
Developed by Thales with the support of Obeo, the Capella workbench is an open-source software solution to design systems architecture. Widely adopted worldwide in various industrial sectors, it provides a methodology, a domain-specific language and a graphical environment to visually describe the components and functions of a system (a car, train, satellite, medical device, …) and how they interact.
Capella source code is publicly and freely available, so that our work benefits the entire community of Capella users and tool providers.
Before we start getting into the specifics of the optimizations we have made, let’s explain what is a Sequence Diagram.
Sequence Diagrams in a nutshell
Simply put, Sequence Diagrams are graphical representations that detail how operations are carried out. They show the order of the visual interaction by using the vertical axis of the diagram to represent when and which messages are sent and the horizontal axis to show the elements that are involved in the interaction. Popularized by the UML modeling language, which provides this kind of representation to represent the flow of logic within a software system, the Sequence Diagram is also one of the many representations available in Capella to describe interaction scenarios between elements (components, entities, actors, etc).
Below, you can see two examples of Sequence Diagrams, one very simple, and another one that is more complex.
To fit its users’ needs, Capella provides several kinds of sequence diagrams:
- Functional Scenarios (lifelines are Functions),
- Exchange Scenarios (lifelines are Components/Actors while sequence messages are Functional or Component Exchanges),
- Interface Scenarios (lifelines are Components/Actors while sequence messages are Interface Operations).
- Modes, States and Functions can also be displayed on these diagrams.
The fact is that Sequence diagrams are advanced Capella features mainly used on very large-scale complex systems. As a result, Sequence diagrams are large data sets that grow continuously throughout the years.
Due to their important size, users encountered performance problems when opening and modifying Sequence Diagrams. In one case, this issue was faced by one of our main customers, a Chinese leading company in systems engineering services.
As we will explain through this blog post, on the latest Capella 5.0 release, the Obeo team, in coordination with Thales, worked on several optimizations to improve the performance of Sequence Diagrams. Mainly by optimizing the generic Sequence Diagram component provided by Eclipse Sirius and used in Capella.
What is the role of Sirius here?
In Capella, most of the diagrams are developed with Eclipse Sirius, an open-source solution developed by Obeo and Thales that enables you to create custom graphical modeling tools dedicated to specific areas of expertise. With a tool created with Sirius, a user can design complex systems (software, business activities, physics, etc.) while keeping the corresponding data consistent (architecture, component properties, etc.).
Among the many benefits of using Sirius is the fact that it provides a component dedicated to sequence diagrams (see User Guide). Thanks to this component, the developer of a graphical modeling tool can easily provide a sequence diagram to its users. He just has to map the concepts of interaction from the elements of his domain model to the graphical elements of a sequence diagram (see Specifier guide).
Contrary to what happens on a classical diagram, the relative graphical positions of elements on a Sequence diagram have strong meaning. This works both ways. This is very different from what happens in other diagrams, where most graphical repositioning of elements are only cosmetic. Most of the specific features and restrictions of sequence diagrams compared to other diagrams derive from this strong guarantee that at all time, the graphical (vertical) order of the elements you see on the diagram match exactly the semantic order of the events which exist in the underlying model.
For this reason, the Arrange All command in Sirius, which launches an automatic layout of all the elements on a diagram, is specific for sequence diagrams. Arranging a Sequence diagram keeps the relative positions of all the elements, but reduces any unneeded vertical or horizontal spaces. All elements are set to the minimum size necessary, and “packed” towards the top-left corner of the diagram. This results in a diagram which uses the minimum space required to present all the elements, while keeping enough white-space between them to be easy to read.
In Capella, the sequence diagrams are specific configurations of the Sirius’ Sequence Diagrams component. It consists of a mapping specification that describes how the graphical elements of a sequence diagram are deduced from the Capella model, and how the user can interact with the diagram elements (creation, drag&drop, reorder, etc).
This mapping is complemented with Java services that execute complex actions.
Improvements for a smoother user experience
On the latest Capella release, the improvements we brought to the Sequence diagram were focused on optimizing the response time of user interactions: layout management, layout computation, resize/move validations, … Our objective was clearly to provide a smoother user experience when opening and working on large sequence diagrams.
One optimization was directly related to Capella : we introduced a cache system to optimize the execution of refresh operations (https://github.com/eclipse/capella/pull/381).
But the other optimizations were mostly done directly in Sirius, on the Sequence Diagram component. This represents 36 changes available in the source code of Sirius 6.4.0 (the version used by Capella 5.0.0):
- adding caches
- avoid useless code executions
- refactoring code
- optimize computations
- etc.
All these changes are publicly available from the git log starting at the v6.4.0 tag (version included in Capella 5.0).
How we have worked on that project
As the performance problems were due to many different data processing involved in the creation and the layout of large Sequence Diagrams, we had to set up an empirical and pragmatic approach to identify and solve bottlenecks in a source code developed in 2010.
This approach led us to use several techniques:
- Pair programming, coding and analysis:
- parallel attempts and discussions,
- proof-of-concepts.
- Usage of optimization tools:
- Sirius integrated time profiler and debugger,
- Yourkit, a Java CPU and memory profiling tool.
- Constitution of test-cases:
- with some real data provided by a customer (“Scenario”),
- with “toy” test-cases, a small Sequence diagram with very few data in order to check that we do not introduce regressions (“Small Scenario”),
- with one “big” test-case, ~5 times the size of the customer’s test-case (“Big Scenario”).
- Evaluation in different situations:
- with Capella and/or Team for Capella,
- on local and/or shared projects,
- with one or several diagrams opened (same projects, different projects)
- Evaluation of various aspects in minds (but mainly the usability):
- time of diagram opening,
- time of diagram refresh,
- time to be able to continue to work after an action on the diagram,
- time to get feedback on diagram modification attempts (dnd, resize, move, …).
- Isolation of attempts:
- each idea, attempt has its own commit,
- be able to see each atomic effect,
- be able to run the Sirius and Capella unit tests and search by dichotomy the change responsible for regressions,
- be able to analyse the possibility to backport the optimizations on maintenance branches if required / funded.
- Specific branch:
- we have worked on a specific branch to be only impacted by our changes and then we have integrated this branch in the Sirius and Capella "master" branches.
As we are used to, we work in a constructive and collaborative way with our ordering customer. We iterated step by step to guarantee a total satisfaction with the final developments.
What we get
Some of the fixes done in Sirius allow better performances in all kinds of diagrams (for the computation of decorators), but the improvements are mainly visible on sequence diagrams: opening, arrange all, layout, command computation, validation, and feedback.
The fixes done in Capella mainly impact the diagram refresh (computation of the content to display) :
As the layout of a sequence is triggered after every change that modifies the content/layout of the diagram, and the refresh is triggered after each impacting the underlying business/semantic model, the optimizations of both algorithms impact almost every user interaction from the palette or on an opened Sequence diagram.
Benefits for Capella and Sirius communities
The changes we made now benefit both users of Capella 5.0 and Sirius 6.4.
Indirectly, they also benefit from the solutions that are based on Sirius, such as Obeo Designer Team, the collaborative solution to simultaneously work on models.
As facts are worth a thousand words: in Capella’s previous version (1.4.0), opening the big scenario diagram took around 10 minutes. It was failing with our collaborative add-on, Team for Capella 1.4.0.
Now in Capella 5.0, opening the big diagram takes 1,8 seconds and less than 4 seconds with Team for Capella 5.0.
Next steps
This work was mainly driven by the needs of our customer, with the focus of improving the performance on his cases. Meanwhile, in other cases, with different usages of Sequence Diagrams, we found that some parts could still be optimized. In particular, the combined fragments used for loops or alternatives.
We are going to start a new project in order to bring a new wave of optimizations to Capella. They will come with version 5.1. Stay tuned!