Open PaulSchweizer opened 5 years ago
I like this idea a lot.
A simple and probably very powerful way to move forward is to restrict the focus on the simple case that you present in your example: Linear chains of nodes. They are
As for your second concern: Would it be possible to do the following:
Graph
is instantiated and the nodes that are assigned to this chain get added into that graph.graph.evaluate_node_in_process
method, introduce a graph.evaluate_subgraph_in_process
method and spawn a process for each chain (which might contain only a single individual node).So, basically I suggest collapsing the graph into subgraphs in such a way that each remaining component has at least two inputs and at most one output (with the exceptions of the entry and exit nodes of the original graph).
I hope I managed to express myself clearly - If I am being confusing, don't hesitate to ask what the hell I mean :-)
Limiting to chains only for now: Agreed!
Subgraphs I like the subgraph idea but I think we should treat that in a separate ticket and decide on how to deal with sub graphs properly #84
We might actually be able to achieve the sub-graph solution without sub-graphs though, by using a dedicated node instead. The node would have one in and one output just for treating the relationships. The node would then evaluate the node chain assigned to it. Hope that makes sense, I can add an example later.
Currently, every node will be evaluated in it's own process. There are however situations where chains of nodes could be grouped together and evaluated in one single process, thus limiting the amount of processes and saving on the startup time for these unnecessary processes.
Consider this graph:
We have 5 nodes resulting in 5 processes. If we would group the nodes, we could lower the number of processes to 3 while still maintaining the same benefits of multi-processing.
Consider this (naive) pseudo-code on how this grouping could work:
For the above example, the result would look like this:
To make this possible we'd need to solve these issues:
graph.evaluate_node_in_process
that handles multiple nodesThe grouping could then be an option when multiprocessing:
I have not tested whether this would actually be beneficial, but it made sense to me.