-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution-Context-independent SpanTree
s
#6802
Comments
In fact, the controllers already can give you a Span Tree without execution context, just use
I think it's not so simple. How do you want to handle "gray" ports? They depend on execution results. We could technically add them as additional info to method call span in span tree, but:
Overall, I think it's a wrong solution to the problems mentioned in the issue. For "Malfunctioning Edge" I would rather find an alternative way for locating port than list of indexes: perhaps we should mix indexes with argument names?
|
Yes, the widget tree heavily relies on the AST IDs assigned to the span tree, as well as resolved method call metadata to produce expected argument nodes, appropriate insertion points and data necessary to properly query dynamic widgets. There might also be an alternative approach. I think that with widget tree being a thing, we don't really have that strong need to have the span tree in the first place. I believe that Its existance is actually a complication in many different areas, notably the expression editing code. We could quite easily transform the widget tree to work on the new AST structure directly, and query/watch the suggestion database itself. We could inject appropriate widgets like argument placeholders directly at that level, without building an intermediate tree structure. There would also be no need for "insertion points". The code modifications could also be expressed easier as a set of AST operations, not span-tree "insert"/"erase" actions. I believe that our new AST representation is suitable for that. |
I would still give span tree a chance.
Remember that the insertion points have made life easier when talking about connections: you could specify the connection endpoint by just span-tree crumbs. With you solution we must change it to AST crumbs + optional "insertion point" info (an argument by index or name, position on list, maybe add element to operator chain, etc.) Of course, we could manage it (expect significant refactoring here), but span tree was designed to unify such cases.
This somehow mix the controller/view separation. The widget tree, being currently in the view, cannot access to any database. To fix that, the controllers should, basing on the information they have, create a good model, on which you can easily instantiate concrete widgets. Once done, we can call this model "span-tree", and this way do the refactoring. |
I think that those are actually a significant source of issues. We had and still have many bugs caused by span-tree being modified while an edge is being dragged. The crumbs defined within the connection model are not stable across tree updates, therefore they get stale and either point to an incorrect node, or no node at all. We have no way of detecting that situation, or updating the crumbs accordingly. To solve this, we will need a better, more stable way to refer to the intended edge endpoint location. For fully connected edges, we don't actually care too much. Every time the expression is updated, we basically rebuild the connected edge models completely from scratch, redoing alias analysis on the updated expressions. The edges that are detached on the source side (the target stays connected) are an exception though - they don't exist from the perspective of the controller. The view maintains their state using the aforementioned span tree crumbs. This is not really correct to do, as it is not a sufficiently stable identity of the location within the expression.
I think I was a little too loose with my wording. We would need a model that would contain relevant information about all AST nodes within each node's expression. It could be prepared and updated by the graph controller. It doesn't have to be itself a tree though. The view would use that data while building the widgets from the AST. |
Do we? I thought we do not touch edge if its crumbs weren't changed. Or at least this was so before the widgets era.
And this is my point of concern: Isn't it too much of logic for the view? |
Let's have a call about this design :) I've scheduled it for tomorrow :) |
I think it depends on what you mean by "touch". The view update will be skipped for edges that were determined unchanged, but the road to get there is pretty bumpy. The connections model of the entire graph is actually computed on-demand for each view update: enso/app/gui/src/presenter/graph.rs Lines 563 to 569 in fe0a06d
enso/app/gui/controller/double-representation/src/graph.rs Lines 96 to 99 in fe0a06d
The same thing happens with span trees (in fact, it's part of the Connections structure for some reason). From the presenter point of view, both of those structures are completely ephemeral and derived from source just in time.
Nothing wrong with this approach in general, but those structures are definitely too expensive to rebuild for my comfort right now. We would likely benefit from making them cheaper to build (or eliminate completely), especially the span tree. Per each "view update", the presenter then attempts to set the expression for each node, and add/remove connections. enso/app/gui/src/presenter/graph.rs Lines 716 to 717 in fe0a06d
enso/app/gui/src/presenter/graph.rs Lines 748 to 749 in fe0a06d
The edge update is actually interesting. Changing endpoind crumbs will effectively be translated into remove+add pair of operations. The edge views will not be reused. Finally, the node updates specifically are filtered for changes, so that the unchanged node views don't need to be updated. enso/app/gui/src/presenter/graph.rs Lines 589 to 597 in fe0a06d
enso/app/gui/src/presenter/graph/state.rs Lines 446 to 469 in fe0a06d
Note that this check is in of itself actually quite expensive - we are deep-comparing the span tree structures, and again it happens for all nodes in the graph on each individual view update. Those contain a ton of boxed objects and strings. I believe that if we remove the span tree, we could directly pass AST updates to the relevant updated nodes, removing all of that logic completely. For edges, the view updates are relatively cheap right now, but it could also be made significantly simpler. Each connection is a pair of endpoints, each containing an Also importantly, the detached edges are not affected by view updates. That means their endpoints can easily become invalid right now. I discovered this issue when adding support for named arguments, because the span tree structure is significantly affected when a connection to a named argument is broken. The detached edge's target endpoint crumbs had to be explicitly updated to match expected location of future insertion point. This logic is obviously incredibly brittle. enso/app/gui/src/presenter/graph.rs Lines 301 to 312 in fe0a06d
To be honest, I don't fully understand why we need the extra presenter layer, as a stateful mediator between controller and the proper graph view. It ends up replicating a lot of state that the view maintains anyway. We could probably make it significantly simpler by letting the graph view handle its state update more directly (not splitting into insert/update/remove, just batch "here is a list of all edges/nodes", deal with it). That would give us less opportunity to make the state inconsistent. |
We have planned this in a call: #6834 |
Currently, the structure of a
SpanTree
depends on information the engine provides after executing the graph.This is a cause of complexity, bugs like #6772, and performance issues.
To fix this:
SpanTree
generation; it should be a pure function of the syntax.SpanTree
s to handle execution results; rather, we should change what execution-information is associated with theSpanTree
nodes.As a result:
_
), fixing Malfunctioning edge after detaching source end #6772.This will require deep changes to the
SpanTree
design, however it will fix some bugs that cannot be solved properly without design changes, and will result in cleaner separation of concerns.(I'll add an estimate to this soon. It is at least a 5 day project.)
The text was updated successfully, but these errors were encountered: