Reduce binary size (1.6MB -> 600K) by removing protos/trace:lite dep
This CL removes any dependency from {traced, traced_probes, perfetto}
to //protos/trace:lite. Neither of them really require such dependency
and it causes significant binary bloat due to all the hundreds
.pb.{cc,h} generated by libprotobuf for any possible trace packet.
Specifically:
traced_probes: needs only to depend on the "zero" protos, for writing.
traced: needs the official protobuf only for the following reasons:
- Packet validation (e.g., trusted uid)
- Directly injecting some special packets (TraceConfig, uid, clocks)
Neither of them requires really the hundreds trace packets. They
can just use TrustedPacket, which doesn't pull in the other packets.
perfetto: it requires only TraceConfig, but that is a separate smaller
target.
Bug: 77316877
Test: pefetto_unittests / perfetto_integrationtests
Change-Id: I6e01b47af3313887c685ffb4614009910413bbea
diff --git a/test/test_helper.cc b/test/test_helper.cc
index 24f814b..7e19555 100644
--- a/test/test_helper.cc
+++ b/test/test_helper.cc
@@ -17,12 +17,13 @@
#include "test/test_helper.h"
#include "gtest/gtest.h"
-#include "perfetto/trace/trace_packet.pb.h"
-#include "perfetto/trace/trace_packet.pbzero.h"
#include "perfetto/traced/traced.h"
#include "perfetto/tracing/core/trace_packet.h"
#include "test/task_runner_thread_delegates.h"
+#include "perfetto/trace/trace_packet.pb.h"
+#include "perfetto/trace/trace_packet.pbzero.h"
+
namespace perfetto {
// If we're building on Android and starting the daemons ourselves,
@@ -52,13 +53,14 @@
void TestHelper::OnTracingStop() {}
void TestHelper::OnTraceData(std::vector<TracePacket> packets, bool has_more) {
- for (auto& packet : packets) {
- ASSERT_TRUE(packet.Decode());
- if (packet->has_clock_snapshot() || packet->has_trace_config())
+ for (auto& encoded_packet : packets) {
+ protos::TracePacket packet;
+ ASSERT_TRUE(encoded_packet.Decode(&packet));
+ if (packet.has_clock_snapshot() || packet.has_trace_config())
continue;
ASSERT_EQ(protos::TracePacket::kTrustedUid,
- packet->optional_trusted_uid_case());
- packet_callback_(*packet);
+ packet.optional_trusted_uid_case());
+ packet_callback_(packet);
}
if (!has_more) {
@@ -97,7 +99,7 @@
}
void TestHelper::ReadData(
- std::function<void(const TracePacket::DecodedTracePacket&)> packet_callback,
+ std::function<void(const protos::TracePacket&)> packet_callback,
std::function<void()> on_finish_callback) {
packet_callback_ = packet_callback;
continuation_callack_ = on_finish_callback;