trace_processor: Remove PERFETTO_TP_HEAP_GRAPHS build flag
The heap_graph module is moved to storage_full. The heap_graph tracker is
now created on demand.
Bug: 141459049
Change-Id: I2c0b1827dde04335bb4f8577def39377adf3c534
diff --git a/Android.bp b/Android.bp
index 827c726..bad25cc 100644
--- a/Android.bp
+++ b/Android.bp
@@ -5744,6 +5744,9 @@
"src/trace_processor/importers/proto/android_probes_parser.cc",
"src/trace_processor/importers/proto/graphics_event_module.cc",
"src/trace_processor/importers/proto/graphics_event_parser.cc",
+ "src/trace_processor/importers/proto/heap_graph_module.cc",
+ "src/trace_processor/importers/proto/heap_graph_tracker.cc",
+ "src/trace_processor/importers/proto/heap_graph_walker.cc",
"src/trace_processor/importers/proto/system_probes_module.cc",
"src/trace_processor/importers/proto/system_probes_parser.cc",
"src/trace_processor/importers/proto/vulkan_memory_tracker.cc",
@@ -5775,9 +5778,6 @@
"src/trace_processor/importers/fuchsia/fuchsia_trace_tokenizer.cc",
"src/trace_processor/importers/fuchsia/fuchsia_trace_utils.cc",
"src/trace_processor/importers/proto/args_table_utils.cc",
- "src/trace_processor/importers/proto/heap_graph_module.cc",
- "src/trace_processor/importers/proto/heap_graph_tracker.cc",
- "src/trace_processor/importers/proto/heap_graph_walker.cc",
"src/trace_processor/importers/proto/proto_importer_module.cc",
"src/trace_processor/importers/proto/proto_trace_parser.cc",
"src/trace_processor/importers/proto/proto_trace_tokenizer.cc",
diff --git a/BUILD b/BUILD
index 71698f7..2c87a43 100644
--- a/BUILD
+++ b/BUILD
@@ -783,6 +783,12 @@
"src/trace_processor/importers/proto/graphics_event_module.h",
"src/trace_processor/importers/proto/graphics_event_parser.cc",
"src/trace_processor/importers/proto/graphics_event_parser.h",
+ "src/trace_processor/importers/proto/heap_graph_module.cc",
+ "src/trace_processor/importers/proto/heap_graph_module.h",
+ "src/trace_processor/importers/proto/heap_graph_tracker.cc",
+ "src/trace_processor/importers/proto/heap_graph_tracker.h",
+ "src/trace_processor/importers/proto/heap_graph_walker.cc",
+ "src/trace_processor/importers/proto/heap_graph_walker.h",
"src/trace_processor/importers/proto/system_probes_module.cc",
"src/trace_processor/importers/proto/system_probes_module.h",
"src/trace_processor/importers/proto/system_probes_parser.cc",
@@ -845,12 +851,6 @@
"src/trace_processor/importers/proto/args_table_utils.cc",
"src/trace_processor/importers/proto/args_table_utils.h",
"src/trace_processor/importers/proto/chrome_compositor_scheduler_state.descriptor.h",
- "src/trace_processor/importers/proto/heap_graph_module.cc",
- "src/trace_processor/importers/proto/heap_graph_module.h",
- "src/trace_processor/importers/proto/heap_graph_tracker.cc",
- "src/trace_processor/importers/proto/heap_graph_tracker.h",
- "src/trace_processor/importers/proto/heap_graph_walker.cc",
- "src/trace_processor/importers/proto/heap_graph_walker.h",
"src/trace_processor/importers/proto/packet_sequence_state.h",
"src/trace_processor/importers/proto/proto_importer_module.cc",
"src/trace_processor/importers/proto/proto_importer_module.h",
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 1544497..4e86d3b 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -84,7 +84,6 @@
"PERFETTO_TP_METRICS=$enable_perfetto_trace_processor_metrics",
"PERFETTO_TP_FTRACE=$enable_perfetto_trace_processor_ftrace",
"PERFETTO_TP_HTTPD=$perfetto_tp_httpd",
- "PERFETTO_TP_HEAP_GRAPHS=$enable_perfetto_trace_processor_heap_graphs",
"PERFETTO_TP_JSON=$enable_perfetto_trace_processor_json",
"PERFETTO_TP_JSON_IMPORT=$enable_perfetto_trace_processor_json_import",
"PERFETTO_TP_FUCHSIA=$enable_perfetto_trace_processor_fuchsia",
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index 3522b94..82d0665 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -219,10 +219,6 @@
enable_perfetto_trace_processor_ftrace =
enable_perfetto_trace_processor && !(build_with_chromium && is_android)
- # Enables parsing support for heap graphs in trace processor.
- enable_perfetto_trace_processor_heap_graphs =
- enable_perfetto_trace_processor && !(build_with_chromium && is_android)
-
# Enables JSON support in the trace processor. Required for JSON trace import
# and export. Importer support can also be disabled using
# |enable_perfetto_trace_processor_json_import|.
diff --git a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
index 3cef49f..e9cae4f 100644
--- a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
+++ b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
@@ -38,7 +38,6 @@
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_METRICS() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FTRACE() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (0)
-#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HEAP_GRAPHS() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON() (0)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON_IMPORT() (0)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FUCHSIA() (1)
diff --git a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
index 86b8cc3..baa1056 100644
--- a/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
+++ b/include/perfetto/base/build_configs/bazel/perfetto_build_flags.h
@@ -38,7 +38,6 @@
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_METRICS() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FTRACE() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_ANDROID() || PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_LINUX() || PERFETTO_BUILDFLAG_DEFINE_PERFETTO_OS_MACOSX())
-#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HEAP_GRAPHS() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON_IMPORT() (1)
#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_FUCHSIA() (1)
diff --git a/src/trace_processor/BUILD.gn b/src/trace_processor/BUILD.gn
index 9604696..176093f 100644
--- a/src/trace_processor/BUILD.gn
+++ b/src/trace_processor/BUILD.gn
@@ -104,9 +104,6 @@
"importers/proto/args_table_utils.cc",
"importers/proto/args_table_utils.h",
"importers/proto/chrome_compositor_scheduler_state.descriptor.h",
- "importers/proto/heap_graph_module.h",
- "importers/proto/heap_graph_tracker.h",
- "importers/proto/heap_graph_walker.h",
"importers/proto/packet_sequence_state.h",
"importers/proto/proto_importer_module.cc",
"importers/proto/proto_importer_module.h",
@@ -201,13 +198,6 @@
enable_perfetto_trace_processor_fuchsia) {
sources += [ "ftrace_utils.cc" ]
}
- if (enable_perfetto_trace_processor_heap_graphs) {
- sources += [
- "importers/proto/heap_graph_module.cc",
- "importers/proto/heap_graph_tracker.cc",
- "importers/proto/heap_graph_walker.cc",
- ]
- }
if (enable_perfetto_trace_processor_fuchsia) {
sources += [
"importers/fuchsia/fuchsia_provider_view.cc",
@@ -240,6 +230,12 @@
"importers/proto/graphics_event_module.h",
"importers/proto/graphics_event_parser.cc",
"importers/proto/graphics_event_parser.h",
+ "importers/proto/heap_graph_module.cc",
+ "importers/proto/heap_graph_module.h",
+ "importers/proto/heap_graph_tracker.cc",
+ "importers/proto/heap_graph_tracker.h",
+ "importers/proto/heap_graph_walker.cc",
+ "importers/proto/heap_graph_walker.h",
"importers/proto/system_probes_module.cc",
"importers/proto/system_probes_module.h",
"importers/proto/system_probes_parser.cc",
@@ -429,6 +425,7 @@
"forwarding_trace_parser_unittest.cc",
"heap_profile_tracker_unittest.cc",
"importers/proto/args_table_utils_unittest.cc",
+ "importers/proto/heap_graph_walker_unittest.cc",
"importers/proto/proto_trace_parser_unittest.cc",
"importers/systrace/systrace_parser_unittest.cc",
"null_term_string_view_unittest.cc",
@@ -504,9 +501,6 @@
"thread_table_unittest.cc",
]
}
- if (enable_perfetto_trace_processor_heap_graphs) {
- sources += [ "importers/proto/heap_graph_walker_unittest.cc" ]
- }
if (enable_perfetto_trace_processor_fuchsia) {
sources += [ "importers/fuchsia/fuchsia_trace_utils_unittest.cc" ]
}
diff --git a/src/trace_processor/importers/proto/heap_graph_module.cc b/src/trace_processor/importers/proto/heap_graph_module.cc
index 3004131..49d2f02 100644
--- a/src/trace_processor/importers/proto/heap_graph_module.cc
+++ b/src/trace_processor/importers/proto/heap_graph_module.cc
@@ -92,8 +92,7 @@
using perfetto::protos::pbzero::TracePacket;
HeapGraphModule::HeapGraphModule(TraceProcessorContext* context)
- : context_(context) {
- context_->heap_graph_tracker.reset(new HeapGraphTracker(context_));
+ : context_(context), heap_graph_tracker_(context) {
RegisterForField(TracePacket::kHeapGraphFieldNumber, context);
RegisterForField(TracePacket::kDeobfuscationMappingFieldNumber, context);
}
@@ -119,7 +118,7 @@
protos::pbzero::HeapGraph::Decoder heap_graph(blob.data, blob.size);
UniquePid upid = context_->process_tracker->GetOrCreateProcess(
static_cast<uint32_t>(heap_graph.pid()));
- context_->heap_graph_tracker->SetPacketIndex(seq_id, heap_graph.index());
+ heap_graph_tracker_.SetPacketIndex(seq_id, heap_graph.index());
for (auto it = heap_graph.objects(); it; ++it) {
protos::pbzero::HeapGraphObject::Decoder object(*it);
HeapGraphTracker::SourceObject obj;
@@ -157,14 +156,14 @@
ref.owned_object_id = object_ids[i];
obj.references.emplace_back(std::move(ref));
}
- context_->heap_graph_tracker->AddObject(seq_id, upid, ts, std::move(obj));
+ heap_graph_tracker_.AddObject(seq_id, upid, ts, std::move(obj));
}
for (auto it = heap_graph.type_names(); it; ++it) {
protos::pbzero::InternedString::Decoder entry(*it);
const char* str = reinterpret_cast<const char*>(entry.str().data);
auto str_view = base::StringView(str, entry.str().size);
- context_->heap_graph_tracker->AddInternedTypeName(
+ heap_graph_tracker_.AddInternedTypeName(
seq_id, entry.iid(), context_->storage->InternString(str_view));
}
for (auto it = heap_graph.field_names(); it; ++it) {
@@ -172,7 +171,7 @@
const char* str = reinterpret_cast<const char*>(entry.str().data);
auto str_view = base::StringView(str, entry.str().size);
- context_->heap_graph_tracker->AddInternedFieldName(
+ heap_graph_tracker_.AddInternedFieldName(
seq_id, entry.iid(), context_->storage->InternString(str_view));
}
for (auto it = heap_graph.roots(); it; ++it) {
@@ -192,11 +191,10 @@
stats::heap_graph_malformed_packet, static_cast<int>(upid));
break;
}
- context_->heap_graph_tracker->AddRoot(seq_id, upid, ts,
- std::move(src_root));
+ heap_graph_tracker_.AddRoot(seq_id, upid, ts, std::move(src_root));
}
if (!heap_graph.continued()) {
- context_->heap_graph_tracker->FinalizeProfile(seq_id);
+ heap_graph_tracker_.FinalizeProfile(seq_id);
}
}
@@ -214,7 +212,7 @@
cls.obfuscated_name().ToStdString().c_str());
} else {
const std::vector<int64_t>* cls_objects =
- context_->heap_graph_tracker->RowsForType(*obfuscated_class_name_id);
+ heap_graph_tracker_.RowsForType(*obfuscated_class_name_id);
if (cls_objects) {
auto interned_deobfuscated_name =
@@ -247,7 +245,7 @@
}
const std::vector<int64_t>* field_references =
- context_->heap_graph_tracker->RowsForField(*obfuscated_field_name_id);
+ heap_graph_tracker_.RowsForField(*obfuscated_field_name_id);
if (field_references) {
auto interned_deobfuscated_name = context_->storage->InternString(
base::StringView(merged_deobfuscated));
diff --git a/src/trace_processor/importers/proto/heap_graph_module.h b/src/trace_processor/importers/proto/heap_graph_module.h
index 2fde80e..492ba60 100644
--- a/src/trace_processor/importers/proto/heap_graph_module.h
+++ b/src/trace_processor/importers/proto/heap_graph_module.h
@@ -40,6 +40,7 @@
void ParseDeobfuscationMapping(protozero::ConstBytes);
TraceProcessorContext* context_;
+ HeapGraphTracker heap_graph_tracker_;
};
} // namespace trace_processor
diff --git a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
index 8df34cd..66aad38 100644
--- a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
+++ b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
@@ -24,7 +24,6 @@
#include "src/trace_processor/event_tracker.h"
#include "src/trace_processor/importers/ftrace/ftrace_module.h"
#include "src/trace_processor/importers/ftrace/sched_event_tracker.h"
-#include "src/trace_processor/importers/proto/heap_graph_module.h"
#include "src/trace_processor/importers/proto/proto_importer_module.h"
#include "src/trace_processor/importers/proto/proto_trace_parser.h"
#include "src/trace_processor/importers/proto/track_event_module.h"
@@ -253,9 +252,6 @@
context_.ftrace_module =
static_cast<FtraceModule*>(context_.modules.back().get());
-#if PERFETTO_BUILDFLAG(PERFETTO_TP_HEAP_GRAPHS)
- context_.modules.emplace_back(new HeapGraphModule(&context_));
-#endif // PERFETTO_BUILDFLAG(PERFETTO_TP_HEAP_GRAPHS)
context_.modules.emplace_back(new TrackEventModule(&context_));
RegisterAdditionalModules(&context_);
diff --git a/src/trace_processor/register_additional_modules.cc b/src/trace_processor/register_additional_modules.cc
index 1b16fd9..bc9d6ef 100644
--- a/src/trace_processor/register_additional_modules.cc
+++ b/src/trace_processor/register_additional_modules.cc
@@ -17,6 +17,7 @@
#include "src/trace_processor/register_additional_modules.h"
#include "src/trace_processor/importers/proto/android_probes_module.h"
#include "src/trace_processor/importers/proto/graphics_event_module.h"
+#include "src/trace_processor/importers/proto/heap_graph_module.h"
#include "src/trace_processor/importers/proto/system_probes_module.h"
namespace perfetto {
@@ -25,6 +26,7 @@
void RegisterAdditionalModules(TraceProcessorContext* context) {
context->modules.emplace_back(new AndroidProbesModule(context));
context->modules.emplace_back(new GraphicsEventModule(context));
+ context->modules.emplace_back(new HeapGraphModule(context));
context->modules.emplace_back(new SystemProbesModule(context));
}
diff --git a/src/trace_processor/syscall_tracker.h b/src/trace_processor/syscall_tracker.h
index 31e39e1..1dba57d 100644
--- a/src/trace_processor/syscall_tracker.h
+++ b/src/trace_processor/syscall_tracker.h
@@ -42,7 +42,6 @@
class SyscallTracker : public Destructible {
public:
- explicit SyscallTracker(TraceProcessorContext*);
SyscallTracker(const SyscallTracker&) = delete;
SyscallTracker& operator=(const SyscallTracker&) = delete;
virtual ~SyscallTracker();
@@ -72,6 +71,8 @@
}
private:
+ explicit SyscallTracker(TraceProcessorContext*);
+
TraceProcessorContext* const context_;
inline StringId SyscallNumberToStringId(uint32_t syscall_num) {
diff --git a/src/trace_processor/trace_processor_context.cc b/src/trace_processor/trace_processor_context.cc
index 5dd858c..01f876b 100644
--- a/src/trace_processor/trace_processor_context.cc
+++ b/src/trace_processor/trace_processor_context.cc
@@ -25,8 +25,6 @@
#include "src/trace_processor/importers/ftrace/ftrace_module.h"
#include "src/trace_processor/importers/ftrace/sched_event_tracker.h"
#include "src/trace_processor/importers/json/json_trace_parser.h"
-#include "src/trace_processor/importers/proto/heap_graph_module.h"
-#include "src/trace_processor/importers/proto/heap_graph_tracker.h"
#include "src/trace_processor/importers/proto/proto_trace_parser.h"
#include "src/trace_processor/importers/proto/track_event_module.h"
#include "src/trace_processor/importers/systrace/systrace_parser.h"
diff --git a/src/trace_processor/trace_processor_context.h b/src/trace_processor/trace_processor_context.h
index 9fb7a6a..ee362f2 100644
--- a/src/trace_processor/trace_processor_context.h
+++ b/src/trace_processor/trace_processor_context.h
@@ -64,7 +64,6 @@
std::unique_ptr<ChunkedTraceReader> chunk_reader;
std::unique_ptr<HeapProfileTracker> heap_profile_tracker;
std::unique_ptr<SystraceParser> systrace_parser;
- std::unique_ptr<HeapGraphTracker> heap_graph_tracker;
std::unique_ptr<BinderTracker> binder_tracker;
// These fields are stored as pointers to Destructible objects rather than
diff --git a/src/trace_processor/trace_processor_storage_impl.cc b/src/trace_processor/trace_processor_storage_impl.cc
index 267a0f1..3e97bd0 100644
--- a/src/trace_processor/trace_processor_storage_impl.cc
+++ b/src/trace_processor/trace_processor_storage_impl.cc
@@ -25,8 +25,6 @@
#include "src/trace_processor/heap_profile_tracker.h"
#include "src/trace_processor/importers/ftrace/ftrace_module.h"
#include "src/trace_processor/importers/ftrace/sched_event_tracker.h"
-#include "src/trace_processor/importers/proto/heap_graph_module.h"
-#include "src/trace_processor/importers/proto/heap_graph_tracker.h"
#include "src/trace_processor/importers/proto/proto_importer_module.h"
#include "src/trace_processor/importers/proto/proto_trace_tokenizer.h"
#include "src/trace_processor/importers/proto/track_event_module.h"
@@ -68,9 +66,6 @@
context_.ftrace_module =
static_cast<FtraceModule*>(context_.modules.back().get());
-#if PERFETTO_BUILDFLAG(PERFETTO_TP_HEAP_GRAPHS)
- context_.modules.emplace_back(new HeapGraphModule(&context_));
-#endif // PERFETTO_BUILDFLAG(PERFETTO_TP_HEAP_GRAPHS)
context_.modules.emplace_back(new TrackEventModule(&context_));
}