pps: Re-emit time clock_sync more regularly

1sec between clock snapshots is too much of a gap in time for perfetto
to reasonably interpolate between clock timelines.

Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41315>
This commit is contained in:
Rob Clark 2026-04-28 09:27:17 -07:00 committed by Marge Bot
parent 0f75fa5bfd
commit e4b77237ac
2 changed files with 6 additions and 8 deletions

View file

@ -20,8 +20,6 @@
// Minimum supported sampling period in nanoseconds
#define MIN_SAMPLING_PERIOD_NS 5000
#define CORRELATION_TIMESTAMP_PERIOD (1000000000ull)
namespace pps
{
/// A data source supports one driver at a time, but if you need more
@ -289,7 +287,6 @@ void GpuDataSource::trace(TraceContext &ctx)
auto packet = ctx.NewTracePacket();
packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_BOOTTIME);
packet->set_timestamp(descriptor_timestamp);
last_correlation_timestamp = perfetto::base::GetBootTimeNs().count();
auto event = packet->set_clock_snapshot();
add_timestamp(event, driver);
}
@ -322,17 +319,18 @@ void GpuDataSource::trace(TraceContext &ctx)
event->set_gpu_id(driver->drm_device.gpu_num);
add_samples(*event, *driver, state->last_counter_vals);
samples_since_correlation++;
}
}
uint64_t cpu_ts = perfetto::base::GetBootTimeNs().count();
if ((cpu_ts - last_correlation_timestamp) > CORRELATION_TIMESTAMP_PERIOD) {
if (samples_since_correlation > 3) {
auto packet = ctx.NewTracePacket();
packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_BOOTTIME);
packet->set_timestamp(cpu_ts);
packet->set_timestamp(perfetto::base::GetBootTimeNs().count());
auto event = packet->set_clock_snapshot();
add_timestamp(event, driver);
last_correlation_timestamp = cpu_ts;
samples_since_correlation = 0;
}
}

View file

@ -55,7 +55,7 @@ class GpuDataSource : public perfetto::DataSource<GpuDataSource, GpuDataSourceTr
std::chrono::nanoseconds time_to_trace;
/// Last CPU timestamp at which we correlated CPU/GPU timestamps
uint64_t last_correlation_timestamp = 0;
unsigned samples_since_correlation = 0;
/// CPU timestamp of packet sent with counter descriptors
uint64_t descriptor_timestamp = 0;