Skip to content

Commit

Permalink
Merge "tp: migrate all tables to be Python based tables"
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Mar 27, 2023
2 parents 75da2af 1c46cbb commit 62458da
Show file tree
Hide file tree
Showing 36 changed files with 1,585 additions and 887 deletions.
18 changes: 18 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -10161,7 10161,13 @@ genrule {
name: "perfetto_src_trace_processor_tables_tables_python",
srcs: [
"src/trace_processor/tables/android_tables.py",
"src/trace_processor/tables/counter_tables.py",
"src/trace_processor/tables/flow_tables.py",
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
],
tools: [
Expand All @@ -10170,7 10176,13 @@ genrule {
cmd: "$(location perfetto_src_trace_processor_tables_tables_python_binary) --gen-dir=$(genDir) --inputs $(in) --outputs $(out)",
out: [
"src/trace_processor/tables/android_tables_py.h",
"src/trace_processor/tables/counter_tables_py.h",
"src/trace_processor/tables/flow_tables_py.h",
"src/trace_processor/tables/memory_tables_py.h",
"src/trace_processor/tables/metadata_tables_py.h",
"src/trace_processor/tables/profiler_tables_py.h",
"src/trace_processor/tables/slice_tables_py.h",
"src/trace_processor/tables/trace_proto_tables_py.h",
"src/trace_processor/tables/track_tables_py.h",
],
}
Expand All @@ -10183,7 10195,13 @@ python_binary_host {
"python/generators/trace_processor_table/serialize.py",
"python/generators/trace_processor_table/util.py",
"src/trace_processor/tables/android_tables.py",
"src/trace_processor/tables/counter_tables.py",
"src/trace_processor/tables/flow_tables.py",
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
"tools/gen_tp_table_headers.py",
],
Expand Down
16 changes: 12 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1979,17 1979,13 @@ perfetto_filegroup(
perfetto_filegroup(
name = "src_trace_processor_tables_tables",
srcs = [
"src/trace_processor/tables/android_tables.h",
"src/trace_processor/tables/counter_tables.h",
"src/trace_processor/tables/flow_tables.h",
"src/trace_processor/tables/macros.h",
"src/trace_processor/tables/macros_internal.h",
"src/trace_processor/tables/memory_tables.h",
"src/trace_processor/tables/metadata_tables.h",
"src/trace_processor/tables/profiler_tables.h",
"src/trace_processor/tables/slice_tables.h",
"src/trace_processor/tables/table_destructors.cc",
"src/trace_processor/tables/trace_proto_tables.h",
],
)

Expand All @@ -1998,12 1994,24 @@ perfetto_cc_tp_tables(
name = "src_trace_processor_tables_tables_python",
srcs = [
"src/trace_processor/tables/android_tables.py",
"src/trace_processor/tables/counter_tables.py",
"src/trace_processor/tables/flow_tables.py",
"src/trace_processor/tables/memory_tables.py",
"src/trace_processor/tables/metadata_tables.py",
"src/trace_processor/tables/profiler_tables.py",
"src/trace_processor/tables/slice_tables.py",
"src/trace_processor/tables/trace_proto_tables.py",
"src/trace_processor/tables/track_tables.py",
],
outs = [
"src/trace_processor/tables/android_tables_py.h",
"src/trace_processor/tables/counter_tables_py.h",
"src/trace_processor/tables/flow_tables_py.h",
"src/trace_processor/tables/memory_tables_py.h",
"src/trace_processor/tables/metadata_tables_py.h",
"src/trace_processor/tables/profiler_tables_py.h",
"src/trace_processor/tables/slice_tables_py.h",
"src/trace_processor/tables/trace_proto_tables_py.h",
"src/trace_processor/tables/track_tables_py.h",
],
)
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/importers/proto/heap_graph_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,7 @@
#include "perfetto/ext/base/string_splitter.h"
#include "perfetto/ext/base/string_utils.h"
#include "src/trace_processor/importers/proto/profiler_util.h"
#include "src/trace_processor/tables/profiler_tables.h"
#include "src/trace_processor/tables/profiler_tables_py.h"

namespace perfetto {
namespace trace_processor {
Expand Down Expand Up @@ -938,7 938,7 @@ HeapGraphTracker::BuildFlamegraph(const int64_t current_ts,

std::unique_ptr<tables::ExperimentalFlamegraphNodesTable> tbl(
new tables::ExperimentalFlamegraphNodesTable(
storage_->mutable_string_pool(), nullptr));
storage_->mutable_string_pool()));

auto it = roots_.find(std::make_pair(current_upid, current_ts));
if (it == roots_.end()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@
#include "protos/perfetto/trace/memory_graph.pbzero.h"
#include "src/trace_processor/containers/string_pool.h"
#include "src/trace_processor/importers/common/args_tracker.h"
#include "src/trace_processor/tables/memory_tables.h"
#include "src/trace_processor/tables/memory_tables_py.h"

namespace perfetto {
namespace trace_processor {
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/importers/proto/profile_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,7 @@
#include "src/trace_processor/sorter/trace_sorter.h"
#include "src/trace_processor/storage/stats.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/profiler_tables.h"
#include "src/trace_processor/tables/profiler_tables_py.h"
#include "src/trace_processor/types/trace_processor_context.h"
#include "src/trace_processor/util/stack_traces_util.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 22,7 @@

#include "perfetto/ext/base/optional.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/profiler_tables.h"
#include "src/trace_processor/tables/profiler_tables_py.h"

#include "protos/perfetto/trace/profiling/profile_common.pbzero.h"
#include "protos/perfetto/trace/profiling/profile_packet.pbzero.h"
Expand Down
2 changes: 2 additions & 0 deletions src/trace_processor/prelude/table_functions/ancestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 20,8 @@
#include "perfetto/ext/base/optional.h"
#include "src/trace_processor/prelude/table_functions/table_function.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/profiler_tables.h"
#include "src/trace_processor/tables/slice_tables.h"

namespace perfetto {
namespace trace_processor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,7 @@

#include "src/trace_processor/prelude/table_functions/table_function.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/flow_tables.h"

#include <queue>
#include <set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 16,8 @@

#include "src/trace_processor/prelude/table_functions/experimental_counter_dur.h"

#include "src/trace_processor/tables/counter_tables.h"

namespace perfetto {
namespace trace_processor {
namespace tables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 31,7 @@ tables::CounterTable::Row CounterRow(int64_t ts, uint32_t track_id) {

TEST(ExperimentalCounterDur, SmokeDur) {
StringPool pool;
tables::CounterTable table(&pool, nullptr);
tables::CounterTable table(&pool);

table.Insert(CounterRow(100 /* ts */, 1 /* track_id */));
table.Insert(CounterRow(102 /* ts */, 2 /* track_id */));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 213,7 @@ std::unique_ptr<tables::ExperimentalFlamegraphNodesTable> FocusTable(
ComputeFocusedState(*in, Matcher(focus_str));
std::unique_ptr<ExperimentalFlamegraphNodesTable> tbl(
new tables::ExperimentalFlamegraphNodesTable(
storage->mutable_string_pool(), nullptr));
storage->mutable_string_pool()));

// Recompute cumulative counts
std::vector<CumulativeCounts> node_to_cumulatives(in->row_count());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 74,7 @@ ExperimentalFlatSlice::ComputeFlatSliceTable(const tables::SliceTable& slice,
int64_t start_bound,
int64_t end_bound) {
std::unique_ptr<tables::ExperimentalFlatSliceTable> out(
new tables::ExperimentalFlatSliceTable(pool, nullptr));
new tables::ExperimentalFlatSliceTable(pool));

auto insert_slice = [&](uint32_t i, int64_t ts,
tables::TrackTable::Id track_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 69,7 @@ class TableAsserter {
TEST(ExperimentalFlatSlice, Smoke) {
StringPool pool;
TableInseter inserter;
tables::SliceTable table(&pool, nullptr);
tables::SliceTable table(&pool);

// A simple stack on track 1.
inserter.Insert(100, 10, 0, TrackId{1});
Expand Down Expand Up @@ -136,7 136,7 @@ TEST(ExperimentalFlatSlice, Smoke) {
TEST(ExperimentalFlatSlice, Bounds) {
StringPool pool;
TableInseter inserter;
tables::SliceTable table(&pool, nullptr);
tables::SliceTable table(&pool);

/// Our timebounds is between 200 and 300.
int64_t start = 200;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 96,7 @@ tables::SliceTable::Id Insert(

TEST(ExperimentalSliceLayoutTest, SingleRow) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name = pool.InternString("SingleRow");

Insert(&slice_table, 1 /*ts*/, 5 /*dur*/, 1 /*track_id*/, name,
Expand All @@ -116,7 116,7 @@ TEST(ExperimentalSliceLayoutTest, SingleRow) {

TEST(ExperimentalSliceLayoutTest, DoubleRow) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name = pool.InternString("SingleRow");

auto id = Insert(&slice_table, 1 /*ts*/, 5 /*dur*/, 1 /*track_id*/, name,
Expand All @@ -138,7 138,7 @@ TEST(ExperimentalSliceLayoutTest, DoubleRow) {

TEST(ExperimentalSliceLayoutTest, MultipleRows) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name = pool.InternString("MultipleRows");

auto a = Insert(&slice_table, 1 /*ts*/, 5 /*dur*/, 1 /*track_id*/, name,
Expand Down Expand Up @@ -167,7 167,7 @@ TEST(ExperimentalSliceLayoutTest, MultipleRows) {

TEST(ExperimentalSliceLayoutTest, MultipleTracks) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name1 = pool.InternString("Slice1");
StringId name2 = pool.InternString("Slice2");
StringId name3 = pool.InternString("Slice3");
Expand Down Expand Up @@ -199,7 199,7 @@ TEST(ExperimentalSliceLayoutTest, MultipleTracks) {

TEST(ExperimentalSliceLayoutTest, MultipleTracksWithGap) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name1 = pool.InternString("Slice1");
StringId name2 = pool.InternString("Slice2");
StringId name3 = pool.InternString("Slice3");
Expand Down Expand Up @@ -237,7 237,7 @@ TEST(ExperimentalSliceLayoutTest, MultipleTracksWithGap) {

TEST(ExperimentalSliceLayoutTest, PreviousGroupFullyNested) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name = pool.InternString("Slice");

// This test ensures that our bounding box logic works when the bounding box
Expand Down Expand Up @@ -285,7 285,7 @@ TEST(ExperimentalSliceLayoutTest, PreviousGroupFullyNested) {

TEST(ExperimentalSliceLayoutTest, FilterOutTracks) {
StringPool pool;
tables::SliceTable slice_table(&pool, nullptr);
tables::SliceTable slice_table(&pool);
StringId name1 = pool.InternString("Slice1");
StringId name2 = pool.InternString("Slice2");
StringId name3 = pool.InternString("Slice3");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 104,7 @@ static FlamegraphTableAndMergedCallsites BuildFlamegraphTableTreeStructure(

std::unique_ptr<tables::ExperimentalFlamegraphNodesTable> tbl(
new tables::ExperimentalFlamegraphNodesTable(
storage->mutable_string_pool(), nullptr));
storage->mutable_string_pool()));

// FORWARD PASS:
// Aggregate callstacks by frame name / mapping name. Use symbolization
Expand Down Expand Up @@ -405,7 405,7 @@ BuildNativeCallStackSamplingFlamegraph(
if (filtered.row_count() == 0) {
std::unique_ptr<tables::ExperimentalFlamegraphNodesTable> empty_tbl(
new tables::ExperimentalFlamegraphNodesTable(
storage->mutable_string_pool(), nullptr));
storage->mutable_string_pool()));
return empty_tbl;
}

Expand Down
Loading

0 comments on commit 62458da

Please sign in to comment.