Nodes: optimize socket usage inferencing for many group inputs
This was found to be a bottleneck in the file from #144756 which has 235 group inputs and 174 group input nodes, which leads to 40,890 sockets. Most of those are never used, so it's wasteful to add them to the map of input values. The inferencing time improved from 24ms to 16ms. Can likely still be improved more, but that's a good improvement for such a small change already.
This commit is contained in:
@@ -85,6 +85,12 @@ struct SocketUsageInferencer {
|
||||
for (const bNode *node : root_tree_.group_input_nodes()) {
|
||||
for (const int i : root_tree_.interface_inputs().index_range()) {
|
||||
const bNodeSocket &socket = node->output_socket(i);
|
||||
if (!socket.is_directly_linked()) {
|
||||
/* This socket is not linked, hence it's value is never used. Thus we don't have to add
|
||||
* it to #all_socket_values_. This optimization helps a lot when the node group has a
|
||||
* very large number of inputs and group input nodes. */
|
||||
continue;
|
||||
}
|
||||
const SocketInContext socket_in_context{nullptr, &socket};
|
||||
const void *input_value = nullptr;
|
||||
if (!this->treat_socket_as_unknown(socket_in_context)) {
|
||||
|
||||
Reference in New Issue
Block a user