diff options
author | Mark Hansen <markhansen@google.com> | 2021-08-24 22:00:15 +0000 |
---|---|---|
committer | Mark Hansen <markhansen@google.com> | 2021-08-24 22:00:19 +0000 |
commit | 172b8e0ed7c9bc602ed551b65edc504bea87c79a (patch) | |
tree | 699a3b06e859154cc6e09d06d3241a6b9242b170 | |
parent | a0defc66dc597813a14de6e6fb17d9f43ad67c45 (diff) | |
download | extras-172b8e0ed7c9bc602ed551b65edc504bea87c79a.tar.gz |
Add "thread" label to pprof_proto_generator
This can be used with pprof tag filtering to filter to specific tags interactively:
https://github.com/google/pprof/blob/master/doc/README.md#tag-filtering
The "thread" label is fairly well-established on the server side pprof for logging multiple threads.
Change-Id: If8cb30c80763fc6c442cdc9c662e937af64d0289
-rwxr-xr-x | simpleperf/scripts/pprof_proto_generator.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/simpleperf/scripts/pprof_proto_generator.py b/simpleperf/scripts/pprof_proto_generator.py index 1abfcbb5..eb49c99d 100755 --- a/simpleperf/scripts/pprof_proto_generator.py +++ b/simpleperf/scripts/pprof_proto_generator.py @@ -107,7 +107,8 @@ class PprofProfilePrinter(object): for i in range(len(sample.value)): print('%svalue[%d] = %d' % (space, i, sample.value[i])) for i in range(len(sample.label)): - print('%slabel[%d] = ', (space, i)) + print('%slabel[%d] = %s:%s' % (space, i, self.string(sample.label[i].key), + self.string(sample.label[i].str))) def show_location_id(self, location_id, space=''): location = self.profile.location[location_id - 1] @@ -162,11 +163,19 @@ class PprofProfilePrinter(object): return self.string_table[string_id] +class Label(object): + def __init__(self, key_id: int, str_id: int): + # See profile.Label.key + self.key_id = key_id + # See profile.Label.str + self.str_id = str_id + class Sample(object): def __init__(self): self.location_ids = [] self.values = {} + self.labels = [] def add_location_id(self, location_id): self.location_ids.append(location_id) @@ -311,6 +320,9 @@ class PprofProfileGenerator(object): sample = Sample() sample.add_value(sample_type_id, 1) sample.add_value(sample_type_id + 1, report_sample.period) + label = Label(self.get_string_id("thread"), + self.get_string_id(report_sample.thread_comm)) + sample.labels.append(label) if self._filter_symbol(symbol): location_id = self.get_location_id(report_sample.ip, symbol) sample.add_location_id(location_id) @@ -554,6 +566,11 @@ class PprofProfileGenerator(object): values[sample_type_id] = sample.values[sample_type_id] profile_sample.value.extend(values) + for l in sample.labels: + label = profile_sample.label.add() + label.key = l.key_id + label.str = l.str_id + def gen_profile_mapping(self, mapping): profile_mapping = self.profile.mapping.add() profile_mapping.id = mapping.id |