Skip to contentSkip to conversation

perf trace: Skip unnecessary synthesis for summary-only mode

PATCH Superseded Namhyung Kim 2 participants 3 messages Mar 30 – Mar 31 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf trace: Skip unnecessary synthesis for summary-only mode

It needs to synthesize task info for the comm name. The mmap information is only needed for callchain symbolization which is not used by the summary mode. Also total or cgroup summary mode don't require the task info. Let's skip the processing if possible.

---
 tools/perf/builtin-trace.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
tools/perf/builtin-trace.c +17 -5
index f487fbaa0ad60028..d09d78b3222717d1 100644
@@ -2004,11 +2004,23 @@ static int trace__symbols_init(struct trace *trace, int argc, const char **argv,
 	if (err < 0)
 		goto out;
 
-	err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
-					    evlist->core.threads, trace__tool_process,
-					    /*needs_mmap=*/callchain_param.enabled,
-					    /*mmap_data=*/false,
-					    /*nr_threads_synthesize=*/1);
+	if (trace->summary_only) {
+		if (trace->summary_mode == SUMMARY__BY_THREAD) {
+			err = __machine__synthesize_threads(trace->host, &trace->tool,
+							    &trace->opts.target,
+							    evlist->core.threads,
+							    trace__tool_process,
+							    /*needs_mmap=*/false,
+							    /*mmap_data=*/false,
+							    /*nr_threads_synthesize=*/1);
+		}
+	} else {
+		err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
+						    evlist->core.threads, trace__tool_process,
+						    /*needs_mmap=*/callchain_param.enabled,
+						    /*mmap_data=*/false,
+						    /*nr_threads_synthesize=*/1);
+	}
 out:
 	if (err) {
 		perf_env__exit(&trace->host_env);
Signature · 1 line
2.53.0.1185.g05d4b7b318-goog
reviewer
#1 lore raw
Quoted 31 lines · Namhyung Kim

It needs to synthesize task info for the comm name. The mmap information is only needed for callchain symbolization which is not used by the summary mode. Also total or cgroup summary mode don't require the task info. Let's skip the processing if possible.

---
 tools/perf/builtin-trace.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
tools/perf/builtin-trace.c +7 -5
index f487fbaa0ad60028..d09d78b3222717d1 100644
@@ -2004,11 +2004,23 @@ static int trace__symbols_init(struct trace *trace, int argc, const char **argv,
        if (err < 0)
                goto out;
 
-       err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
-                                           evlist->core.threads, trace__tool_process,
-                                           /*needs_mmap=*/callchain_param.enabled,
-                                           /*mmap_data=*/false,
-                                           /*nr_threads_synthesize=*/1);
+       if (trace->summary_only) {
+               if (trace->summary_mode == SUMMARY__BY_THREAD) {
+                       err = __machine__synthesize_threads(trace->host, &trace->tool,
+                                                           &trace->opts.target,
+                                                           evlist->core.threads,
+                                                           trace__tool_process,
+                                                           /*needs_mmap=*/false,

tools/perf/builtin-trace.c static int trace__symbols_init(struct trace *trace, int argc, const char **argv, · line 2023

Quoted 10 lines
tools/perf/builtin-trace.c +10 -0
+                                                           /*mmap_data=*/false,
+                                                           /*nr_threads_synthesize=*/1);
+               }
+       } else {
+               err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
+                                                   evlist->core.threads, trace__tool_process,
+                                                   /*needs_mmap=*/callchain_param.enabled,
+                                                   /*mmap_data=*/false,
+                                                   /*nr_threads_synthesize=*/1);
+       }

Could this be simplified to something like:

```
if (!trace->summary_only || trace->summary_mode == SUMMARY__BY_THREAD) {
       err = __machine__synthesize_threads(trace->host, &trace->tool,
&trace->opts.target,
                                           evlist->core.threads,
trace__tool_process,

/*needs_mmap=*/callchain_param.enabled && !trace->summary_only,
                                           /*mmap_data=*/false,
                                           /*nr_threads_synthesize=*/1);
}
```

Thanks,
Ian

Quoted 6 lines
tools/perf/builtin-trace.c +0 -1
 out:
        if (err) {
                perf_env__exit(&trace->host_env);
--

2.53.0.1185.g05d4b7b318-goog

author maintainer
#2 lore raw
Quoted 44 lines · Ian Rogers
Quoted 31 lines · Namhyung Kim

It needs to synthesize task info for the comm name. The mmap information is only needed for callchain symbolization which is not used by the summary mode. Also total or cgroup summary mode don't require the task info. Let's skip the processing if possible.

---
 tools/perf/builtin-trace.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
tools/perf/builtin-trace.c +7 -5
index f487fbaa0ad60028..d09d78b3222717d1 100644
@@ -2004,11 +2004,23 @@ static int trace__symbols_init(struct trace *trace, int argc, const char **argv,
        if (err < 0)
                goto out;
 
-       err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
-                                           evlist->core.threads, trace__tool_process,
-                                           /*needs_mmap=*/callchain_param.enabled,
-                                           /*mmap_data=*/false,
-                                           /*nr_threads_synthesize=*/1);
+       if (trace->summary_only) {
+               if (trace->summary_mode == SUMMARY__BY_THREAD) {
+                       err = __machine__synthesize_threads(trace->host, &trace->tool,
+                                                           &trace->opts.target,
+                                                           evlist->core.threads,
+                                                           trace__tool_process,
+                                                           /*needs_mmap=*/false,

tools/perf/builtin-trace.c static int trace__symbols_init(struct trace *trace, int argc, const char **argv, · line 2023

Quoted 10 lines
tools/perf/builtin-trace.c +10 -0
+                                                           /*mmap_data=*/false,
+                                                           /*nr_threads_synthesize=*/1);
+               }
+       } else {
+               err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
+                                                   evlist->core.threads, trace__tool_process,
+                                                   /*needs_mmap=*/callchain_param.enabled,
+                                                   /*mmap_data=*/false,
+                                                   /*nr_threads_synthesize=*/1);
+       }

Could this be simplified to something like:

Quoted 12 lines
```
if (!trace->summary_only || trace->summary_mode == SUMMARY__BY_THREAD) {
       err = __machine__synthesize_threads(trace->host, &trace->tool,
&trace->opts.target,
                                           evlist->core.threads,
trace__tool_process,

/*needs_mmap=*/callchain_param.enabled && !trace->summary_only,
                                           /*mmap_data=*/false,
                                           /*nr_threads_synthesize=*/1);
}
```

Looks good, will update.

Btw, it'd be nice if you could find a mail client that can turn off the line wrapping. :)

Thanks,
Namhyung