Commit ac28ca4a authored by Ned Nguyen's avatar Ned Nguyen Committed by Commit Bot

Improve the sharding algorithm & reshard linux_perf, mac_1013_high_end, and mac_1012_low_end

This CL improve the sharding algorithm by adjusting the policy of picking a story
at the boundary a benchmark shard.

Before this, we will keep adding story to a benchmark shard until the total time
assigned is greater than expected total time (assuming assignment is perfect).
This CL changes it to keep adding story until the absolute value of the difference
between total time assigned and expeted total time is minimal.

The effectiveness of this change can be shown by looking at the predict stats ("extra_info" field)
in the 3 shards: linux_perf_shard_map, mac_1012_low_end_26_shard_map,
mac_1013_high_end_26_shard_map.

Change-Id: I3ace373fb1393658cc21aca1a61a66d865a8c059

NOTRY=true  # tests covered by PRESUBMIT

Change-Id: I3ace373fb1393658cc21aca1a61a66d865a8c059
Reviewed-on: https://chromium-review.googlesource.com/1108374
Commit-Queue: Ned Nguyen <nednguyen@google.com>
Reviewed-by: default avatarEmily Hanley <eyaich@chromium.org>
Reviewed-by: default avatarAshley Enstad <ashleymarie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569241}
parent 6ea21191
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
"blink_perf.events": {}, "blink_perf.events": {},
"blink_perf.image_decoder": {}, "blink_perf.image_decoder": {},
"blink_perf.layout": { "blink_perf.layout": {
"end": 32 "end": 31
} }
} }
}, },
"1": { "1": {
"benchmarks": { "benchmarks": {
"blink_perf.layout": { "blink_perf.layout": {
"begin": 32 "begin": 31
}, },
"blink_perf.owp_storage": {}, "blink_perf.owp_storage": {},
"blink_perf.paint": {}, "blink_perf.paint": {},
...@@ -52,14 +52,14 @@ ...@@ -52,14 +52,14 @@
}, },
"loading.mobile": {}, "loading.mobile": {},
"media.desktop": { "media.desktop": {
"end": 19 "end": 18
} }
} }
}, },
"5": { "5": {
"benchmarks": { "benchmarks": {
"media.desktop": { "media.desktop": {
"begin": 19 "begin": 18
}, },
"media.mobile": {}, "media.mobile": {},
"memory.desktop": {}, "memory.desktop": {},
...@@ -69,14 +69,14 @@ ...@@ -69,14 +69,14 @@
"octane": {}, "octane": {},
"oortonline_tbmv2": {}, "oortonline_tbmv2": {},
"power.desktop": { "power.desktop": {
"end": 4 "end": 3
} }
} }
}, },
"6": { "6": {
"benchmarks": { "benchmarks": {
"power.desktop": { "power.desktop": {
"begin": 4 "begin": 3
}, },
"power.idle_platform": {}, "power.idle_platform": {},
"power.typical_10_mobile": {}, "power.typical_10_mobile": {},
...@@ -100,22 +100,22 @@ ...@@ -100,22 +100,22 @@
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 58, "begin": 58,
"end": 132 "end": 131
} }
} }
}, },
"9": { "9": {
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 132, "begin": 131,
"end": 215 "end": 214
} }
} }
}, },
"10": { "10": {
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 215 "begin": 214
}, },
"rendering.mobile": {}, "rendering.mobile": {},
"scheduler.tough_scheduling_cases": {}, "scheduler.tough_scheduling_cases": {},
...@@ -135,11 +135,16 @@ ...@@ -135,11 +135,16 @@
"smoothness.pathological_mobile_sites": {}, "smoothness.pathological_mobile_sites": {},
"smoothness.simple_mobile_sites": {}, "smoothness.simple_mobile_sites": {},
"smoothness.sync_scroll.key_mobile_sites_smooth": {}, "smoothness.sync_scroll.key_mobile_sites_smooth": {},
"smoothness.top_25_smooth": {} "smoothness.top_25_smooth": {
"end": 24
}
} }
}, },
"11": { "11": {
"benchmarks": { "benchmarks": {
"smoothness.top_25_smooth": {
"begin": 24
},
"smoothness.tough_ad_cases": {}, "smoothness.tough_ad_cases": {},
"smoothness.tough_animation_cases": { "smoothness.tough_animation_cases": {
"end": 62 "end": 62
...@@ -159,14 +164,14 @@ ...@@ -159,14 +164,14 @@
"smoothness.tough_scrolling_cases": {}, "smoothness.tough_scrolling_cases": {},
"smoothness.tough_texture_upload_cases": {}, "smoothness.tough_texture_upload_cases": {},
"smoothness.tough_webgl_ad_cases": { "smoothness.tough_webgl_ad_cases": {
"end": 5 "end": 4
} }
} }
}, },
"13": { "13": {
"benchmarks": { "benchmarks": {
"smoothness.tough_webgl_ad_cases": { "smoothness.tough_webgl_ad_cases": {
"begin": 5 "begin": 4
}, },
"smoothness.tough_webgl_cases": {}, "smoothness.tough_webgl_cases": {},
"speedometer": {}, "speedometer": {},
...@@ -184,14 +189,14 @@ ...@@ -184,14 +189,14 @@
"benchmarks": { "benchmarks": {
"system_health.common_desktop": { "system_health.common_desktop": {
"begin": 23, "begin": 23,
"end": 60 "end": 61
} }
} }
}, },
"15": { "15": {
"benchmarks": { "benchmarks": {
"system_health.common_desktop": { "system_health.common_desktop": {
"begin": 60 "begin": 61
}, },
"system_health.common_mobile": {}, "system_health.common_mobile": {},
"system_health.memory_desktop": { "system_health.memory_desktop": {
...@@ -203,30 +208,30 @@ ...@@ -203,30 +208,30 @@
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 11, "begin": 11,
"end": 29 "end": 28
} }
} }
}, },
"17": { "17": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 29, "begin": 28,
"end": 53 "end": 52
} }
} }
}, },
"18": { "18": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 53, "begin": 52,
"end": 59 "end": 58
} }
} }
}, },
"19": { "19": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 59 "begin": 58
}, },
"system_health.memory_mobile": {}, "system_health.memory_mobile": {},
"system_health.webview_startup": {}, "system_health.webview_startup": {},
...@@ -259,38 +264,38 @@ ...@@ -259,38 +264,38 @@
"v8.browsing_desktop": { "v8.browsing_desktop": {
"begin": 18 "begin": 18
}, },
"v8.browsing_desktop-future": {} "v8.browsing_desktop-future": {},
"v8.browsing_mobile": {},
"v8.browsing_mobile-future": {}
} }
}, },
"22": { "22": {
"benchmarks": { "benchmarks": {
"v8.browsing_mobile": {},
"v8.browsing_mobile-future": {},
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"end": 39 "end": 38
} }
} }
}, },
"23": { "23": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 39, "begin": 38,
"end": 81 "end": 80
} }
} }
}, },
"24": { "24": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 81, "begin": 80,
"end": 120 "end": 119
} }
} }
}, },
"25": { "25": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 120 "begin": 119
}, },
"wasm": {}, "wasm": {},
"webrtc": {} "webrtc": {}
...@@ -298,9 +303,9 @@ ...@@ -298,9 +303,9 @@
}, },
"extra_infos": { "extra_infos": {
"num_stories": 2401, "num_stories": 2401,
"predicted_min_shard_time": 2442.7268490479796, "predicted_min_shard_time": 2971.1511643131307,
"predicted_min_shard_index": 18, "predicted_min_shard_index": 16,
"predicted_max_shard_time": 3869.938049616162, "predicted_max_shard_time": 3198.222966333333,
"predicted_max_shard_index": 17 "predicted_max_shard_index": 19
} }
} }
\ No newline at end of file
...@@ -29,22 +29,22 @@ ...@@ -29,22 +29,22 @@
"jetstream": {}, "jetstream": {},
"kraken": {}, "kraken": {},
"loading.desktop": { "loading.desktop": {
"end": 13 "end": 12
} }
} }
}, },
"2": { "2": {
"benchmarks": { "benchmarks": {
"loading.desktop": { "loading.desktop": {
"begin": 13, "begin": 12,
"end": 52 "end": 51
} }
} }
}, },
"3": { "3": {
"benchmarks": { "benchmarks": {
"loading.desktop": { "loading.desktop": {
"begin": 52, "begin": 51,
"end": 85 "end": 85
} }
} }
...@@ -56,17 +56,12 @@ ...@@ -56,17 +56,12 @@
}, },
"loading.mobile": {}, "loading.mobile": {},
"media.desktop": {}, "media.desktop": {},
"media.mobile": {}, "media.mobile": {}
"memory.desktop": {
"end": 1
}
} }
}, },
"5": { "5": {
"benchmarks": { "benchmarks": {
"memory.desktop": { "memory.desktop": {},
"begin": 1
},
"memory.long_running_idle_gmail_background_tbmv2": {}, "memory.long_running_idle_gmail_background_tbmv2": {},
"memory.long_running_idle_gmail_tbmv2": {}, "memory.long_running_idle_gmail_tbmv2": {},
"memory.top_10_mobile": {}, "memory.top_10_mobile": {},
...@@ -95,14 +90,14 @@ ...@@ -95,14 +90,14 @@
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 11, "begin": 11,
"end": 65 "end": 64
} }
} }
}, },
"8": { "8": {
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 65, "begin": 64,
"end": 126 "end": 126
} }
} }
...@@ -129,14 +124,14 @@ ...@@ -129,14 +124,14 @@
"smoothness.gpu_rasterization.tough_path_rendering_cases": {}, "smoothness.gpu_rasterization.tough_path_rendering_cases": {},
"smoothness.gpu_rasterization.tough_pinch_zoom_cases": {}, "smoothness.gpu_rasterization.tough_pinch_zoom_cases": {},
"smoothness.gpu_rasterization.tough_scrolling_cases": { "smoothness.gpu_rasterization.tough_scrolling_cases": {
"end": 32 "end": 31
} }
} }
}, },
"11": { "11": {
"benchmarks": { "benchmarks": {
"smoothness.gpu_rasterization.tough_scrolling_cases": { "smoothness.gpu_rasterization.tough_scrolling_cases": {
"begin": 32 "begin": 31
}, },
"smoothness.gpu_rasterization_and_decoding.image_decoding_cases": {}, "smoothness.gpu_rasterization_and_decoding.image_decoding_cases": {},
"smoothness.image_decoding_cases": {}, "smoothness.image_decoding_cases": {},
...@@ -192,25 +187,25 @@ ...@@ -192,25 +187,25 @@
"benchmarks": { "benchmarks": {
"system_health.common_desktop": { "system_health.common_desktop": {
"begin": 9, "begin": 9,
"end": 54 "end": 55
} }
} }
}, },
"15": { "15": {
"benchmarks": { "benchmarks": {
"system_health.common_desktop": { "system_health.common_desktop": {
"begin": 54 "begin": 55
}, },
"system_health.common_mobile": {}, "system_health.common_mobile": {},
"system_health.memory_desktop": { "system_health.memory_desktop": {
"end": 10 "end": 9
} }
} }
}, },
"16": { "16": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 10, "begin": 9,
"end": 28 "end": 28
} }
} }
...@@ -219,22 +214,22 @@ ...@@ -219,22 +214,22 @@
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 28, "begin": 28,
"end": 52 "end": 51
} }
} }
}, },
"18": { "18": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 52, "begin": 51,
"end": 59 "end": 58
} }
} }
}, },
"19": { "19": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 59 "begin": 58
}, },
"system_health.memory_mobile": {}, "system_health.memory_mobile": {},
"system_health.webview_startup": {}, "system_health.webview_startup": {},
...@@ -247,42 +242,42 @@ ...@@ -247,42 +242,42 @@
"thread_times.simple_mobile_sites": {}, "thread_times.simple_mobile_sites": {},
"thread_times.tough_compositor_cases": {}, "thread_times.tough_compositor_cases": {},
"thread_times.tough_scrolling_cases": { "thread_times.tough_scrolling_cases": {
"end": 22 "end": 21
} }
} }
}, },
"20": { "20": {
"benchmarks": { "benchmarks": {
"thread_times.tough_scrolling_cases": { "thread_times.tough_scrolling_cases": {
"begin": 22 "begin": 21
}, },
"tracing.tracing_with_background_memory_infra": {}, "tracing.tracing_with_background_memory_infra": {},
"v8.browsing_desktop": { "v8.browsing_desktop": {
"end": 18 "end": 17
} }
} }
}, },
"21": { "21": {
"benchmarks": { "benchmarks": {
"v8.browsing_desktop": { "v8.browsing_desktop": {
"begin": 18 "begin": 17
}, },
"v8.browsing_desktop-future": {} "v8.browsing_desktop-future": {},
"v8.browsing_mobile": {},
"v8.browsing_mobile-future": {}
} }
}, },
"22": { "22": {
"benchmarks": { "benchmarks": {
"v8.browsing_mobile": {},
"v8.browsing_mobile-future": {},
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"end": 38 "end": 37
} }
} }
}, },
"23": { "23": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 38, "begin": 37,
"end": 78 "end": 78
} }
} }
...@@ -291,14 +286,14 @@ ...@@ -291,14 +286,14 @@
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 78, "begin": 78,
"end": 121 "end": 120
} }
} }
}, },
"25": { "25": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 121 "begin": 120
}, },
"wasm": {}, "wasm": {},
"webrtc": {} "webrtc": {}
...@@ -306,9 +301,9 @@ ...@@ -306,9 +301,9 @@
}, },
"extra_infos": { "extra_infos": {
"num_stories": 2401, "num_stories": 2401,
"predicted_min_shard_time": 2686.0698310505054, "predicted_min_shard_time": 2776.9827897373734,
"predicted_min_shard_index": 19, "predicted_min_shard_index": 15,
"predicted_max_shard_time": 3190.7565990909093, "predicted_max_shard_time": 3109.875536161616,
"predicted_max_shard_index": 18 "predicted_max_shard_index": 16
} }
} }
\ No newline at end of file
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
"blink_perf.events": {}, "blink_perf.events": {},
"blink_perf.image_decoder": {}, "blink_perf.image_decoder": {},
"blink_perf.layout": { "blink_perf.layout": {
"end": 56 "end": 55
} }
} }
}, },
"1": { "1": {
"benchmarks": { "benchmarks": {
"blink_perf.layout": { "blink_perf.layout": {
"begin": 56 "begin": 55
}, },
"blink_perf.owp_storage": {}, "blink_perf.owp_storage": {},
"blink_perf.paint": {}, "blink_perf.paint": {},
...@@ -45,25 +45,25 @@ ...@@ -45,25 +45,25 @@
"benchmarks": { "benchmarks": {
"loading.desktop": { "loading.desktop": {
"begin": 44, "begin": 44,
"end": 81 "end": 80
} }
} }
}, },
"4": { "4": {
"benchmarks": { "benchmarks": {
"loading.desktop": { "loading.desktop": {
"begin": 81 "begin": 80
}, },
"loading.mobile": {}, "loading.mobile": {},
"media.desktop": { "media.desktop": {
"end": 26 "end": 25
} }
} }
}, },
"5": { "5": {
"benchmarks": { "benchmarks": {
"media.desktop": { "media.desktop": {
"begin": 26 "begin": 25
}, },
"media.mobile": {}, "media.mobile": {},
"memory.desktop": {}, "memory.desktop": {},
...@@ -95,30 +95,30 @@ ...@@ -95,30 +95,30 @@
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 7, "begin": 7,
"end": 65 "end": 64
} }
} }
}, },
"8": { "8": {
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 65, "begin": 64,
"end": 128 "end": 127
} }
} }
}, },
"9": { "9": {
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 128, "begin": 127,
"end": 207 "end": 206
} }
} }
}, },
"10": { "10": {
"benchmarks": { "benchmarks": {
"rendering.desktop": { "rendering.desktop": {
"begin": 207 "begin": 206
}, },
"rendering.mobile": {}, "rendering.mobile": {},
"scheduler.tough_scheduling_cases": {}, "scheduler.tough_scheduling_cases": {},
...@@ -150,14 +150,14 @@ ...@@ -150,14 +150,14 @@
"smoothness.top_25_smooth": {}, "smoothness.top_25_smooth": {},
"smoothness.tough_ad_cases": {}, "smoothness.tough_ad_cases": {},
"smoothness.tough_animation_cases": { "smoothness.tough_animation_cases": {
"end": 35 "end": 34
} }
} }
}, },
"12": { "12": {
"benchmarks": { "benchmarks": {
"smoothness.tough_animation_cases": { "smoothness.tough_animation_cases": {
"begin": 35 "begin": 34
}, },
"smoothness.tough_canvas_cases": {}, "smoothness.tough_canvas_cases": {},
"smoothness.tough_filters_cases": {}, "smoothness.tough_filters_cases": {},
...@@ -165,14 +165,14 @@ ...@@ -165,14 +165,14 @@
"smoothness.tough_path_rendering_cases": {}, "smoothness.tough_path_rendering_cases": {},
"smoothness.tough_pinch_zoom_cases": {}, "smoothness.tough_pinch_zoom_cases": {},
"smoothness.tough_scrolling_cases": { "smoothness.tough_scrolling_cases": {
"end": 14 "end": 13
} }
} }
}, },
"13": { "13": {
"benchmarks": { "benchmarks": {
"smoothness.tough_scrolling_cases": { "smoothness.tough_scrolling_cases": {
"begin": 14 "begin": 13
}, },
"smoothness.tough_texture_upload_cases": {}, "smoothness.tough_texture_upload_cases": {},
"smoothness.tough_webgl_ad_cases": {}, "smoothness.tough_webgl_ad_cases": {},
...@@ -192,14 +192,14 @@ ...@@ -192,14 +192,14 @@
"benchmarks": { "benchmarks": {
"system_health.common_desktop": { "system_health.common_desktop": {
"begin": 11, "begin": 11,
"end": 58 "end": 57
} }
} }
}, },
"15": { "15": {
"benchmarks": { "benchmarks": {
"system_health.common_desktop": { "system_health.common_desktop": {
"begin": 58 "begin": 57
}, },
"system_health.common_mobile": {}, "system_health.common_mobile": {},
"system_health.memory_desktop": { "system_health.memory_desktop": {
...@@ -219,14 +219,14 @@ ...@@ -219,14 +219,14 @@
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 29, "begin": 29,
"end": 53 "end": 52
} }
} }
}, },
"18": { "18": {
"benchmarks": { "benchmarks": {
"system_health.memory_desktop": { "system_health.memory_desktop": {
"begin": 53, "begin": 52,
"end": 59 "end": 59
} }
} }
...@@ -247,14 +247,14 @@ ...@@ -247,14 +247,14 @@
"thread_times.simple_mobile_sites": {}, "thread_times.simple_mobile_sites": {},
"thread_times.tough_compositor_cases": {}, "thread_times.tough_compositor_cases": {},
"thread_times.tough_scrolling_cases": { "thread_times.tough_scrolling_cases": {
"end": 27 "end": 26
} }
} }
}, },
"20": { "20": {
"benchmarks": { "benchmarks": {
"thread_times.tough_scrolling_cases": { "thread_times.tough_scrolling_cases": {
"begin": 27 "begin": 26
}, },
"tracing.tracing_with_background_memory_infra": {}, "tracing.tracing_with_background_memory_infra": {},
"v8.browsing_desktop": { "v8.browsing_desktop": {
...@@ -268,14 +268,14 @@ ...@@ -268,14 +268,14 @@
"begin": 17 "begin": 17
}, },
"v8.browsing_desktop-future": { "v8.browsing_desktop-future": {
"end": 18 "end": 17
} }
} }
}, },
"22": { "22": {
"benchmarks": { "benchmarks": {
"v8.browsing_desktop-future": { "v8.browsing_desktop-future": {
"begin": 18 "begin": 17
}, },
"v8.browsing_mobile": {}, "v8.browsing_mobile": {},
"v8.browsing_mobile-future": {}, "v8.browsing_mobile-future": {},
...@@ -288,22 +288,22 @@ ...@@ -288,22 +288,22 @@
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 35, "begin": 35,
"end": 76 "end": 75
} }
} }
}, },
"24": { "24": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 76, "begin": 75,
"end": 118 "end": 117
} }
} }
}, },
"25": { "25": {
"benchmarks": { "benchmarks": {
"v8.runtime_stats.top_25": { "v8.runtime_stats.top_25": {
"begin": 118 "begin": 117
}, },
"wasm": {}, "wasm": {},
"webrtc": {} "webrtc": {}
...@@ -311,9 +311,9 @@ ...@@ -311,9 +311,9 @@
}, },
"extra_infos": { "extra_infos": {
"num_stories": 2401, "num_stories": 2401,
"predicted_min_shard_time": 1956.2044916944444, "predicted_min_shard_time": 2614.9442498055555,
"predicted_min_shard_index": 18, "predicted_min_shard_index": 17,
"predicted_max_shard_time": 3590.0444336944443, "predicted_max_shard_time": 2931.3046755833334,
"predicted_max_shard_index": 17 "predicted_max_shard_index": 18
} }
} }
\ No newline at end of file
...@@ -73,21 +73,24 @@ from telemetry.internal.browser import browser_options ...@@ -73,21 +73,24 @@ from telemetry.internal.browser import browser_options
def main(args, benchmarks): def main(args, benchmarks):
story_timing_dict = _load_timing_data_from_file(benchmarks, args.timing_data) story_timing_ordered_dict = _load_timing_data_from_file(
benchmarks, args.timing_data)
all_stories = {} all_stories = {}
for b in benchmarks: for b in benchmarks:
all_stories[b.Name()] = _get_stories_for_benchmark(b) all_stories[b.Name()] = _get_stories_for_benchmark(b)
sharding_map = generate_sharding_map(story_timing_dict, sharding_map = generate_sharding_map(story_timing_ordered_dict,
all_stories, args.num_shards, args.debug) all_stories, args.num_shards, args.debug)
with open(args.output_file, 'w') as output_file: with open(args.output_file, 'w') as output_file:
json.dump(sharding_map, output_file, indent = 4, separators=(',', ': ')) json.dump(sharding_map, output_file, indent = 4, separators=(',', ': '))
if args.test_data: if args.test_data:
story_timing_dict = _load_timing_data_from_file(benchmarks, args.test_data) story_timing_ordered_dict = _load_timing_data_from_file(
print test_sharding_map(args.output_file, story_timing_dict, all_stories) benchmarks, args.test_data)
print test_sharding_map(
args.output_file, story_timing_ordered_dict, all_stories)
def get_args(): def get_args():
...@@ -116,8 +119,11 @@ def get_args(): ...@@ -116,8 +119,11 @@ def get_args():
return parser return parser
def generate_sharding_map(story_timing_dict, all_stories, num_shards, debug): def generate_sharding_map(
max_time_per_shard = _get_max_time_per_shard(story_timing_dict, num_shards) story_timing_ordered_dict, all_stories, num_shards, debug):
expected_time_per_shard = _get_expected_time_per_shard(
story_timing_ordered_dict, num_shards)
total_time = 0 total_time = 0
sharding_map = OrderedDict() sharding_map = OrderedDict()
...@@ -126,27 +132,36 @@ def generate_sharding_map(story_timing_dict, all_stories, num_shards, debug): ...@@ -126,27 +132,36 @@ def generate_sharding_map(story_timing_dict, all_stories, num_shards, debug):
min_shard_index = None min_shard_index = None
max_shard_time = 0 max_shard_time = 0
max_shard_index = None max_shard_index = None
num_stories = len(story_timing_dict) num_stories = len(story_timing_ordered_dict)
for i in range(num_shards): for i in range(num_shards):
sharding_map[str(i)] = {'benchmarks': OrderedDict()} sharding_map[str(i)] = {'benchmarks': OrderedDict()}
debug_map[str(i)] = OrderedDict() debug_map[str(i)] = OrderedDict()
time_per_shard = 0 time_per_shard = 0
stories_in_shard = [] stories_in_shard = []
while total_time < max_time_per_shard * (i + 1) and len( expected_total_time = expected_time_per_shard * (i + 1)
story_timing_dict) > 0: last_diff = abs(total_time - expected_total_time)
(story, time) = story_timing_dict.popitem(last=False) # Keep adding story to the current shard until the absolute difference
# between the total time of shards so far and expected total time is
# minimal.
while (story_timing_ordered_dict and
abs(total_time + story_timing_ordered_dict.items()[0][1] -
expected_total_time) <= last_diff):
(story, time) = story_timing_ordered_dict.popitem(last=False)
total_time += time total_time += time
time_per_shard += time time_per_shard += time
stories_in_shard.append(story) stories_in_shard.append(story)
debug_map[str(i)][story] = time debug_map[str(i)][story] = time
last_diff = abs(total_time - expected_total_time)
_add_benchmarks_to_shard(sharding_map, i, stories_in_shard, all_stories) _add_benchmarks_to_shard(sharding_map, i, stories_in_shard, all_stories)
debug_map[str(i)]['full_time'] = time_per_shard # Double time_per_shard to account for reference benchmark run.
debug_map[str(i)]['expected_total_time'] = time_per_shard * 2
if time_per_shard > max_shard_time: if time_per_shard > max_shard_time:
max_shard_time = time_per_shard max_shard_time = time_per_shard
max_shard_index = i max_shard_index = i
if time_per_shard < min_shard_time: if time_per_shard < min_shard_time:
min_shard_time = time_per_shard min_shard_time = time_per_shard
min_shard_index = i min_shard_index = i
if debug: if debug:
with open(debug, 'w') as output_file: with open(debug, 'w') as output_file:
json.dump(debug_map, output_file, indent = 4, separators=(',', ': ')) json.dump(debug_map, output_file, indent = 4, separators=(',', ': '))
...@@ -163,7 +178,7 @@ def generate_sharding_map(story_timing_dict, all_stories, num_shards, debug): ...@@ -163,7 +178,7 @@ def generate_sharding_map(story_timing_dict, all_stories, num_shards, debug):
return sharding_map return sharding_map
def _get_max_time_per_shard(timing_data, num_shards): def _get_expected_time_per_shard(timing_data, num_shards):
total_run_time = 0 total_run_time = 0
for story in timing_data: for story in timing_data:
total_run_time += timing_data[story] total_run_time += timing_data[story]
...@@ -193,14 +208,14 @@ def _add_benchmarks_to_shard(sharding_map, shard_index, stories_in_shard, ...@@ -193,14 +208,14 @@ def _add_benchmarks_to_shard(sharding_map, shard_index, stories_in_shard,
def _load_timing_data_from_file(benchmarks, timing_data_file): def _load_timing_data_from_file(benchmarks, timing_data_file):
story_timing_dict = _init_timing_dict_for_benchmarks(benchmarks) story_timing_ordered_dict = _init_timing_dict_for_benchmarks(benchmarks)
with open(timing_data_file, 'r') as timing_data_file: with open(timing_data_file, 'r') as timing_data_file:
story_timing = json.load(timing_data_file) story_timing = json.load(timing_data_file)
for run in story_timing: for run in story_timing:
if run['name'] in story_timing_dict: if run['name'] in story_timing_ordered_dict:
if run['duration']: if run['duration']:
story_timing_dict[run['name']] += float(run['duration']) story_timing_ordered_dict[run['name']] += float(run['duration'])
return story_timing_dict return story_timing_ordered_dict
def _init_timing_dict_for_benchmarks(benchmarks): def _init_timing_dict_for_benchmarks(benchmarks):
......
...@@ -37,8 +37,8 @@ class TestShardingMapGenerator(unittest.TestCase): ...@@ -37,8 +37,8 @@ class TestShardingMapGenerator(unittest.TestCase):
json.dump(sharding_map, f) json.dump(sharding_map, f)
results = sharding_map_generator.test_sharding_map(map_path, results = sharding_map_generator.test_sharding_map(map_path,
timing_data_for_testing, all_stories) timing_data_for_testing, all_stories)
self.assertEqual(results['0']['full_time'], 173) self.assertEqual(results['0']['full_time'], 116)
self.assertEqual(results['1']['full_time'], 120) self.assertEqual(results['1']['full_time'], 177)
self.assertEqual(results['2']['full_time'], 140) self.assertEqual(results['2']['full_time'], 140)
finally: finally:
os.remove(map_path) os.remove(map_path)
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