Skip to content

Commit

Permalink
Merge "Add PerfTracker" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
carlscabgro authored and Gerrit Code Review committed Nov 21, 2024
2 parents 834aa3b + 4c62312 commit 57e9e9c
Show file tree
Hide file tree
Showing 28 changed files with 485 additions and 503 deletions.
17 changes: 1 addition & 16 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,6 @@ cc_test {
":perfetto_src_trace_processor_importers_perf_text_perf_text",
":perfetto_src_trace_processor_importers_perf_text_perf_text_event",
":perfetto_src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":perfetto_src_trace_processor_importers_perf_tracker",
":perfetto_src_trace_processor_importers_proto_full",
":perfetto_src_trace_processor_importers_proto_minimal",
":perfetto_src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down Expand Up @@ -12698,11 +12697,11 @@ filegroup {
"src/trace_processor/importers/perf/aux_stream_manager.cc",
"src/trace_processor/importers/perf/auxtrace_info_record.cc",
"src/trace_processor/importers/perf/auxtrace_record.cc",
"src/trace_processor/importers/perf/etm_tokenizer.cc",
"src/trace_processor/importers/perf/features.cc",
"src/trace_processor/importers/perf/itrace_start_record.cc",
"src/trace_processor/importers/perf/mmap_record.cc",
"src/trace_processor/importers/perf/perf_data_tokenizer.cc",
"src/trace_processor/importers/perf/perf_tracker.cc",
"src/trace_processor/importers/perf/record_parser.cc",
"src/trace_processor/importers/perf/sample.cc",
"src/trace_processor/importers/perf/sample_id.cc",
Expand Down Expand Up @@ -12743,14 +12742,6 @@ filegroup {
],
}

// GN: //src/trace_processor/importers/perf:tracker
filegroup {
name: "perfetto_src_trace_processor_importers_perf_tracker",
srcs: [
"src/trace_processor/importers/perf/dso_tracker.cc",
],
}

// GN: //src/trace_processor/importers/perf:unittests
filegroup {
name: "perfetto_src_trace_processor_importers_perf_unittests",
Expand Down Expand Up @@ -15685,7 +15676,6 @@ cc_test {
":perfetto_src_trace_processor_importers_perf_text_perf_text",
":perfetto_src_trace_processor_importers_perf_text_perf_text_event",
":perfetto_src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":perfetto_src_trace_processor_importers_perf_tracker",
":perfetto_src_trace_processor_importers_perf_unittests",
":perfetto_src_trace_processor_importers_proto_full",
":perfetto_src_trace_processor_importers_proto_minimal",
Expand Down Expand Up @@ -16760,7 +16750,6 @@ cc_binary {
":perfetto_src_trace_processor_importers_perf_text_perf_text",
":perfetto_src_trace_processor_importers_perf_text_perf_text_event",
":perfetto_src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":perfetto_src_trace_processor_importers_perf_tracker",
":perfetto_src_trace_processor_importers_proto_full",
":perfetto_src_trace_processor_importers_proto_minimal",
":perfetto_src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down Expand Up @@ -16978,7 +16967,6 @@ cc_binary {
":perfetto_protos_perfetto_trace_system_info_zero_gen",
":perfetto_protos_perfetto_trace_track_event_zero_gen",
":perfetto_protos_perfetto_trace_translation_zero_gen",
":perfetto_protos_third_party_simpleperf_zero_gen",
":perfetto_src_base_base",
":perfetto_src_protozero_protozero",
":perfetto_src_trace_processor_containers_containers",
Expand All @@ -17000,7 +16988,6 @@ cc_binary {
":perfetto_src_trace_processor_importers_perf_record",
":perfetto_src_trace_processor_importers_perf_text_perf_text_event",
":perfetto_src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":perfetto_src_trace_processor_importers_perf_tracker",
":perfetto_src_trace_processor_importers_proto_minimal",
":perfetto_src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
":perfetto_src_trace_processor_importers_proto_proto_importer_module",
Expand Down Expand Up @@ -17067,7 +17054,6 @@ cc_binary {
"perfetto_protos_perfetto_trace_system_info_zero_gen_headers",
"perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
"perfetto_protos_perfetto_trace_translation_zero_gen_headers",
"perfetto_protos_third_party_simpleperf_zero_gen_headers",
"perfetto_src_trace_processor_importers_proto_gen_cc_android_track_event_descriptor",
"perfetto_src_trace_processor_importers_proto_gen_cc_chrome_track_event_descriptor",
"perfetto_src_trace_processor_importers_proto_gen_cc_track_event_descriptor",
Expand Down Expand Up @@ -17192,7 +17178,6 @@ cc_binary_host {
":perfetto_src_trace_processor_importers_perf_text_perf_text",
":perfetto_src_trace_processor_importers_perf_text_perf_text_event",
":perfetto_src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":perfetto_src_trace_processor_importers_perf_tracker",
":perfetto_src_trace_processor_importers_proto_full",
":perfetto_src_trace_processor_importers_proto_minimal",
":perfetto_src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down
17 changes: 2 additions & 15 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ perfetto_cc_library(
":src_trace_processor_importers_perf_text_perf_text",
":src_trace_processor_importers_perf_text_perf_text_event",
":src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":src_trace_processor_importers_perf_tracker",
":src_trace_processor_importers_proto_full",
":src_trace_processor_importers_proto_minimal",
":src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down Expand Up @@ -2041,8 +2040,6 @@ perfetto_filegroup(
"src/trace_processor/importers/perf/auxtrace_info_record.h",
"src/trace_processor/importers/perf/auxtrace_record.cc",
"src/trace_processor/importers/perf/auxtrace_record.h",
"src/trace_processor/importers/perf/etm_tokenizer.cc",
"src/trace_processor/importers/perf/etm_tokenizer.h",
"src/trace_processor/importers/perf/features.cc",
"src/trace_processor/importers/perf/features.h",
"src/trace_processor/importers/perf/itrace_start_record.cc",
Expand All @@ -2052,6 +2049,8 @@ perfetto_filegroup(
"src/trace_processor/importers/perf/perf_data_tokenizer.cc",
"src/trace_processor/importers/perf/perf_data_tokenizer.h",
"src/trace_processor/importers/perf/perf_file.h",
"src/trace_processor/importers/perf/perf_tracker.cc",
"src/trace_processor/importers/perf/perf_tracker.h",
"src/trace_processor/importers/perf/record_parser.cc",
"src/trace_processor/importers/perf/record_parser.h",
"src/trace_processor/importers/perf/sample.cc",
Expand Down Expand Up @@ -2084,15 +2083,6 @@ perfetto_filegroup(
],
)

# GN target: //src/trace_processor/importers/perf:tracker
perfetto_filegroup(
name = "src_trace_processor_importers_perf_tracker",
srcs = [
"src/trace_processor/importers/perf/dso_tracker.cc",
"src/trace_processor/importers/perf/dso_tracker.h",
],
)

# GN target: //src/trace_processor/importers/perf_text:perf_text
perfetto_filegroup(
name = "src_trace_processor_importers_perf_text_perf_text",
Expand Down Expand Up @@ -6597,7 +6587,6 @@ perfetto_cc_library(
":src_trace_processor_importers_perf_text_perf_text",
":src_trace_processor_importers_perf_text_perf_text_event",
":src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":src_trace_processor_importers_perf_tracker",
":src_trace_processor_importers_proto_full",
":src_trace_processor_importers_proto_minimal",
":src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down Expand Up @@ -6802,7 +6791,6 @@ perfetto_cc_binary(
":src_trace_processor_importers_perf_text_perf_text",
":src_trace_processor_importers_perf_text_perf_text_event",
":src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":src_trace_processor_importers_perf_tracker",
":src_trace_processor_importers_proto_full",
":src_trace_processor_importers_proto_minimal",
":src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down Expand Up @@ -6996,7 +6984,6 @@ perfetto_cc_binary(
":src_trace_processor_importers_perf_text_perf_text",
":src_trace_processor_importers_perf_text_perf_text_event",
":src_trace_processor_importers_perf_text_perf_text_sample_line_parser",
":src_trace_processor_importers_perf_tracker",
":src_trace_processor_importers_proto_full",
":src_trace_processor_importers_proto_minimal",
":src_trace_processor_importers_proto_packet_sequence_state_generation_hdr",
Expand Down
1 change: 0 additions & 1 deletion src/trace_processor/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ source_set("storage_minimal") {
"importers/ftrace:minimal",
"importers/fuchsia:fuchsia_record",
"importers/memory_tracker:graph_processor",
"importers/perf:tracker",
"importers/proto:gen_cc_android_track_event_descriptor",
"importers/proto:gen_cc_chrome_track_event_descriptor",
"importers/proto:gen_cc_track_event_descriptor",
Expand Down
21 changes: 2 additions & 19 deletions src/trace_processor/importers/perf/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,6 @@ source_set("record") {
]
}

source_set("tracker") {
sources = [
"dso_tracker.cc",
"dso_tracker.h",
]
deps = [
"../../../../gn:default_deps",
"../../../../include/perfetto/ext/base:base",
"../../../../protos/third_party/simpleperf:zero",
"../..//storage:storage",
"../..//tables:tables",
"../..//types:types",
"../common:common",
]
}

source_set("perf") {
sources = [
"attrs_section_reader.cc",
Expand All @@ -71,8 +55,6 @@ source_set("perf") {
"auxtrace_info_record.h",
"auxtrace_record.cc",
"auxtrace_record.h",
"etm_tokenizer.cc",
"etm_tokenizer.h",
"features.cc",
"features.h",
"itrace_start_record.cc",
Expand All @@ -82,6 +64,8 @@ source_set("perf") {
"perf_data_tokenizer.cc",
"perf_data_tokenizer.h",
"perf_file.h",
"perf_tracker.cc",
"perf_tracker.h",
"record_parser.cc",
"record_parser.h",
"sample.cc",
Expand All @@ -98,7 +82,6 @@ source_set("perf") {
]
public_deps = [ ":record" ]
deps = [
":tracker",
"../../../../gn:default_deps",
"../../../../protos/perfetto/common:zero",
"../../../../protos/perfetto/trace:zero",
Expand Down
25 changes: 16 additions & 9 deletions src/trace_processor/importers/perf/aux_data_tokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "perfetto/base/status.h"
#include "perfetto/trace_processor/trace_blob_view.h"
#include "src/trace_processor/importers/perf/aux_record.h"
#include "src/trace_processor/importers/perf/aux_stream_manager.h"
#include "src/trace_processor/importers/perf/itrace_start_record.h"
#include "src/trace_processor/storage/stats.h"
#include "src/trace_processor/storage/trace_storage.h"
Expand All @@ -31,26 +30,34 @@
namespace perfetto::trace_processor::perf_importer {

AuxDataTokenizer::~AuxDataTokenizer() = default;
AuxDataTokenizerFactory::~AuxDataTokenizerFactory() = default;
AuxDataStream::~AuxDataStream() = default;

DummyAuxDataTokenizer::DummyAuxDataTokenizer(TraceProcessorContext* context,
AuxStream*)
: context_(context) {}
DummyAuxDataTokenizer::DummyAuxDataTokenizer(TraceProcessorContext* context)
: stream_(context) {}

DummyAuxDataTokenizer::~DummyAuxDataTokenizer() = default;

void DummyAuxDataTokenizer::OnDataLoss(uint64_t size) {
base::StatusOr<AuxDataStream*> DummyAuxDataTokenizer::InitializeAuxDataStream(
AuxStream*) {
return &stream_;
}

DummyAuxDataStream::DummyAuxDataStream(TraceProcessorContext* context)
: context_(context) {}
void DummyAuxDataStream::OnDataLoss(uint64_t size) {
context_->storage->IncrementStats(stats::perf_aux_lost,
static_cast<int>(size));
}
base::Status DummyAuxDataTokenizer::Parse(AuxRecord, TraceBlobView data) {
base::Status DummyAuxDataStream::Parse(AuxRecord, TraceBlobView data) {
context_->storage->IncrementStats(stats::perf_aux_ignored,
static_cast<int>(data.size()));
return base::OkStatus();
}
base::Status DummyAuxDataTokenizer::NotifyEndOfStream() {
base::Status DummyAuxDataStream::NotifyEndOfStream() {
return base::OkStatus();
}

base::Status DummyAuxDataTokenizer::OnItraceStartRecord(ItraceStartRecord) {
base::Status DummyAuxDataStream::OnItraceStartRecord(ItraceStartRecord) {
return base::OkStatus();
}

Expand Down
47 changes: 21 additions & 26 deletions src/trace_processor/importers/perf/aux_data_tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define SRC_TRACE_PROCESSOR_IMPORTERS_PERF_AUX_DATA_TOKENIZER_H_

#include <cstdint>
#include <functional>
#include <memory>

#include "perfetto/base/status.h"
Expand All @@ -36,47 +37,33 @@ struct AuxRecord;
class AuxStream;
struct ItraceStartRecord;

class AuxDataTokenizer {
class AuxDataStream {
public:
virtual ~AuxDataTokenizer();
virtual ~AuxDataStream();
virtual void OnDataLoss(uint64_t) = 0;
virtual base::Status Parse(AuxRecord record, TraceBlobView data) = 0;
virtual base::Status NotifyEndOfStream() = 0;
virtual base::Status OnItraceStartRecord(ItraceStartRecord start) = 0;
};

// Base class for `AuxDataTokenizer` factories.
// Base class for aux data tokenizers.
// A factory is created upon encountering an AUXTRACE_INFO record. the payload
// for such messages usually contains trace specific information to setup trace
// specific parsing. Subclasses are responsible for parsing the payload and
// storing any data needed to create `AuxDataTokenizer` instances as new data
// storing any data needed to create `AuxDataStream` instances as new data
// streams are encountered in the trace.
class AuxDataTokenizerFactory {
class AuxDataTokenizer {
public:
virtual ~AuxDataTokenizerFactory();
virtual base::StatusOr<std::unique_ptr<AuxDataTokenizer>> Create(
TraceProcessorContext* context,
virtual ~AuxDataTokenizer();
virtual base::StatusOr<AuxDataStream*> InitializeAuxDataStream(
AuxStream* stream) = 0;
};

// Generic `AuxDataTokenizerFactory` implementation for factories that keep no
// state.
template <typename Tokenizer>
class SimpleAuxDataTokenizerFactory : public AuxDataTokenizerFactory {
public:
SimpleAuxDataTokenizerFactory() {}
base::StatusOr<std::unique_ptr<AuxDataTokenizer>> Create(
TraceProcessorContext* context,
AuxStream* stream) override {
return std::unique_ptr<AuxDataTokenizer>(new Tokenizer(context, stream));
}
};

// Dummy tokenizer that just discard data.
// Used to skip streams that we do not know how to parse.
class DummyAuxDataTokenizer : public AuxDataTokenizer {
class DummyAuxDataStream : public AuxDataStream {
public:
DummyAuxDataTokenizer(TraceProcessorContext* context, AuxStream* stream);
explicit DummyAuxDataStream(TraceProcessorContext* context);
void OnDataLoss(uint64_t size) override;
base::Status Parse(AuxRecord, TraceBlobView data) override;
base::Status NotifyEndOfStream() override;
Expand All @@ -86,10 +73,18 @@ class DummyAuxDataTokenizer : public AuxDataTokenizer {
TraceProcessorContext* const context_;
};

// Dummy factory that creates tokenizers that just discard data.
// Dummy tokenizer that just discard data.
// Used to skip streams that we do not know how to parse.
using DummyAuxDataTokenizerFactory =
SimpleAuxDataTokenizerFactory<DummyAuxDataTokenizer>;
class DummyAuxDataTokenizer : public AuxDataTokenizer {
public:
explicit DummyAuxDataTokenizer(TraceProcessorContext* context);
~DummyAuxDataTokenizer() override;
virtual base::StatusOr<AuxDataStream*> InitializeAuxDataStream(
AuxStream* stream) override;

private:
DummyAuxDataStream stream_;
};

} // namespace perf_importer
} // namespace trace_processor
Expand Down
Loading

0 comments on commit 57e9e9c

Please sign in to comment.