Bug 1474208: Use median of all process values for AWSY base content. r?erahm draft
authorKris Maglione <maglione.k@gmail.com>
Sun, 08 Jul 2018 11:50:46 -0700
changeset 815765 df958ecd1ed3ce6f7aaa2045b5be0c8c86087708
parent 815490 4a17cb8ebd21ca3f583132f7aea42fd7cd588522
push id115650
push usermaglione.k@gmail.com
push dateMon, 09 Jul 2018 23:53:57 +0000
reviewerserahm
bugs1474208
milestone63.0a1
Bug 1474208: Use median of all process values for AWSY base content. r?erahm MozReview-Commit-ID: DBiJjeTlyZE
testing/awsy/awsy/process_perf_data.py
testing/awsy/awsy/test_base_memory_usage.py
--- a/testing/awsy/awsy/process_perf_data.py
+++ b/testing/awsy/awsy/process_perf_data.py
@@ -27,16 +27,24 @@ CHECKPOINTS = [
 PERF_SUITES = [
     { 'name': "Resident Memory", 'node': "resident" },
     { 'name': "Explicit Memory", 'node': "explicit/" },
     { 'name': "Heap Unclassified", 'node': "explicit/heap-unclassified" },
     { 'name': "JS", 'node': "js-main-runtime/" },
     { 'name': "Images", 'node': "explicit/images/" }
 ]
 
+def median(values):
+    sorted_ = sorted(values)
+    med = int(len(sorted_) / 2)
+
+    if len(sorted_) % 2:
+        return sorted_[med]
+    return (sorted_[med - 1] + sorted_[med]) / 2
+
 def update_checkpoint_paths(checkpoint_files, checkpoints):
     """
     Updates checkpoints with memory report file fetched in data_path
     :param checkpoint_files: list of files in data_path
     :param checkpoints: The checkpoints to update the path of.
     """
     target_path = [['Start-', 0],
                       ['StartSettled-', 0],
@@ -80,25 +88,25 @@ def create_suite(name, node, data_path, 
         suite['extraOptions'] = ["stylo-sequential"]
     update_checkpoint_paths(glob.glob(os.path.join(data_path, "memory-report*")), checkpoints)
 
     total = 0
     for checkpoint in checkpoints:
         memory_report_path = os.path.join(data_path, checkpoint['path'])
 
         name_filter = checkpoint.get('name_filter', None)
-        count = checkpoint.get('count', 0)
+        if checkpoint.get('median'):
+            process = median
+        else:
+            process = sum
 
         if node != "resident":
             totals = parse_about_memory.calculate_memory_report_values(
                                             memory_report_path, node, name_filter)
-            if count:
-                value = sum(totals.values()[:count])
-            else:
-                value = sum(totals.values())
+            value = process(totals.values())
         else:
             # For "resident" we really want RSS of the chrome ("Main") process
             # and USS of the child processes. We'll still call it resident
             # for simplicity (it's nice to be able to compare RSS of non-e10s
             # with RSS + USS of e10s).
             totals_rss = parse_about_memory.calculate_memory_report_values(
                                             memory_report_path, node, 'Main')
             totals_uss = parse_about_memory.calculate_memory_report_values(
--- a/testing/awsy/awsy/test_base_memory_usage.py
+++ b/testing/awsy/awsy/test_base_memory_usage.py
@@ -12,17 +12,17 @@ if AWSY_PATH not in sys.path:
 from awsy.awsy_test_case import AwsyTestCase
 
 # A description of each checkpoint and the root path to it.
 CHECKPOINTS = [
     {
         'name': "After tabs open [+30s, forced GC]",
         'path': "memory-report-TabsOpenForceGC-4.json.gz",
         'name_filter': 'Web Content', # We only want the content process
-        'count': 1 # We only care about the first one
+        'median': True, # We want the median from all content processes
     },
 ]
 
 # A description of each perfherder suite and the path to its values.
 PERF_SUITES = [
     { 'name': "Base Content Resident Unique Memory", 'node': "resident-unique" },
     { 'name': "Base Content Heap Unclassified", 'node': "explicit/heap-unclassified" },
     { 'name': "Base Content JS", 'node': "js-main-runtime/" },