Principle:1kbgz Tributary Graph Execution
| Knowledge Sources | |
|---|---|
| Domains | Graph_Execution, Streaming |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
An execution model for streaming computation graphs that processes nodes level-by-level in topological order, with concurrent execution within each level via asyncio.
Description
Graph execution in Tributary's streaming subsystem follows a level-by-level (BFS) execution strategy:
- The graph is traversed via deep BFS from the output node to produce a list of levels (topological layers).
- Within each level, all nodes execute concurrently via asyncio.gather.
- Levels execute sequentially: level waits for all nodes in level to complete.
- The loop continues until the output node produces a StreamEnd sentinel.
This ensures data dependencies are respected (a node only fires after all its upstream nodes have produced values for the current tick) while maximizing parallelism within each level.
Key characteristics:
- Topological ordering: Nodes are grouped into layers by BFS depth.
- Concurrent within level: asyncio.gather runs all nodes in a level as concurrent coroutines.
- Sequential across levels: Level starts only after level finishes.
- Termination: The loop ends when the starting node's value is StreamEnd.
- Lifecycle hooks: Nodes can register _onstarts and _onstops coroutines for setup/teardown.
Usage
Use this principle when executing streaming data pipelines. The execution model is suitable for:
- Real-time data processing with async I/O (HTTP, Kafka, WebSocket)
- Pipelines where stages have different latencies (concurrent within level helps)
- Long-running streams with graceful shutdown via stop()
Theoretical Basis
The execution follows a synchronous dataflow model where each "tick" processes one value through the entire graph:
# Abstract execution model (NOT real implementation)
async def run_graph(graph):
levels = deep_bfs(graph.output_node) # topological layers
await run_onstarts(graph)
while True:
for level in levels:
await asyncio.gather(*[node() for node in level])
value = graph.output_node.value()
if isinstance(value, StreamEnd):
break
await run_onstops(graph)
return value
The level-by-level constraint ensures that every node in level has all its upstream dependencies in levels , which have already completed.