Skip to content

Commit 67cb2bf

Browse files
committed
f
1 parent 456bc0a commit 67cb2bf

File tree

7 files changed

+94
-18
lines changed

7 files changed

+94
-18
lines changed

protos/perfetto/config/perfetto_config.proto

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,55 @@ message TracingServiceState {
456456

457457
// Begin of protos/perfetto/common/builtin_clock.proto
458458

459+
// Builtin clock domains used in Perfetto traces.
460+
//
461+
// The default trace time clock is BUILTIN_CLOCK_TRACE_FILE: a synthetic clock
462+
// representing the trace file's own timeline. Each trace file gets its own
463+
// instance (scoped by trace file index).
464+
//
465+
// For backwards compatibility, Perfetto proto traces register BOOTTIME as a
466+
// fallback: if the first timestamp conversion uses a clock other than the
467+
// trace file clock and no explicit clock snapshot data exists, the trace time
468+
// is switched to BOOTTIME. This fallback does not fire for modern traces that
469+
// include ClockSnapshots or that only use the trace file clock directly.
470+
//
471+
// The `primary_trace_clock` field in ClockSnapshot can definitively override
472+
// the trace time clock regardless of the above.
459473
enum BuiltinClock {
460474
BUILTIN_CLOCK_UNKNOWN = 0;
475+
476+
// Corresponds to CLOCK_REALTIME. See clock_gettime(2).
461477
BUILTIN_CLOCK_REALTIME = 1;
478+
479+
// Corresponds to CLOCK_REALTIME_COARSE. See clock_gettime(2).
462480
BUILTIN_CLOCK_REALTIME_COARSE = 2;
481+
482+
// Corresponds to CLOCK_MONOTONIC. See clock_gettime(2).
463483
BUILTIN_CLOCK_MONOTONIC = 3;
484+
485+
// Corresponds to CLOCK_MONOTONIC_COARSE. See clock_gettime(2).
464486
BUILTIN_CLOCK_MONOTONIC_COARSE = 4;
487+
488+
// Corresponds to CLOCK_MONOTONIC_RAW. See clock_gettime(2).
465489
BUILTIN_CLOCK_MONOTONIC_RAW = 5;
490+
491+
// Corresponds to CLOCK_BOOTTIME. See clock_gettime(2).
492+
// For proto traces, this is used as a backwards-compatible fallback trace
493+
// time clock when no explicit clock snapshots are present.
466494
BUILTIN_CLOCK_BOOTTIME = 6;
495+
496+
// TSC (Time Stamp Counter). Architecture-specific high-resolution counter.
467497
BUILTIN_CLOCK_TSC = 9;
498+
499+
// Corresponds to the perf event clock (PERF_CLOCK).
468500
BUILTIN_CLOCK_PERF = 10;
501+
502+
// A synthetic clock representing the trace file's own timeline. Each trace
503+
// file gets its own instance (scoped by trace file index). This is the
504+
// default trace time clock before any clock snapshot or format-specific
505+
// override takes effect.
469506
BUILTIN_CLOCK_TRACE_FILE = 11;
507+
470508
BUILTIN_CLOCK_MAX_ID = 63;
471509

472510
reserved 7, 8;

protos/perfetto/trace/perfetto_trace.proto

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,55 @@ message TracingServiceState {
456456

457457
// Begin of protos/perfetto/common/builtin_clock.proto
458458

459+
// Builtin clock domains used in Perfetto traces.
460+
//
461+
// The default trace time clock is BUILTIN_CLOCK_TRACE_FILE: a synthetic clock
462+
// representing the trace file's own timeline. Each trace file gets its own
463+
// instance (scoped by trace file index).
464+
//
465+
// For backwards compatibility, Perfetto proto traces register BOOTTIME as a
466+
// fallback: if the first timestamp conversion uses a clock other than the
467+
// trace file clock and no explicit clock snapshot data exists, the trace time
468+
// is switched to BOOTTIME. This fallback does not fire for modern traces that
469+
// include ClockSnapshots or that only use the trace file clock directly.
470+
//
471+
// The `primary_trace_clock` field in ClockSnapshot can definitively override
472+
// the trace time clock regardless of the above.
459473
enum BuiltinClock {
460474
BUILTIN_CLOCK_UNKNOWN = 0;
475+
476+
// Corresponds to CLOCK_REALTIME. See clock_gettime(2).
461477
BUILTIN_CLOCK_REALTIME = 1;
478+
479+
// Corresponds to CLOCK_REALTIME_COARSE. See clock_gettime(2).
462480
BUILTIN_CLOCK_REALTIME_COARSE = 2;
481+
482+
// Corresponds to CLOCK_MONOTONIC. See clock_gettime(2).
463483
BUILTIN_CLOCK_MONOTONIC = 3;
484+
485+
// Corresponds to CLOCK_MONOTONIC_COARSE. See clock_gettime(2).
464486
BUILTIN_CLOCK_MONOTONIC_COARSE = 4;
487+
488+
// Corresponds to CLOCK_MONOTONIC_RAW. See clock_gettime(2).
465489
BUILTIN_CLOCK_MONOTONIC_RAW = 5;
490+
491+
// Corresponds to CLOCK_BOOTTIME. See clock_gettime(2).
492+
// For proto traces, this is used as a backwards-compatible fallback trace
493+
// time clock when no explicit clock snapshots are present.
466494
BUILTIN_CLOCK_BOOTTIME = 6;
495+
496+
// TSC (Time Stamp Counter). Architecture-specific high-resolution counter.
467497
BUILTIN_CLOCK_TSC = 9;
498+
499+
// Corresponds to the perf event clock (PERF_CLOCK).
468500
BUILTIN_CLOCK_PERF = 10;
501+
502+
// A synthetic clock representing the trace file's own timeline. Each trace
503+
// file gets its own instance (scoped by trace file index). This is the
504+
// default trace time clock before any clock snapshot or format-specific
505+
// override takes effect.
469506
BUILTIN_CLOCK_TRACE_FILE = 11;
507+
470508
BUILTIN_CLOCK_MAX_ID = 63;
471509

472510
reserved 7, 8;
@@ -7972,10 +8010,13 @@ message ClockSnapshot {
79728010
}
79738011
repeated Clock clocks = 1;
79748012

7975-
// The authoritative clock domain for the trace. Defaults to BOOTTIME, but can
7976-
// be overridden in TraceConfig's builtin_data_sources. Trace processor will
7977-
// attempt to translate packet/event timestamps from various data sources (and
7978-
// their chosen clock domains) to this domain during import.
8013+
// The authoritative clock domain for the trace. When set, this definitively
8014+
// overrides the trace time clock. If not set, the trace time clock remains
8015+
// at its default (BUILTIN_CLOCK_TRACE_FILE), unless a format-specific
8016+
// fallback applies (e.g. BOOTTIME for legacy proto traces without clock
8017+
// snapshots). Trace processor will attempt to translate packet/event
8018+
// timestamps from various data sources (and their chosen clock domains) to
8019+
// this domain during import.
79798020
optional BuiltinClock primary_trace_clock = 2;
79808021
}
79818022

src/trace_processor/forwarding_trace_parser.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ base::Status ForwardingTraceParser::Init(const TraceBlobView& blob) {
163163
} else if (trace_type_ == kFuchsiaTraceType) {
164164
trace_context_->clock_tracker->SetGlobalClock(
165165
ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME));
166-
} else if (trace_type_ == kGeckoTraceType ||
167-
trace_type_ == kJsonTraceType ||
166+
} else if (trace_type_ == kGeckoTraceType || trace_type_ == kJsonTraceType ||
168167
trace_type_ == kInstrumentsXmlTraceType) {
169168
trace_context_->clock_tracker->SetGlobalClock(
170169
ClockId::TraceFile(trace_context_->trace_id().value));

src/trace_processor/importers/common/clock_tracker_unittest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ TEST_F(ClockTrackerTest, AddDeferredIdentitySync_WithExplicitSnapshot) {
690690
EXPECT_EQ(*ct_->ToTraceTime(BOOTTIME, 1100), 1100);
691691
}
692692

693-
TEST_F(ClockTrackerTest, AddDeferredIdentitySync_DoesNotChangeGlobalTraceClock) {
693+
TEST_F(ClockTrackerTest,
694+
AddDeferredIdentitySync_DoesNotChangeGlobalTraceClock) {
694695
// Trace time starts as BOOTTIME (test fixture default).
695696
constexpr ClockTracker::ClockId TRACE_FILE = ClockId::TraceFile(0);
696697
ct_->AddDeferredIdentitySync(TRACE_FILE);

src/trace_processor/importers/fuchsia/fuchsia_trace_tokenizer.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ FuchsiaTraceTokenizer::FuchsiaTraceTokenizer(TraceProcessorContext* context)
8484
parser_ = parser.get();
8585
stream_ = context->sorter->CreateStream(std::move(parser));
8686
RegisterProvider(0, "");
87-
8887
}
8988

9089
FuchsiaTraceTokenizer::~FuchsiaTraceTokenizer() = default;
@@ -599,8 +598,8 @@ void FuchsiaTraceTokenizer::ParseRecord(TraceBlobView tbv) {
599598
current_provider_->GetThread(incoming_thread_ref));
600599
}
601600
{
602-
auto trace_ts =
603-
context_->clock_tracker->ToTraceTime(ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME), ts);
601+
auto trace_ts = context_->clock_tracker->ToTraceTime(
602+
ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME), ts);
604603
if (trace_ts) {
605604
stream_->Push(*trace_ts, std::move(record));
606605
}
@@ -639,8 +638,8 @@ void FuchsiaTraceTokenizer::ParseRecord(TraceBlobView tbv) {
639638
return;
640639
}
641640
{
642-
auto trace_ts =
643-
context_->clock_tracker->ToTraceTime(ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME), ts);
641+
auto trace_ts = context_->clock_tracker->ToTraceTime(
642+
ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME), ts);
644643
if (trace_ts) {
645644
stream_->Push(*trace_ts, std::move(record));
646645
}
@@ -673,8 +672,8 @@ void FuchsiaTraceTokenizer::ParseRecord(TraceBlobView tbv) {
673672
return;
674673
}
675674
{
676-
auto trace_ts =
677-
context_->clock_tracker->ToTraceTime(ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME), ts);
675+
auto trace_ts = context_->clock_tracker->ToTraceTime(
676+
ClockId::Machine(protos::pbzero::BUILTIN_CLOCK_BOOTTIME), ts);
678677
if (trace_ts) {
679678
stream_->Push(*trace_ts, std::move(record));
680679
}

src/trace_processor/importers/perf_text/perf_text_trace_tokenizer.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ std::string Slice(const std::string& str, size_t start, size_t end) {
6464
PerfTextTraceTokenizer::PerfTextTraceTokenizer(TraceProcessorContext* ctx)
6565
: context_(ctx),
6666
stream_(ctx->sorter->CreateStream(
67-
std::make_unique<PerfTextTraceParser>(ctx))) {
68-
}
67+
std::make_unique<PerfTextTraceParser>(ctx))) {}
6968
PerfTextTraceTokenizer::~PerfTextTraceTokenizer() = default;
7069

7170
base::Status PerfTextTraceTokenizer::Parse(TraceBlobView blob) {

src/trace_processor/importers/systrace/systrace_trace_parser.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ SystraceTraceParser::SystraceTraceParser(TraceProcessorContext* ctx)
113113
: line_parser_(ctx),
114114
ctx_(ctx),
115115
stream_(ctx->sorter->CreateStream(
116-
std::make_unique<SystraceLineSink>(&line_parser_))) {
117-
}
116+
std::make_unique<SystraceLineSink>(&line_parser_))) {}
118117
SystraceTraceParser::~SystraceTraceParser() = default;
119118

120119
base::Status SystraceTraceParser::Parse(TraceBlobView blob) {

0 commit comments

Comments
 (0)