0

I have list of tasks that needs to be executed . Each task is a producer that updates multiple entities in response to consuming multiple entities. So tasks are dependent on each other for their execution. However, some producers are ok with consuming some or all of their entities stale. This should effectively makes sure there are no deadlocks.

How to design an execution graph in this case where: 1) Maximum number of tasks are run parallel (and) 2) Maximum number of tasks consume live/non-stale data

Any help is highly appreciate.

Editing after comments: Producer is able to tolerate stale data. This implies that any edge can be removed. So, there is always a solution (a DAG can be formed). This edge removed has a cost. So effectively the problem is:

Given a cyclic graph G (with root node and sink node), with operations - remove an edge between two nodes with cost C. How to create a DAG with maximum number of nodes at any level of node and with minimum cost. Here level is the depth from root nodes. If it takes two edges to reach a nodes from root, the level of node is 2. root node is at level '0'.

  • Why don't you let the graph design itself by connecting the tasks with select operations on 1-element synchronized buffers, so tasks run if an only if their required inputs are all present? This approach is much easier to maintain as the system changes. – Gene Nov 15 '15 at 14:39
  • deadlocks. Deadlocks cannot be avoided as they are something inherit to the context. So, I need to resolve the deadlock. – Sreeja Thummala Nov 15 '15 at 14:43
  • You said "This should effectively makes sure there are no deadlocks." – Gene Nov 15 '15 at 18:55
  • Suppose lets say there is a cycle: P1->P2->P1. If P1 can tolerate stale data, P2->P1 edge can be effectively be removed such that there is no more cycle. I mean by that statement that as the edges can be removed, there is always a scenario where is there is no cycle effectively meaning no deadlocks. – Sreeja Thummala Nov 15 '15 at 20:09
  • The overall scenario is that given a cyclic graph, I need a directed acyclic graph where there is maximum parallelization. We need to maximize number of nodes at any level of the graph. – Sreeja Thummala Nov 15 '15 at 20:13
  • 1
    I don't have time to work on this now, but I think what you can do is look at deadlock recovery algorithms. These are designed to break cycles in a deadlock graph that's already occurred. You just want to break them by accepting stale results rather than killing tasks. – Gene Nov 15 '15 at 20:26
  • Thats a great suggestion. I will look into them and update if I could come up with any solution. – Sreeja Thummala Nov 15 '15 at 20:29
  • Another characterization of this problem is called "max weight spanning DAG". You're looking to drop edges of min possible weight in order to get a graph with no cycles. It's the same thing as finding the largest possible DAG. – Gene Nov 15 '15 at 20:36

0 Answers0