Issue 582676 in chromium: Inconsistent offsets between GPU timer queries

14 views
Skip to first unread message

chro...@googlecode.com

unread,
Jan 29, 2016, 9:03:57 PM1/29/16
to chromi...@chromium.org
Status: Started
Owner: d...@chromium.org
CC: k...@chromium.org, ew...@google.com
Labels: Type-Bug Pri-2 Cr-Internals-GPU-Internals OS-Android OS-Windows

New issue 582676 by d...@chromium.org: Inconsistent offsets between GPU
timer queries
https://code.google.com/p/chromium/issues/detail?id=582676

For platforms which support the EXT_disjoint_timer_query extension (android
platforms, and also windows through angle), to synchronize between the GPU
and CPU clock times we must continually query the offset for each query.
This is due to the fact that the GPU time can be "paused" whenever the GPU
is idle, so the offset can drift apart.

Currently the code looks something like this:

glGetInteger64v(GL_TIMESTAMP, &gl_now);
int64_t micro_now = NanoToMicro(gl_now);
offset_ = GetCurrentCPUTime() - micro_now;

The offset is stored in "microseconds". The problem is these instructions
themselves are not accurate enough to be completed within a microsecond
timeframe, so the offset is meaningless outside of that accuracy. This
ultimately causes us to flakily fail certain conformance tests. For example
one test takes 2 timestamps, and check that the later timestamp is in fact
later.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Jan 29, 2016, 9:06:57 PM1/29/16
to chromi...@chromium.org

Comment #1 on issue 582676 by d...@chromium.org: Inconsistent offsets
So the solution to this problem is to "discard" delta offsets that are
within a reasonable epsilon value. For these timing values I think a
reasonable epsilon value is 1 millisecond since I don't expect these lines
which calculate the offset to ever execute over 1 millisecond.

Note that this does not effect GPU times relative to other GPU times (those
are still accurate up to whatever the driver gives us, down to
nanoseconds), and CPU times relative to other cpu TIMES (generally recorded
in microseconds).

chro...@googlecode.com

unread,
Jan 29, 2016, 9:16:56 PM1/29/16
to chromi...@chromium.org

Comment #2 on issue 582676 by k...@chromium.org: Inconsistent offsets
Hang on, are we talking about the WebGL EXT_disjoint_timer_query
conformance test at
https://www.khronos.org/registry/webgl/sdk/tests/conformance/extensions/ext-disjoint-timer-query.html ?

Is the test buggy? Or do we really think Chrome's implementation is wrong?

chro...@googlecode.com

unread,
Jan 29, 2016, 9:26:02 PM1/29/16
to chromi...@chromium.org

Comment #3 on issue 582676 by d...@chromium.org: Inconsistent offsets
I think chrome's implementation is wrong (for EXT_disjoint_timer_query).
Essentially the GPU gives timestamps at the nanosecond granularity, but we
are constantly adjusting it with a granularity up to 30 microseconds
(numbers from testing). So the numbers are always +/- 30 microseconds off.
We should ignore these small differences so that the numbers are accurate
relative to one another.

chro...@googlecode.com

unread,
Jan 29, 2016, 9:27:57 PM1/29/16
to chromi...@chromium.org

Comment #4 on issue 582676 by d...@chromium.org: Inconsistent offsets
And to reply to the first question in #2: yes, I am talking about that
webgl conformance test.

chro...@googlecode.com

unread,
Feb 1, 2016, 8:53:29 PM2/1/16
to chromi...@chromium.org

Comment #5 on issue 582676 by bugd...@chromium.org: Inconsistent offsets
between GPU timer queries
https://code.google.com/p/chromium/issues/detail?id=582676#c5

The following revision refers to this bug:

https://chromium.googlesource.com/chromium/src.git/+/ea6d840e4d96f6df739f55a89ccf69daa3569a77

commit ea6d840e4d96f6df739f55a89ccf69daa3569a77
Author: dyen <dy...@chromium.org>
Date: Tue Feb 02 00:55:01 2016

Fix GPUTiming offset so it is stable within significant digits.

The timer offset between GPU and CPU time were resolved to
microsecond accuracy before. This was causing inaccuracy
flakiness when comparing timestamps.

The issue is that we cannot assume these instructions run in
microsecond accuracy, so the offset will change from query to
query. Instead they should be considered only up to a sensible
accuracy for these instructions (such as milliseconds) and only
updating the offset if it has changed more than 1 millisecond.

The reason we compare with the previous offset is so we catch
drifts from the previous calculation rather than an integer
boundary. For example 0.9 vs 1.1 would be 0 and 1. Note even if
we were rounding it we would still have this problem, IE
0.45 vs 0.55 would be 0 and 1.

BUG=582676

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

Cr-Commit-Position: refs/heads/master@{#372843}

[modify]
http://crrev.com/ea6d840e4d96f6df739f55a89ccf69daa3569a77/ui/gl/gpu_timing.cc
[modify]
http://crrev.com/ea6d840e4d96f6df739f55a89ccf69daa3569a77/ui/gl/gpu_timing_unittest.cc

chro...@googlecode.com

unread,
Feb 2, 2016, 1:35:20 PM2/2/16
to chromi...@chromium.org
Updates:
Status: Fixed

Comment #6 on issue 582676 by d...@chromium.org: Inconsistent offsets
(No comment was entered for this change.)
Reply all
Reply to author
Forward
0 new messages