diff options
author | Anton Kirilov <anton.kirilov@linaro.org> | 2017-05-22 12:02:46 +0000 |
---|---|---|
committer | Linaro Android Code Review <android-review@review.linaro.org> | 2017-05-22 12:02:46 +0000 |
commit | 8fdb89de7b7a5fa1a0fdb1e71af883443fdd49f7 (patch) | |
tree | 86db2b45c3686a9d8737711cd3b93b350b7c5584 /tools | |
parent | f259da953dc531f03cfb21382d702d3c6bfb4340 (diff) | |
parent | 39199b73955945646c3e1b771677fb09e6aa3f88 (diff) | |
download | art-testing-8fdb89de7b7a5fa1a0fdb1e71af883443fdd49f7.tar.gz |
Merge "Implement cpuset support."
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/benchmarks/run.py | 47 | ||||
-rwxr-xr-x | tools/compilation_statistics/run.py | 24 | ||||
-rw-r--r-- | tools/utils.py | 3 |
3 files changed, 54 insertions, 20 deletions
diff --git a/tools/benchmarks/run.py b/tools/benchmarks/run.py index 989175a..271b6b7 100755 --- a/tools/benchmarks/run.py +++ b/tools/benchmarks/run.py @@ -64,8 +64,8 @@ def BuildOptions(): return args -def host_java(command): - return utils.Command(command, cwd=utils.dir_build_java_classes) +def host_java(command, command_string=None): + return utils.Command(command, command_string, cwd=utils.dir_build_java_classes) def DeleteAppInDalvikCache(target_copy_path, target): # We delete the entire dalvik-cache in the test path. @@ -83,8 +83,7 @@ def BuildBenchmarks(build_for_target): command += ['-t'] utils.Command(command) -def RunBenchADB(mode, compiler_mode, android_root, auto_calibrate, apk, - classname, target): +def RunBenchADB(mode, compiler_mode, android_root, auto_calibrate, apk, classname, target, cpuset): format_data = {'workdir': os.path.dirname(apk)} path, env, runtime_param = utils.GetAndroidRootConfiguration(android_root, mode == '64') # Escaping through `adb shell` is fiddly, so we expand the path fully in @@ -113,9 +112,14 @@ def RunBenchADB(mode, compiler_mode, android_root, auto_calibrate, apk, # - Performance critical funtions are JIT compiled as soon as possible. dalvikvm_options += ' -Xusejit:true -Xnodex2oat -Xjitthreshold:100' - command = 'cd {workdir} && ' + \ - ' '.join([environment_config, dalvikvm, - dalvikvm_options, '-cp', apk, apk_arguments]) + command = 'cd {workdir} && ' + + if cpuset: + command += 'echo $BASHPID > /dev/cpuset/' + cpuset + '/tasks && ' + dalvikvm = 'exec ' + dalvikvm + + command += ' '.join([environment_config, dalvikvm, + dalvikvm_options, '-cp', apk, apk_arguments]) command = command.format(**format_data) return utils_adb.shell(command, target, exit_on_error=False) @@ -126,12 +130,22 @@ def RunBenchHost(ignored_mode, auto_calibrate, ignored_apk, classname, - ignored_target): + ignored_target, + cpuset): + command_string = None + if auto_calibrate: command = ['java', bench_runner_main, classname] else: command = ['java', classname] - return host_java(command) + + if cpuset: + command_string = 'echo $BASHPID > /dev/cpuset/' + cpuset + '/tasks && ' + command_last = command_string + 'exec ' + ' '.join(command) + command_string += ' '.join(command) + command = ['bash', '-c', command_last] + + return host_java(command, command_string) # TODO: Avoid using global variables. @@ -144,7 +158,8 @@ def RunBench(apk, classname, mode = utils.default_mode, compiler_mode = utils.default_compiler_mode, android_root = utils.default_android_root, - target = None): + target = None, + cpuset = None): rc = 0 for iteration in range(iterations): try: @@ -154,7 +169,8 @@ def RunBench(apk, classname, auto_calibrate, apk, classname, - target) + target, + cpuset) rc += local_rc outerr = outerr.rstrip('\r\n') utils_print.VerbosePrint(outerr) @@ -187,7 +203,8 @@ def RunBenchs(apk, bench_names, iterations=utils.default_n_iterations, mode=utils.default_mode, compiler_mode=utils.default_compiler_mode, - android_root=utils.default_android_root): + android_root=utils.default_android_root, + cpuset=None): rc = 0 utils_print.VerbosePrint('\n# Running benchmarks: ' + ' '.join(bench_names)) run_helper = RunBenchADB if target else RunBenchHost @@ -200,7 +217,8 @@ def RunBenchs(apk, bench_names, mode = mode, compiler_mode = compiler_mode, android_root = android_root, - target = target) + target = target, + cpuset = cpuset) return rc @@ -253,7 +271,8 @@ def GetBenchmarkResults(args): args.iterations, args.mode, args.compiler_mode, - args.android_root) + args.android_root, + args.cpuset) if rc: utils.Error("The benchmarks did *not* run successfully. (rc = %d)" % rc, rc) diff --git a/tools/compilation_statistics/run.py b/tools/compilation_statistics/run.py index dce0ae4..4ee3b4c 100755 --- a/tools/compilation_statistics/run.py +++ b/tools/compilation_statistics/run.py @@ -74,6 +74,7 @@ def GetStats(apk, android_root, target_copy_path, iterations, + cpuset, work_dir, boot_oat_file): path, env, runtime_param = utils.GetAndroidRootConfiguration(android_root, isa.endswith('64')) @@ -124,7 +125,12 @@ def GetStats(apk, command = re.sub(" -j\d+ ", " -j1 ", command) # Remove newline at end. command = re.sub("\n$", "", command) - command = '(echo $BASHPID && ' + env + ' exec ' + command + ') | head -n1' + command = '(echo $BASHPID && ' + + if cpuset: + command += 'echo $BASHPID > /dev/cpuset/' + cpuset + '/tasks && ' + + command += env + ' exec ' + command + ') | head -n1' else: runtime_arguments = ' --runtime-arg -Xnorelocate ' @@ -137,9 +143,14 @@ def GetStats(apk, # Only the output of the first command is necessary; execute in a subshell # to guarantee PID value; only one thread is used for compilation to reduce # measurement noise. - command = '(echo $BASHPID && ' + env + ' exec ' + dex2oat + \ - ' -j1' + runtime_arguments + ' '.join(dex2oat_options) + \ - ' --dex-file=' + apk_path + ' --oat-file=' + oat + command = '(echo $BASHPID && ' + + if cpuset: + command += 'echo $BASHPID > /dev/cpuset/' + cpuset + '/tasks && ' + + command += env + ' exec ' + dex2oat + \ + ' -j1' + runtime_arguments + ' '.join(dex2oat_options) + \ + ' --dex-file=' + apk_path + ' --oat-file=' + oat command += ' --instruction-set=' + isa + ') | head -n1' linux_target = os.getenv('ART_TARGET_LINUX', 'false') == 'true' @@ -258,13 +269,14 @@ def GetCompilationStatisticsResults(args): for apk in sorted(apk_list): if apk[:8] == "boot.oat": res[apk] = GetStats(apk, args.target, isa, args.compiler_mode, args.android_root, - args.target_copy_path, args.iterations, work_dir, boot_oat_file) + args.target_copy_path, args.iterations, args.cpuset, work_dir, + boot_oat_file) else: utils_adb.push(apk, args.target_copy_path, args.target) apk_name = os.path.basename(apk) res[apk_name] = GetStats(apk_name, args.target, isa, args.compiler_mode, args.android_root, args.target_copy_path, - args.iterations, work_dir, None) + args.iterations, args.cpuset, work_dir, None) shutil.rmtree(work_dir) return res diff --git a/tools/utils.py b/tools/utils.py index e39a16d..695a943 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -174,6 +174,9 @@ def AddCommonRunOptions(parser): opts.add_argument('--android-root', default = default_android_root, help='Set root for android.') + opts.add_argument('--cpuset', + default = None, + help = 'Cpuset to use when running on target.') def ValidateCommonRunOptions(args): options_requiring_target_mode = ['mode', 'compiler-mode'] |