From d226c0d97de5ba1b34970d0df8e469b22ba79c34 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Fri, 7 Nov 2025 02:56:58 +0000 Subject: [PATCH] u_trace: remove redundant char* to string conversion (v2) Add the string length parameter to the set_name(), set_value() function to remove the conversion from char* to std::string which takes extra work like calling strlen() to compute the string length. From the callback sampling in the perfetto tracing, the ratio of trace_payload_as_extra_intel_end_draw_indexed to intel_ds_end_draw_indexed drops from 63.80% to 59.65% with this change. v2: Add the data of the callback sampling to the description. Signed-off-by: Andy Hsu Reviewed-by: Yiwei Zhang Part-of: --- src/util/perf/u_trace.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/perf/u_trace.py b/src/util/perf/u_trace.py index 1e0443774f2..f1640b66af4 100644 --- a/src/util/perf/u_trace.py +++ b/src/util/perf/u_trace.py @@ -711,14 +711,14 @@ trace_payload_as_extra_${trace_name}(perfetto::protos::pbzero::GpuRenderStageEve % else: { auto data = event->add_extra_data(); - data->set_name("${arg.name}"); + data->set_name("${arg.name}", ${len(arg.name)}); % if arg.is_indirect: const ${arg.type}* __${arg.var} = (const ${arg.type}*)((uint8_t *)indirect_data + ${arg.indirect_offset}); % endif - sprintf(buf, "${arg.c_format}", ${arg.value_expr("payload")}); + const int slen = sprintf(buf, "${arg.c_format}", ${arg.value_expr("payload")}); - data->set_value(buf); + data->set_value(buf, slen); } % endif % endfor