eclipse-sirius / sirius-web

Sirius Web: open-source low-code platform to define custom web applications supporting your specific visual languages
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
75 stars 50 forks source link

Avoid re-sending identical diagrams to the clients #3670

Open pcdavid opened 3 months ago

pcdavid commented 3 months ago

This is formulated about diagrams, but the issue is more general. It's just more impacting in terms of performance for diagrams which can quickly become large compared to the other kinds of representations (only large explorer trees with thousands of tree items could also be a problem I think for now).

The issue is that on any semantic change (in practice, any execution of a tool which may have a semantic impact, whether it actually did change something, see this comment in another context) we must refresh/update all the active representations (e.g. diagrams) in the same editing context. Such is the open-ended nature of Sirius that we can not reliably predict, for a given tool execution or semantic change, which representations it will actually impact or not, so we must update all.

However, once the backend has done its work, i.e. DiagramCreationService.refresh(IEditingContext, IDiagramContext) has obtained the updated version of the Diagram, we unconditionally send the whole "new version" to all client browsers who currently display that diagram. For large diagrams this can have significant performance impact. It means we serialize the Diagram DTO as a GraphQL payload (with a non-trivial overhead in invoking all the field resolvers), potentially once per browser/client, and then send large amount of data (a medium-sized diagram can represent several megabytes of payload) to the clients, which then have to re-render it.

This whole process is required in the case where the new/updated version of the diagram is actually different from the previous one, but is 100% overhead when the diagram was not actually impacted by the semantic change which triggered the refresh, and the newly computed diagram is identical to the previous one.

This not an uncommon case at all. It two users Alice and Bob are working on the same project, each in separate subsets of the project and with their own diagrams opened, any change by Alice in the semantic subset she is working on will trigger a refresh of both Alice & Bob's diagrams (which is normal), but also, in this case, re-sending the same diagram he currently has displayed to Bob for no reason.

pcdavid commented 3 months ago

A few remarks: