SF: add trace points for dispatcher system
Adds initial tracing points for the dispatcher and predictor vsync
signal dispatch system, along with some helper classes to turn traces
on and off based on system properties.
Verbose tracing can be turned on with 'setprop debug.sf.vsp_trace 1'
Test: boot with tracepoints on, see intended traces
Bug: 144927823
Change-Id: Ib6764404b77881887f338a41a25daa1d7068dc1f
diff --git a/services/surfaceflinger/Scheduler/Timer.cpp b/services/surfaceflinger/Scheduler/Timer.cpp
index fb4f315..8f81c2c 100644
--- a/services/surfaceflinger/Scheduler/Timer.cpp
+++ b/services/surfaceflinger/Scheduler/Timer.cpp
@@ -25,6 +25,7 @@
#include <chrono>
#include <cstdint>
+#include "SchedulerUtils.h"
#include "Timer.h"
namespace android::scheduler {
@@ -32,11 +33,6 @@
static constexpr size_t kReadPipe = 0;
static constexpr size_t kWritePipe = 1;
-template <class T, size_t N>
-constexpr size_t arrayLen(T (&)[N]) {
- return N;
-}
-
Timer::Timer()
: mTimerFd(timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK)),
mEpollFd(epoll_create1(EPOLL_CLOEXEC)) {
@@ -66,11 +62,8 @@
return systemTime(SYSTEM_TIME_MONOTONIC);
}
-constexpr char const* timerTraceTag = "AlarmInNs";
void Timer::alarmIn(std::function<void()> const& cb, nsecs_t fireIn) {
std::lock_guard<decltype(mMutex)> lk(mMutex);
- ATRACE_INT64(timerTraceTag, fireIn);
-
using namespace std::literals;
static constexpr int ns_per_s =
std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count();
@@ -91,7 +84,6 @@
void Timer::alarmCancel() {
std::lock_guard<decltype(mMutex)> lk(mMutex);
- ATRACE_INT64(timerTraceTag, 0);
struct itimerspec old_timer;
struct itimerspec new_timer {
@@ -137,7 +129,6 @@
uint64_t iteration = 0;
char const traceNamePrefix[] = "TimerIteration #";
- static constexpr size_t max64print = std::numeric_limits<decltype(iteration)>::digits10;
static constexpr size_t maxlen = arrayLen(traceNamePrefix) + max64print;
std::array<char, maxlen> str_buffer;
auto timing = true;