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

Unified Diff: telemetry/telemetry/util/bot_utils.py

Issue 2408783002: Factoring out device affinity generation to be used in swarming (Closed)
Patch Set: Pulling out into a utility Created 4 years, 2 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 | « telemetry/telemetry/benchmark_runner.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/util/bot_utils.py
diff --git a/telemetry/telemetry/util/bot_utils.py b/telemetry/telemetry/util/bot_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..70955f5d3a4ab2e443df261d0c0c7d5ef9a2f7d2
--- /dev/null
+++ b/telemetry/telemetry/util/bot_utils.py
@@ -0,0 +1,27 @@
+# Copyright 2013 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.
+
+"""
+Utility functions used to generate info used by the bots.
+
+TODO(eyaich): Remove once we no longer generate the list of benchmarks to
+run on the perf waterfall in telemetry.
+"""
+
+import hashlib
+
+def GetDeviceAffinity(num_shards, base_name):
+ # Based on the current timings, we shift the result of the hash function to
+ # achieve better load balancing. Those shift values are to be revised when
+ # necessary. The shift value is calculated such that the total cycle time
+ # is minimized.
+ hash_shift = {
+ 2 : 47, # for old desktop configurations with 2 slaves
+ 5 : 56, # for new desktop configurations with 5 slaves
+ 21 : 43 # for Android 3 slaves 7 devices configurations
+ }
+ shift = hash_shift.get(num_shards, 0)
+ base_name_hash = hashlib.sha1(base_name).hexdigest()
+ device_affinity = (int(base_name_hash, 16) >> shift) % num_shards
+ return device_affinity
« no previous file with comments | « telemetry/telemetry/benchmark_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698