From 40488038cf6cff16d4d4ec1e3bb4bdf7092f6beb Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 5 Sep 2025 13:00:24 +0200 Subject: [PATCH] Geometry Nodes: optimize group input logging Previously, group input values were logged for each group input socket. This means that each value might be logged many times currently when there are many Group Input nodes. This patch changes it so that group input values are only logged for a single socket. In the provided file from #145385 this speeds up playback performance from 23 to 39 fps. The next bottleneck there is node editor drawing. If I change the Geometry Nodes editor to another editor type the speedup is 36 (`main`) to 110 fps (this patch). Pull Request: https://projects.blender.org/blender/blender/pulls/145781 --- .../nodes/intern/geometry_nodes_lazy_function.cc | 8 ++++++-- source/blender/nodes/intern/geometry_nodes_log.cc | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc index 1f683ed7111..f3750e29fad 100644 --- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc +++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc @@ -1764,11 +1764,15 @@ class GeometryNodesLazyFunctionLogger : public lf::GraphExecutor::Logger { return; } - const Span bsockets = - lf_graph_info_.mapping.bsockets_by_lf_socket_map.lookup(&lf_socket); + Span bsockets = lf_graph_info_.mapping.bsockets_by_lf_socket_map.lookup( + &lf_socket); if (bsockets.is_empty()) { return; } + if (bsockets[0]->owner_node().is_group_input()) { + /* Only log a group input once instead of for every group input node separately. */ + bsockets = bsockets.take_front(1); + } for (const bNodeSocket *bsocket : bsockets) { /* Avoid logging to some sockets when the same value will also be logged to a linked socket. diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index ca61deb04c4..d3cc3e7947a 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -688,6 +688,7 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) Stack sockets_to_check; sockets_to_check.push(&query_socket); added_sockets.add(&query_socket); + const bNodeTree &tree = query_socket.owner_tree(); while (!sockets_to_check.is_empty()) { const bNodeSocket &socket = *sockets_to_check.pop(); @@ -738,6 +739,16 @@ ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket) } } } + else if (node.is_group_input()) { + const int index = socket.index(); + /* Check if the value is stored for any other group input node. */ + for (const bNode *other_group_input : tree.group_input_nodes()) { + const bNodeSocket &other_socket = other_group_input->output_socket(index); + if (added_sockets.add(&other_socket)) { + sockets_to_check.push(&other_socket); + } + } + } } }