Commit 76f85199 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[tracing] Use ChromeTracePacket to save binary size with perfetto

Previously, compiling with perfetto would add 2.3 MiB to the d8 release
binary. With this change it's 472 KiB.

This is because trace:lite pulls in many more compiled proto classes
than we need, e.g. a bunch of stuff under ftrace/ which is only used
on Android.

Chrome uses a 'mirror proto' ChromeTrackPacket to only provide
compiled protos for the types of packets it will actually see, which on
non-android devices does not include anything under ftrace/.

We use the same trick here in the JSON consumer.

Cq-Include-Trybots: luci.v8.try:v8_linux64_perfetto_dbg_ng
Bug: v8:8339
Change-Id: Iae1f74eec3bd93b18e9f069701fc016440d3ce5e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1619759
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61662}
parent 8d695a44
......@@ -3676,7 +3676,7 @@ v8_component("v8_libplatform") {
]
deps += [
"third_party/perfetto:libperfetto",
"third_party/perfetto/protos/perfetto/trace:lite",
"third_party/perfetto/protos/perfetto/trace/chrome:minimal_complete_lite",
]
}
}
......
......@@ -7,7 +7,7 @@
#include <cmath>
#include "base/trace_event/common/trace_event_common.h"
#include "perfetto/trace/trace_packet.pb.h"
#include "perfetto/trace/chrome/chrome_trace_packet.pb.h"
#include "perfetto/tracing/core/trace_packet.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
......@@ -28,7 +28,7 @@ PerfettoJSONConsumer::~PerfettoJSONConsumer() { *stream_ << "]}"; }
void PerfettoJSONConsumer::OnTraceData(
std::vector<::perfetto::TracePacket> packets, bool has_more) {
for (const ::perfetto::TracePacket& packet : packets) {
::perfetto::protos::TracePacket proto_packet;
perfetto::protos::ChromeTracePacket proto_packet;
bool success = packet.Decode(&proto_packet);
USE(success);
DCHECK(success);
......@@ -128,7 +128,7 @@ void PerfettoJSONConsumer::AppendArgValue(
}
void PerfettoJSONConsumer::ProcessPacket(
const ::perfetto::protos::TracePacket& packet) {
const ::perfetto::protos::ChromeTracePacket& packet) {
for (const ::perfetto::protos::ChromeTraceEvent& event :
packet.chrome_events().trace_events()) {
if (append_comma_) *stream_ << ",";
......
......@@ -17,7 +17,7 @@ class TracePacket;
namespace protos {
class ChromeTraceEvent_Arg;
class TracePacket;
class ChromeTracePacket;
} // namespace protos
} // namespace perfetto
......@@ -70,7 +70,7 @@ class PerfettoJSONConsumer final : public ::perfetto::Consumer {
// Internal implementation
void AppendJSONString(const char* str);
void AppendArgValue(const ::perfetto::protos::ChromeTraceEvent_Arg& arg);
void ProcessPacket(const ::perfetto::protos::TracePacket& packet);
void ProcessPacket(const ::perfetto::protos::ChromeTracePacket& packet);
std::ostream* stream_;
bool append_comma_ = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment