Node state passing#187
Conversation
BREAKING CHANGE: old update signature does no longer work
|
This is a huuuuuuge change. I'm ok with the pipeline control of the state, and with the capability of using a dirty state. The OTOH, I have different concerns about the deltas() approach. I'd like to hold off on merging this (I'm talkin of the deltas part). Not because the delta-based design is wrong in principle, but because there's currently no state-passing mechanism at all to compare it against, and we're taking on a breaking change across the base node, pipeline, remote service, and warp nodes to introduce one. In a nutshell, aside the good-qualiy code you wrote: We're choosing the first implementation here, not optimizing an existing one, so I think the choice deserves more scrutiny. Pros of the delta approach (SET/DEL) as implemented
Cons / risks
IMHO, I'd like to start with the simplest model: implement the send the full state on each update in warp: Given the size of the surface this touches, I'd rather land the simpler version first and let real needs drive the added complexity later. Open to revisiting if there's a specific workload or constraint behind the delta design that I'm missing. |
…nature will not require changing it
|
I applied the changes and fixed the issues with the warp nodes. Just to make a quick recap of the key points of this PR that were not included in the original text:
|
Description
This PR offers an implementation of a node state passing mechanism.
State object
The new
Stateobject extendsUserDict, so it can be used like any regular dictionary. Additionally, it holds a slim history of deltas, that can be used to recreate a state. Once retrieved, deltas are deleted from the state object as to prevent excessive duplication.Using deltas instead of full states allows, if needed, to share only relevant changes about a node state, thus avoiding retransmission in performance-critical scenarios.
Nodes as fully stateless entities
Nodes receive an external state object reference, and use that reference internally whenever the
updatemethod is called. The method signature now becomes:Nodes still retain the option to use dirty state, as well as to use their state values through
self._state.State store in the pipeline
The pipeline object now holds a dictionary where node names are the keys, and states are the values. Whenever a new node is instantiated in a pipeline, its state is created and linked with
node.link_state(state_store[node_name].Warped nodes
Similarly to what the pipeline object does, the remote service creates a state store, but in this case the dictionary does not hold node names as keys but pipe ids. This solves the issue of a warped node shared across multiple pipes: when this happens, every time a new message is available from a pipe, the service links the correct state on the node and then pushes the message to its queue.
This PR also includes changes for all the built-in nodes.
PR type
Select all the labels that apply to this PR.
Affected components