Add explicit argument for running on golem
If passed, link in third party dependencies explicitly in scripts and don't build
This will allow for a simplified setup in our performance tracking
Change-Id: I18087187e52cda1f617bc433e97b7b93ecabe03a
diff --git a/tools/golem.py b/tools/golem.py
new file mode 100755
index 0000000..cda9875
--- /dev/null
+++ b/tools/golem.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+# Utility methods to make running on our performance tracking system easier.
+import os
+import sys
+
+LINKED_THIRD_PARTY_DIRECTORIES = [
+ 'framework',
+ 'benchmarks',
+ 'gradle-plugin',
+ 'gradle',
+ 'android_jar',
+ 'proguardsettings',
+ 'gmscore',
+ 'youtube',
+ 'gmail',
+ 'r8',
+ 'openjdk',
+]
+
+# Path to our internally updated third party
+THIRD_PARTY_SOURCE = "/usr/local/google/home/golem/src/r8/third_party"
+
+def link_third_party():
+ assert os.path.exists('third_party')
+ for dir in LINKED_THIRD_PARTY_DIRECTORIES:
+ src = os.path.join(THIRD_PARTY_SOURCE, dir)
+ dest = os.path.join('third_party', dir)
+ if os.path.exists(dest):
+ raise Exception('Destination "{}" already exists, are you running with'
+ ' --golem locally'.format(dest))
+ print('Symlinking {} to {}'.format(src, dest))
+ os.symlink(src, dest)
+
+if __name__ == '__main__':
+ sys.exit(link_third_party())
diff --git a/tools/run_bootstrap_benchmark.py b/tools/run_bootstrap_benchmark.py
index bfc62e6..ad26959 100755
--- a/tools/run_bootstrap_benchmark.py
+++ b/tools/run_bootstrap_benchmark.py
@@ -3,9 +3,11 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
+import argparse
import os
import sys
+import golem
import minify_tool
import toolhelper
import utils
@@ -13,6 +15,16 @@
PINNED_R8_JAR = os.path.join(utils.REPO_ROOT, 'third_party/r8/r8.jar')
PINNED_PGR8_JAR = os.path.join(utils.REPO_ROOT, 'third_party/r8/r8-pg6.0.1.jar')
+def parse_arguments(argv):
+ parser = argparse.ArgumentParser(
+ description = 'Run r8 bootstrap benchmarks.')
+ parser.add_argument('--golem',
+ help = 'Link in third party dependencies.',
+ default = False,
+ action = 'store_true')
+ return parser.parse_args(argv)
+
+
def dex(input, output):
return_code = toolhelper.run(
'd8', [
@@ -28,6 +40,9 @@
sys.exit(return_code)
if __name__ == '__main__':
+ options = parse_arguments(sys.argv[1:])
+ if options.golem:
+ golem.link_third_party()
with utils.TempDir() as temp:
memory_file = os.path.join(temp, 'memory.dump')
r8_output = os.path.join(temp, 'r8.zip')
diff --git a/tools/run_kotlin_benchmarks.py b/tools/run_kotlin_benchmarks.py
index 7f13989..c3f5b94 100755
--- a/tools/run_kotlin_benchmarks.py
+++ b/tools/run_kotlin_benchmarks.py
@@ -5,6 +5,7 @@
# Script for running kotlin based benchmarks
+import golem
import optparse
import os
import subprocess
@@ -44,8 +45,8 @@
help='The benchmark to run',
default='rgx',
choices=['rgx', 'deltablue', 'sta', 'empty'])
- result.add_option('--no-build',
- help='Don\'t build r8',
+ result.add_option('--golem',
+ help='Don\'t build r8 and link in third_party deps',
default=False, action='store_true')
result.add_option('--use-device',
help='Run the benchmark on an attaced device',
@@ -84,6 +85,8 @@
def Main():
(options, args) = parse_options()
+ if options.golem:
+ golem.link_third_party()
temp = '/tmp/output'
dex_path = os.path.join(temp, "classes.jar")
proguard_conf = os.path.join(temp, 'proguard.conf')
@@ -97,7 +100,7 @@
'--min-api', str(options.api),
benchmark_jar
]
- toolhelper.run('r8', r8_args, build=not options.no_build)
+ toolhelper.run('r8', r8_args, build=not options.golem)
if options.use_device:
result = run_art_device(dex_path)
else:
diff --git a/tools/run_on_app.py b/tools/run_on_app.py
index 9e30644..cfd9b9f 100755
--- a/tools/run_on_app.py
+++ b/tools/run_on_app.py
@@ -12,6 +12,7 @@
import gmail_data
import gmscore_data
+import golem
import toolhelper
import utils
import youtube_data
@@ -38,6 +39,10 @@
help='',
default=False,
action='store_true')
+ result.add_option('--golem',
+ help='',
+ default=False,
+ action='store_true')
result.add_option('--no-libraries',
help='',
default=False,
@@ -104,6 +109,8 @@
utils.check_java_version()
app_provided_pg_conf = False;
(options, args) = ParseOptions(argv)
+ if options.golem:
+ golem.link_third_party()
outdir = options.out
data = None
if options.app == 'gmscore':
@@ -200,8 +207,9 @@
additional_pg_conf = GenerateAdditionalProguardConfiguration(
temp, os.path.abspath(pg_outdir))
args.extend(['--pg-conf', additional_pg_conf])
+ build = not options.no_build and not options.golem
exit_code = toolhelper.run(options.compiler, args,
- build=not options.no_build,
+ build=build,
debug=not options.no_debug,
profile=options.profile,
track_memory_file=options.track_memory_to_file)
diff --git a/tools/run_proguard_dx_on_app.py b/tools/run_proguard_dx_on_app.py
index 4624f26..e78d5d1 100755
--- a/tools/run_proguard_dx_on_app.py
+++ b/tools/run_proguard_dx_on_app.py
@@ -20,6 +20,7 @@
import gmail_data
import gmscore_data
+import golem
import proguard
import utils
import youtube_data
@@ -38,6 +39,10 @@
help = 'Use CompatDx (D8) instead of DX.',
default = False,
action = 'store_true')
+ parser.add_argument('--golem',
+ help = 'Link in third party dependencies.',
+ default = False,
+ action = 'store_true')
parser.add_argument('--print-runtimeraw',
metavar = 'BENCHMARKNAME',
help = 'Print the line \'<BENCHMARKNAME>(RunTimeRaw): <elapsed>' +
@@ -57,7 +62,8 @@
def Main(argv):
utils.check_java_version()
options = parse_arguments(argv)
-
+ if options.golem:
+ golem.link_third_party()
outdir = options.out
if options.app == 'gmscore':
diff --git a/tools/test_framework.py b/tools/test_framework.py
index be6c9f7..6bc2f90 100755
--- a/tools/test_framework.py
+++ b/tools/test_framework.py
@@ -20,6 +20,7 @@
from __future__ import print_function
from glob import glob
import argparse
+import golem
import os
import re
import subprocess
@@ -43,6 +44,10 @@
choices = ['dx', 'd8', 'd8-release'],
required = True,
help = 'Compiler tool to use.')
+ parser.add_argument('--golem',
+ help = 'Running on golem, link in third_party resources.',
+ default = False,
+ action = 'store_true')
parser.add_argument('--name',
required = True,
help = 'Results will be printed using the specified benchmark name (e.g.'
@@ -62,7 +67,8 @@
utils.check_java_version()
args = parse_arguments()
output_dir = args.output
-
+ if args.golem:
+ golem.link_third_party()
with utils.TempDir() as temp_dir:
if not output_dir:
diff --git a/tools/test_gradle_benchmarks.py b/tools/test_gradle_benchmarks.py
index 0c976a3..c451424 100755
--- a/tools/test_gradle_benchmarks.py
+++ b/tools/test_gradle_benchmarks.py
@@ -5,10 +5,11 @@
from __future__ import print_function
import argparse
+import gradle
+import golem
import os
import sys
import utils
-import gradle
from enum import Enum
BENCHMARKS_ROOT_DIR = os.path.join(utils.REPO_ROOT, 'third_party', 'benchmarks')
@@ -18,6 +19,9 @@
description='Run D8 or DX on gradle apps located in'
' third_party/benchmarks/.'
' Report Golem-compatible RunTimeRaw values.')
+ parser.add_argument('--golem',
+ help = 'Running on golem, link in third_party resources.',
+ default = False, action = 'store_true')
parser.add_argument('--skip_download',
help='Don\'t automatically pull down dependencies.',
default=False, action='store_true')
@@ -153,6 +157,8 @@
def Main():
args = parse_arguments()
+ if args.golem:
+ golem.link_third_party()
if args.tool == 'd8':
tool = Benchmark.Tools.D8
@@ -205,7 +211,7 @@
['clean']),
]
- if not args.skip_download:
+ if not args.skip_download and not args.golem:
EnsurePresence(os.path.join('third_party', 'benchmarks', 'android-sdk'),
'android SDK')
EnsurePresence(os.path.join('third_party', 'gradle-plugin'),