Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: tools/perf/measurements/v8_detached_context_age_in_gc.py

Issue 930333002: [telemetry] Add new measurement that counts number of GCs needed to free V8 context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bucket value getter Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/perf/benchmarks/v8.py ('k') | tools/perf/measurements/v8_detached_context_age_in_gc_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/measurements/v8_detached_context_age_in_gc.py
diff --git a/tools/perf/measurements/v8_detached_context_age_in_gc.py b/tools/perf/measurements/v8_detached_context_age_in_gc.py
new file mode 100644
index 0000000000000000000000000000000000000000..51dec330727b1c606fd5879ccab40a1a1e4ad7f5
--- /dev/null
+++ b/tools/perf/measurements/v8_detached_context_age_in_gc.py
@@ -0,0 +1,54 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+from telemetry.page import page_test
+from telemetry.value import histogram
+from telemetry.value import histogram_util
+from telemetry.value import scalar
+from telemetry.value import skip
+
+_NAME = 'V8.DetachedContextAgeInGC'
+_UNITS = 'garbage_collections'
+_DISPLAY_NAME = 'V8_DetachedContextAgeInGC'
+_TYPE = histogram_util.RENDERER_HISTOGRAM
+_DESCRIPTION = 'Number of GCs needed to collect detached context'
+
+
+def _GetMaxDetachedContextAge(tab, data_start):
+ data = histogram_util.GetHistogram(_TYPE, _NAME, tab)
+ delta = histogram_util.SubtractHistogram(data, data_start)
+ if not 'buckets' in delta:
+ return
+ buckets = json.loads(delta)['buckets']
+ if buckets:
+ return max(x.get('high', x['low']) for x in buckets)
+
+
+class V8DetachedContextAgeInGC(page_test.PageTest):
+ def __init__(self):
+ super(V8DetachedContextAgeInGC, self).__init__('RunPageInteractions')
+ self._data_start = None
+
+ def CustomizeBrowserOptions(self, options):
+ options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings'])
+
+ def DidNavigateToPage(self, page, tab):
+ self._data_start = histogram_util.GetHistogram(_TYPE, _NAME, tab)
+
+ def ValidateAndMeasurePage(self, page, tab, results):
+ # Trigger GC to get histogram data.
+ # Seven GCs should be enough to collect any detached context.
+ # If a detached context survives more GCs then there is a leak.
+ MAX_AGE = 8
+ for _ in xrange(MAX_AGE):
+ tab.CollectGarbage()
+ value = _GetMaxDetachedContextAge(tab, self._data_start)
+ if value is None:
+ results.AddValue(skip.SkipValue(
+ results.current_page, 'No detached contexts'))
+ else:
+ results.AddValue(scalar.ScalarValue(
+ results.current_page, _DISPLAY_NAME, _UNITS, value,
+ description=_DESCRIPTION))
« no previous file with comments | « tools/perf/benchmarks/v8.py ('k') | tools/perf/measurements/v8_detached_context_age_in_gc_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698