Commit 67966175 authored by epenner@chromium.org's avatar epenner@chromium.org

Telemetry: Fix timeline frame counting on Mac

We want to count the last the last swap in the embedding
chain. Usually there is a hardware swap for this but on mac
there doesn't appear to be one. This uses the decoder swap
for now until we know the canonical swap call and add a trace
there.

TBR=nduca@chromium.org
NOTRY=true

No-try since this is blocking this from working on the mac and I've run the tests locally.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245478 0039d316-1c4b-4281-b951-d872f2087c98
parent 496b1765
...@@ -149,6 +149,13 @@ FastPathDetails = NoThreads ...@@ -149,6 +149,13 @@ FastPathDetails = NoThreads
SilkResults = ["renderer_main", "total_all"] SilkResults = ["renderer_main", "total_all"]
SilkDetails = MainThread SilkDetails = MainThread
# TODO(epenner): Thread names above are likely fairly stable but trace names
# could change. We should formalize this trace to keep this robust.
GpuFrameTraceName = ":RealSwapBuffers"
# TODO(epenner): The decoder swap-buffers can be used by several producers.
# we need to find the canonical swap buffers on Mac.
GpuFrameTraceNameMac = "GLES2DecoderImpl::DoSwapBuffers"
def ThreadCategoryName(thread_name): def ThreadCategoryName(thread_name):
thread_category = "other" thread_category = "other"
for substring, category in TimelineThreadCategories.iteritems(): for substring, category in TimelineThreadCategories.iteritems():
...@@ -226,20 +233,14 @@ class ThreadTimesTimelineMetric(TimelineMetric): ...@@ -226,20 +233,14 @@ class ThreadTimesTimelineMetric(TimelineMetric):
self.results_to_report = AllThreads self.results_to_report = AllThreads
self.details_to_report = NoThreads self.details_to_report = NoThreads
def CalcFrameCount(self): def CountSlices(self, slices, substring):
gpu_swaps = 0 count = 0
for thread in self._model.GetAllThreads(): for event in slices:
if (ThreadCategoryName(thread.name) == "GPU"): if substring in event.name:
for event in thread.IterAllSlices(): count += 1
if ":RealSwapBuffers" in event.name: return count
gpu_swaps += 1
return gpu_swaps
def AddResults(self, tab, results): def AddResults(self, tab, results):
num_frames = self.CalcFrameCount()
if not num_frames:
raise MissingFramesError()
# Set up each thread category for consistant results. # Set up each thread category for consistant results.
thread_category_results = {} thread_category_results = {}
for name in TimelineThreadCategories.values(): for name in TimelineThreadCategories.values():
...@@ -259,6 +260,14 @@ class ThreadTimesTimelineMetric(TimelineMetric): ...@@ -259,6 +260,14 @@ class ThreadTimesTimelineMetric(TimelineMetric):
if ThreadCategoryName(thread.name) in FastPath: if ThreadCategoryName(thread.name) in FastPath:
thread_category_results['total_fast_path'].AppendThreadSlices(thread) thread_category_results['total_fast_path'].AppendThreadSlices(thread)
# Calculate the number of frames from the GPU thread.
gpu_slices = thread_category_results['GPU'].all_slices
num_frames = self.CountSlices(gpu_slices, GpuFrameTraceName)
if not num_frames:
num_frames = self.CountSlices(gpu_slices, GpuFrameTraceNameMac)
if not num_frames:
raise MissingFramesError()
# Report the desired results and details. # Report the desired results and details.
for thread_results in thread_category_results.values(): for thread_results in thread_category_results.values():
if thread_results.name in self.results_to_report: if thread_results.name in self.results_to_report:
......
...@@ -78,7 +78,7 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase): ...@@ -78,7 +78,7 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
# Create two frame swaps (Results times should be divided by two) # Create two frame swaps (Results times should be divided by two)
gpu_main = model.GetOrCreateProcess(1).GetOrCreateThread(3) gpu_main = model.GetOrCreateProcess(1).GetOrCreateThread(3)
gpu_main.name = 'CrGPUMain' gpu_main.name = 'CrGpuMain'
gpu_main.BeginSlice('gpucat', ':RealSwapBuffers', 10, 10) gpu_main.BeginSlice('gpucat', ':RealSwapBuffers', 10, 10)
gpu_main.EndSlice(11, 11) gpu_main.EndSlice(11, 11)
gpu_main.BeginSlice('gpucat', ':RealSwapBuffers', 12, 12) gpu_main.BeginSlice('gpucat', ':RealSwapBuffers', 12, 12)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment