aboutsummaryrefslogtreecommitdiff
path: root/crosperf/benchmark_run.py
diff options
context:
space:
mode:
authorHan Shen <shenhan@google.com>2015-08-05 17:19:55 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-20 20:29:33 +0000
commitba64928c5dcbacbc70b4358881a89ad96227164d (patch)
tree4d2887d79204febd1c5b016810b2a65bb7551c91 /crosperf/benchmark_run.py
parent0aa17b4641bcc205c52e6db0c529dd3126003ec5 (diff)
downloadtoolchain-utils-ba64928c5dcbacbc70b4358881a89ad96227164d.tar.gz
Crosperf schedv2 (1) - new option and integrating new scheduler.
This Cl introduces a new option '--schedv2' which uses the new scheduler to allocate jobs (benchmark_runs) to duts. With this option, schedv2 takes control of storing/allocating jobs and reimage machines using the new algorithm. This CL leaves actual reimaging and running jobs non-op (a random time sleep is used for each such op, which would be replace in later CLs.) You may try this CL like this and see how schedv2 works - crosperf --locks_dir=/usr/local/google/home/shenhan/tmp --use_file_locks=True --logging_level=verbose --schedv2 some.exp Change-Id: If5bb7751b466c39e54c93fe8f0b4e363be6d9165 Reviewed-on: https://chrome-internal-review.googlesource.com/225515 Commit-Queue: Han Shen <shenhan@google.com> Tested-by: Han Shen <shenhan@google.com> Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'crosperf/benchmark_run.py')
-rw-r--r--crosperf/benchmark_run.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/crosperf/benchmark_run.py b/crosperf/benchmark_run.py
index cee41dac..dabbdeb2 100644
--- a/crosperf/benchmark_run.py
+++ b/crosperf/benchmark_run.py
@@ -64,6 +64,9 @@ class BenchmarkRun(threading.Thread):
self.timeline.Record(STATUS_PENDING)
self.share_cache = share_cache
+ # This is used by schedv2.
+ self.owner_thread = None
+
def ReadCache(self):
# Just use the first machine for running the cached version,
# without locking it.
@@ -137,7 +140,10 @@ class BenchmarkRun(threading.Thread):
self.timeline.Record(STATUS_FAILED)
self.failure_reason = str(e)
finally:
- if self.machine:
+ if self.owner_thread is not None:
+ # In schedv2 mode, we do not lock machine locally. So noop here.
+ pass
+ elif self.machine:
if not self.machine.IsReachable():
self._logger.LogOutput("Machine %s is not reachable, removing it."
% self.machine.name)
@@ -154,6 +160,10 @@ class BenchmarkRun(threading.Thread):
self.failure_reason = "Thread terminated."
def AcquireMachine(self):
+ if self.owner_thread is not None:
+ # No need to lock machine locally, DutWorker, which is a thread, is
+ # responsible for running br.
+ return self.owner_thread.dut()
while True:
machine = None
if self.terminated:
@@ -204,8 +214,13 @@ class BenchmarkRun(threading.Thread):
def RunTest(self, machine):
self.timeline.Record(STATUS_IMAGING)
- self.machine_manager.ImageMachine(machine,
- self.label)
+ if self.owner_thread is not None:
+ # In schedv2 mode, do not even call ImageMachine. Machine image is
+ # guarenteed.
+ pass
+ else:
+ self.machine_manager.ImageMachine(machine,
+ self.label)
self.timeline.Record(STATUS_RUNNING)
[retval, out, err] = self.suite_runner.Run(machine.name,
self.label,
@@ -226,6 +241,11 @@ class BenchmarkRun(threading.Thread):
def SetCacheConditions(self, cache_conditions):
self.cache_conditions = cache_conditions
+ def __str__(self):
+ """For better debugging."""
+
+ return 'BenchmarkRun[name="{}"]'.format(self.name)
+
class MockBenchmarkRun(BenchmarkRun):
"""Inherited from BenchmarkRuna."""