Issue Description
Currently in the Runtime._worker method, a new node instance is created for each execution:
node = self._node_mapping[state["node_name"]]
outputs = await node()._execute(node.Inputs(**state["inputs"]))
This approach ensures isolation but may impact performance, especially under high throughput scenarios.
Proposed Solution
Consider caching node instances to improve performance:
- Cache instances in a dictionary keyed by node name
- Reuse existing instances if nodes are stateless
- Manage a pool of instances if needed
Implementation Considerations
- Evaluate if nodes are stateless and safe to reuse
- Consider thread/async safety implications
- Measure performance impact before and after changes
References
Issue Description
Currently in the
Runtime._workermethod, a new node instance is created for each execution:This approach ensures isolation but may impact performance, especially under high throughput scenarios.
Proposed Solution
Consider caching node instances to improve performance:
Implementation Considerations
References
python-sdk/exospherehost/runtime.pyaround lines 289-290