summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hansen <markhansen@google.com>2021-09-28 12:58:09 +1000
committerMark Hansen <markhansen@google.com>2021-09-28 13:26:15 +1000
commit1a2ebeaa5baa0c0b22c73fbcf068e7082dacfe4d (patch)
tree5d297a6182f87cc38cde0a4263adf669d1c2e842
parent7065552bf01bf25e4471d7b54ee9f0426702a2cc (diff)
downloadextras-1a2ebeaa5baa0c0b22c73fbcf068e7082dacfe4d.tar.gz
Add pid & tid labels to pprof_proto_generator.py
Uses precedent set by perf_data_converter: https://github.com/google/perf_data_converter/blob/e8a65906a406fedcc0e78b75f95de16f2d99eecc/src/perf_data_converter.h#L57 Example on a Google Maps profile: ``` (pprof) tags pid: Total 103383248686.0 103383248686.0 ( 100%): 14330 tid: Total 103383248686.0 22119496619.0 (21.40%): 14364 13358985234.0 (12.92%): 14351 7386956769.0 ( 7.15%): 14352 5422475643.0 ( 5.25%): 14362 5307503967.0 ( 5.13%): 14346 5100700923.0 ( 4.93%): 14330 4790949129.0 ( 4.63%): 14370 3146972395.0 ( 3.04%): 14367 2886594038.0 ( 2.79%): 14384 2629996668.0 ( 2.54%): 14398 2614501772.0 ( 2.53%): 14401 2317441688.0 ( 2.24%): 14460 2268259602.0 ( 2.19%): 14408 2129146149.0 ( 2.06%): 14372 1862608311.0 ( 1.80%): 14459 [...] ``` BUG=200992206 Test: Ran test/test.py -p TestPprofProtoGenerator.\* Change-Id: Icbc1503ca05c46387eff3f6799f0c16df4b78001 Change-Id: I7aecbb9a520aa5f6b06f96a844050a2189d14a52
-rwxr-xr-xsimpleperf/scripts/pprof_proto_generator.py6
-rw-r--r--simpleperf/scripts/test/pprof_proto_generator_test.py2
2 files changed, 8 insertions, 0 deletions
diff --git a/simpleperf/scripts/pprof_proto_generator.py b/simpleperf/scripts/pprof_proto_generator.py
index b29634da..09d54d5f 100755
--- a/simpleperf/scripts/pprof_proto_generator.py
+++ b/simpleperf/scripts/pprof_proto_generator.py
@@ -332,6 +332,12 @@ class PprofProfileGenerator(object):
self.get_string_id("threadpool"),
self.get_string_id(
numbers_re.sub("%d", report_sample.thread_comm))))
+ sample.labels.append(Label(
+ self.get_string_id("pid"),
+ self.get_string_id(str(report_sample.pid))))
+ sample.labels.append(Label(
+ self.get_string_id("tid"),
+ self.get_string_id(str(report_sample.tid))))
if self._filter_symbol(symbol):
location_id = self.get_location_id(report_sample.ip, symbol)
sample.add_location_id(location_id)
diff --git a/simpleperf/scripts/test/pprof_proto_generator_test.py b/simpleperf/scripts/test/pprof_proto_generator_test.py
index 4a8de00b..e246faa7 100644
--- a/simpleperf/scripts/test/pprof_proto_generator_test.py
+++ b/simpleperf/scripts/test/pprof_proto_generator_test.py
@@ -57,6 +57,8 @@ class TestPprofProtoGenerator(TestBase):
self.assertIn('label[0] = thread:Binder:10419_3', output)
self.assertIn('label[0] = thread:Binder:10419_4', output)
self.assertIn('label[1] = threadpool:Binder:%d_%d', output)
+ self.assertIn('label[2] = pid:10419', output)
+ self.assertIn('label[3] = tid:10459', output)
def test_tid_filter(self):
key1 = 'art::ProfileSaver::Run()' # function in thread 10459