Skip to content

Commit

Permalink
Makes TraceTicks use the monotonic timer on Chrome OS
Browse files Browse the repository at this point in the history
This is the end result of an effort to eliminate the need for TraceTicks
to be based on the ftrace clock on Chrome OS. Chrome tracing began using
the ftrace clock so that we could correlate what was happening in Chrome
(recorded in Chrome traces and thus based on TraceTicks) with what was
happening inside of the ChromeOS kernel (and thus based on the ftrace
clock). Having this end-to-end view of performance was necessary for
full-stack debugging on Chrome OS.

However, a May 2015 Linux patch (https://goo.gl/2Or7DF) added the
ability to use the monotonic clock as the source for timestamps within
ftrace. This allows us to use the monotonic clock for ftrace and thus
have the benefits of having consistent timestamps in our Chrome-level
and kernel-level tracing tools, without the cost of having to carry
around timestamps from two different sources within Chrome (the
monotonic clock for TimeTicks and the ftrace clock for TraceTicks).

sonnyrao@ graciously volunteered to backport this Linux patch to major
past versions of Chrome OS, paving the way for this patch which
finally starts using the monotonic timer for TraceTicks on Chrome OS.
He's ready to submit the second side of this CL which tells ftrace to
start using the monotonic clock as soon as this one gets DEPS rolled
into ChromeOS (sometime tomorrow morning).

The one down-side to all of this is that, once sonnyrao@ completes the
backports and this patch is submitted, developers with the latest
version of Chrome but with a version of ChromeOS that is not within
the most recent 5 versions will have ftrace timestamps that do not
match Chrome tracing timestamps. This shouldn't cause any functional
problems, but it will make it harder to get a full picture of
Chrome's performance down to the kernel level.

BUG=541692

Review URL: https://codereview.chromium.org/1374753004

Cr-Commit-Position: refs/heads/master@{#355650}
  • Loading branch information
charliea authored and Commit bot committed Oct 22, 2015
1 parent 7620c3c commit b164c04
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions base/time/time_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,11 @@ ThreadTicks ThreadTicks::Now() {
#endif
}

// Use the Chrome OS specific system-wide clock.
#if defined(OS_CHROMEOS)
// static
TraceTicks TraceTicks::Now() {
struct timespec ts;
if (clock_gettime(kClockSystemTrace, &ts) != 0) {
// NB: fall-back for a chrome os build running on linux
return TraceTicks(ClockNow(CLOCK_MONOTONIC));
}
return TraceTicks(ConvertTimespecToMicros(ts));
}

#else // !defined(OS_CHROMEOS)

// static
TraceTicks TraceTicks::Now() {
return TraceTicks(ClockNow(CLOCK_MONOTONIC));
}

#endif // defined(OS_CHROMEOS)

#endif // !OS_MACOSX

// static
Expand Down

0 comments on commit b164c04

Please sign in to comment.