Skip to content

Commit

Permalink
[tracing] Use ChromeTracePacket to save binary size with perfetto
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Jakob Gruber <[email protected]>
Auto-Submit: Peter Marshall <[email protected]>
Reviewed-by: Jakob Gruber <[email protected]>
Cr-Commit-Position: refs/heads/master@{#61662}
  • Loading branch information
psmarshall authored and Commit Bot committed May 20, 2019
1 parent 8d695a4 commit 76f8519
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libplatform/tracing/perfetto-json-consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down Expand Up @@ -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_ << ",";
Expand Down
4 changes: 2 additions & 2 deletions src/libplatform/tracing/perfetto-json-consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TracePacket;

namespace protos {
class ChromeTraceEvent_Arg;
class TracePacket;
class ChromeTracePacket;
} // namespace protos
} // namespace perfetto

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 76f8519

Please sign in to comment.