-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket Cache - RFC #128
Comments
Also note that setting a output socket in no way trigger any update events, that is done by the update system. |
As usual, i have to reread several times and try to understand to start ask questions. |
Idea for socket code. Now the we started packing the name of the bpy prop we could simplify the code by packing the prop value to the right level. socket=self.inputs['Radius']
radius=socket.get() Where it would return the input list or if 'Radius' in self.inputs and self.inputs['Radius'].links:
Radius = SvGetSocketAnyType(self,self.inputs['Radius'])[0]
else:
Radius = [self.rad_] could become if 'Radius' in self.inputs:
Radius = self.inputs['Radius'].get()[0] And that `if 'Radius' in self.inputs:`` I want to care of by separating ui and process code. So that the end could to this instead. Radius=self.inputs['Radius'].get()[0] |
how did you extend socket class with get function? |
Well, I didn't look at the class reference when I wrote that so def sv_get(self,default=None):
if self.links and not self.is_output:
return SvGetSocket(self)
elif prop_name:
return [[self.node[self.prop_name]]]
else:
return default |
But to write a method the for the sockets you can just write in node_s in the respective classes. |
http://www.blender.org/documentation/blender_python_api_2_70a_release/bpy.types.NodeSocket.html?highlight=socket#bpy.types.NodeSocket |
Look under Don't hesitate to ask. |
thanks, i'm blind OMG |
One of my early goals of the socket cache was to stop destroying data and to allow more complex data to exist between nodes. def sv_get(obj,name=''):
if isinstance(obj,NodeSocket):
return SvGetSocket(socket)
elif isinstance(obj,Node):
return SvGetSocket(obj.inputs[name])
else:
Error... We modify |
@zeffii
|
Also added |
|
History
All sockets had a String Property that was used to store the socket values.
self.outputs['Matrix'].MatrixProperty = str(matrixes)
And then they where read like this.
Integer = eval(self.inputs['Integer'].links[0].from_socket.StringsProperty)[0][0]
This was a simple good solution but obviously the biggest performance problem in Sverchok.
Performance testing from February:
"step 2 new" is where we are today.
Current implementation
def SvGetSocketAnyType(self, socket):
def SvSetSocketAnyType(self, socket_name, out):
Issues:
Note: This is because these functions are used in a way they were originally not planned to be used.
If we look at these function we see that already today they are only wrappers for another interface.
def SvSetSocket(socket, out):
def SvGetSocket(socket, copy = False):
These functions perform the actual Socket Cache functionality.
data=socket_data_cache[ng][s_id]
They maintain a socket cache for each nodegroup that is reset on each Edit event, see #121 .
Note This reset happens in the makeTreeUpdate2 function.
Still these names are longer than needed and before defining the new interface I think we should discuss it.
Data integrity.
Data is only stored for each output socket. But since this data can 1) be read many times by the same node using partial updates and 2) be read from many sockets. It needs to be ensured that it is not modified. Many nodes always create new data but some modify the input in place. To ensure safety and to be able to keep the nodes as black boxes the following is used.
This much quicker than the built in deepcopy function that is very advanced and can handle many scenarios. If you can make this function quicker everything in Sverchok goes quicker. Using this is instead of copy.deepcopy() is the only difference between "step 2" and "step 2 new"
This function parses the data on every get socket unless the copy parameter is set to True when it uses a shallow copy.
Future
Interface
I think the best idea is to implement socket data cache function on in the socket class.
So we can use
socket.get()
andsocket.set(data)
We could remove offload a lot of code for the nodes by providing an argument to be used instead if the socket isn't linked.
int=socket.get([[self.integer]])
An optional argument for shallow copy for nodes that do not modify data in place, that would be off by default since many strange things can start to happen then...
Moving to the socket interface to the socket class could also provide a simple way to make specialized interfaces for different socket types in the future.
Other ideas:
However the even more general approach to this is @vectorize decorator (one pass fits all) #105
Cache datum
To provide an integer for the last modified input so nodes can see which input has changed.
The integer would be globally updated and always increasing. However I am not sure if this is worth the effort right now.
Questions?
The text was updated successfully, but these errors were encountered: