Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-09-17 13:08:43 +0300
committerJacques Lucke <jacques@blender.org>2022-09-17 13:08:57 +0300
commit7549e0c5ae36be739f0e0a38e87eb85428808e89 (patch)
treed931c76b0001cfc5bea7ac3f29287d91713ef5ac /source/blender/nodes
parent1810b1e4c88191e3578518e12f9f3d318e08dc60 (diff)
Geometry Nodes: use stringref instead of string in logger
This reduces logging overhead. The performance difference is only significant when there are many fast nodes. In my test file with many math nodes, the performance improved from 720ms to 630ms.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/NOD_geometry_exec.hh4
-rw-r--r--source/blender/nodes/NOD_geometry_nodes_log.hh34
-rw-r--r--source/blender/nodes/intern/geometry_nodes_lazy_function.cc3
-rw-r--r--source/blender/nodes/intern/geometry_nodes_log.cc14
-rw-r--r--source/blender/nodes/intern/node_geometry_exec.cc12
5 files changed, 37 insertions, 30 deletions
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 16669f7cfce..73e82f741ab 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -237,13 +237,13 @@ class GeoNodeExecParams {
* Add an error message displayed at the top of the node when displaying the node tree,
* and potentially elsewhere in Blender.
*/
- void error_message_add(const NodeWarningType type, std::string message) const;
+ void error_message_add(const NodeWarningType type, StringRef message) const;
std::string attribute_producer_name() const;
void set_default_remaining_outputs();
- void used_named_attribute(std::string attribute_name, NamedAttributeUsage usage);
+ void used_named_attribute(StringRef attribute_name, NamedAttributeUsage usage);
private:
/* Utilities for detecting common errors at when using this class. */
diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh b/source/blender/nodes/NOD_geometry_nodes_log.hh
index dd4868b6ba0..cf59c99bc79 100644
--- a/source/blender/nodes/NOD_geometry_nodes_log.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_log.hh
@@ -169,37 +169,37 @@ using TimePoint = Clock::time_point;
class GeoTreeLogger {
public:
std::optional<ComputeContextHash> parent_hash;
- std::optional<std::string> group_node_name;
+ std::optional<StringRefNull> group_node_name;
Vector<ComputeContextHash> children_hashes;
LinearAllocator<> *allocator = nullptr;
struct WarningWithNode {
- std::string node_name;
+ StringRefNull node_name;
NodeWarning warning;
};
struct SocketValueLog {
- std::string node_name;
- std::string socket_identifier;
+ StringRefNull node_name;
+ StringRefNull socket_identifier;
destruct_ptr<ValueLog> value;
};
struct NodeExecutionTime {
- std::string node_name;
+ StringRefNull node_name;
TimePoint start;
TimePoint end;
};
struct ViewerNodeLogWithNode {
- std::string node_name;
+ StringRefNull node_name;
destruct_ptr<ViewerNodeLog> viewer_log;
};
struct AttributeUsageWithNode {
- std::string node_name;
- std::string attribute_name;
+ StringRefNull node_name;
+ StringRefNull attribute_name;
NamedAttributeUsage usage;
};
struct DebugMessage {
- std::string node_name;
- std::string message;
+ StringRefNull node_name;
+ StringRefNull message;
};
Vector<WarningWithNode> node_warnings;
@@ -235,12 +235,12 @@ class GeoNodeLog {
*/
std::chrono::nanoseconds run_time{0};
/** Maps from socket identifiers to their values. */
- Map<std::string, ValueLog *> input_values_;
- Map<std::string, ValueLog *> output_values_;
+ Map<StringRefNull, ValueLog *> input_values_;
+ Map<StringRefNull, ValueLog *> output_values_;
/** Maps from attribute name to their usage flags. */
- Map<std::string, NamedAttributeUsage> used_named_attributes;
+ Map<StringRefNull, NamedAttributeUsage> used_named_attributes;
/** Messages that are used for debugging purposes during development. */
- Vector<std::string> debug_messages;
+ Vector<StringRefNull> debug_messages;
GeoNodeLog();
~GeoNodeLog();
@@ -269,12 +269,12 @@ class GeoTreeLog {
bool reduced_debug_messages_ = false;
public:
- Map<std::string, GeoNodeLog> nodes;
- Map<std::string, ViewerNodeLog *, 0> viewer_node_logs;
+ Map<StringRefNull, GeoNodeLog> nodes;
+ Map<StringRefNull, ViewerNodeLog *, 0> viewer_node_logs;
Vector<NodeWarning> all_warnings;
std::chrono::nanoseconds run_time_sum{0};
Vector<const GeometryAttributeInfo *> existing_attributes;
- Map<std::string, NamedAttributeUsage> used_named_attributes;
+ Map<StringRefNull, NamedAttributeUsage> used_named_attributes;
GeoTreeLog(GeoModifierLog *modifier_log, Vector<GeoTreeLogger *> tree_loggers);
~GeoTreeLog();
diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc
index 137057414d4..996cea26718 100644
--- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc
+++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc
@@ -134,7 +134,8 @@ class LazyFunctionForGeometryNode : public LazyFunction {
if (geo_eval_log::GeoModifierLog *modifier_log = user_data->modifier_data->eval_log) {
geo_eval_log::GeoTreeLogger &tree_logger = modifier_log->get_local_tree_logger(
*user_data->compute_context);
- tree_logger.node_execution_times.append({node_.name, start_time, end_time});
+ tree_logger.node_execution_times.append(
+ {tree_logger.allocator->copy_string(node_.name), start_time, end_time});
}
}
};
diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc
index 350b199cd60..110573c9119 100644
--- a/source/blender/nodes/intern/geometry_nodes_log.cc
+++ b/source/blender/nodes/intern/geometry_nodes_log.cc
@@ -148,7 +148,9 @@ void GeoTreeLogger::log_value(const bNode &node, const bNodeSocket &socket, cons
auto store_logged_value = [&](destruct_ptr<ValueLog> value_log) {
auto &socket_values = socket.in_out == SOCK_IN ? this->input_socket_values :
this->output_socket_values;
- socket_values.append({node.name, socket.identifier, std::move(value_log)});
+ socket_values.append({this->allocator->copy_string(node.name),
+ this->allocator->copy_string(socket.identifier),
+ std::move(value_log)});
};
auto log_generic_value = [&](const CPPType &type, const void *value) {
@@ -194,7 +196,7 @@ void GeoTreeLogger::log_viewer_node(const bNode &viewer_node,
log->geometry = geometry;
log->field = field;
log->geometry.ensure_owns_direct_data();
- this->viewer_node_logs.append({viewer_node.name, std::move(log)});
+ this->viewer_node_logs.append({this->allocator->copy_string(viewer_node.name), std::move(log)});
}
void GeoTreeLog::ensure_node_warnings()
@@ -315,11 +317,11 @@ void GeoTreeLog::ensure_used_named_attributes()
return;
}
- auto add_attribute = [&](const StringRef node_name,
- const StringRef attribute_name,
+ auto add_attribute = [&](const StringRefNull node_name,
+ const StringRefNull attribute_name,
const NamedAttributeUsage &usage) {
- this->nodes.lookup_or_add_as(node_name).used_named_attributes.lookup_or_add_as(attribute_name,
- usage) |= usage;
+ this->nodes.lookup_or_add_default(node_name).used_named_attributes.lookup_or_add(
+ attribute_name, usage) |= usage;
this->used_named_attributes.lookup_or_add_as(attribute_name, usage) |= usage;
};
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc
index 1833774fe33..1de92fa8409 100644
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@ -13,18 +13,22 @@
namespace blender::nodes {
-void GeoNodeExecParams::error_message_add(const NodeWarningType type, std::string message) const
+void GeoNodeExecParams::error_message_add(const NodeWarningType type,
+ const StringRef message) const
{
if (geo_eval_log::GeoTreeLogger *tree_logger = this->get_local_tree_logger()) {
- tree_logger->node_warnings.append({node_.name, {type, std::move(message)}});
+ tree_logger->node_warnings.append({tree_logger->allocator->copy_string(node_.name),
+ {type, tree_logger->allocator->copy_string(message)}});
}
}
-void GeoNodeExecParams::used_named_attribute(std::string attribute_name,
+void GeoNodeExecParams::used_named_attribute(const StringRef attribute_name,
const NamedAttributeUsage usage)
{
if (geo_eval_log::GeoTreeLogger *tree_logger = this->get_local_tree_logger()) {
- tree_logger->used_named_attributes.append({node_.name, std::move(attribute_name), usage});
+ tree_logger->used_named_attributes.append({tree_logger->allocator->copy_string(node_.name),
+ tree_logger->allocator->copy_string(attribute_name),
+ usage});
}
}