Include *_data.py files in restart_if_new_version() check
Change-Id: I3a9ba8bc5c45e153e3258056010a7443d51e93d4
diff --git a/tools/chrome_data.py b/tools/chrome_data.py
index 7649257..0d4329d 100644
--- a/tools/chrome_data.py
+++ b/tools/chrome_data.py
@@ -278,3 +278,18 @@
},
},
}
+
+def GetLatestVersion():
+ return '200520-monochrome_public_minimal_apks'
+
+def GetName():
+ return 'chrome'
+
+def GetMemoryData(version):
+ assert version == '200520-monochrome_public_minimal_apks'
+ return {
+ 'find-xmx-min': 600,
+ 'find-xmx-max': 700,
+ 'find-xmx-range': 16,
+ 'oom-threshold': 625,
+ }
diff --git a/tools/internal_test.py b/tools/internal_test.py
index 2571efc..cc2ee93 100755
--- a/tools/internal_test.py
+++ b/tools/internal_test.py
@@ -38,6 +38,9 @@
import utils
import run_on_app
+import chrome_data
+import iosched_data
+import r8_data
import youtube_data
# How often the bot/tester should check state
@@ -57,54 +60,18 @@
EXITCODE = 'exitcode'
TIMED_OUT = 'timed_out'
-BENCHMARK_APPS = [
- {
- 'app': 'r8',
- 'version': 'cf',
- 'find-xmx-min': 128,
- 'find-xmx-max': 400,
- 'find-xmx-range': 16,
- 'oom-threshold': 247,
- },
- {
- 'app': 'chrome',
- 'version': '180917',
- 'find-xmx-min': 256,
- 'find-xmx-max': 450,
- 'find-xmx-range': 16,
- 'oom-threshold': 340,
- },
- {
- 'app': 'youtube',
- 'version': youtube_data.LATEST_VERSION,
- 'find-xmx-min': 2800,
- 'find-xmx-max': 3200,
- 'find-xmx-range': 64,
- 'oom-threshold': 3000,
- # TODO(b/143431825): Youtube can OOM randomly in memory configurations
- # that should work.
- 'skip-find-xmx-max': True,
- },
- {
- 'app': 'iosched',
- 'version': '2019',
- 'find-xmx-min': 128,
- 'find-xmx-max': 1024,
- 'find-xmx-range': 16,
- # TODO(b/183371778): Figure out why the need to bump this
- 'oom-threshold': 329,
- },
-]
+BENCHMARK_APPS = [chrome_data, iosched_data, r8_data, youtube_data]
-def find_min_xmx_command(record):
+def find_min_xmx_command(app_data):
+ record = app_data.GetMemoryData(app_data.GetLatestVersion())
assert record['find-xmx-min'] < record['find-xmx-max']
assert record['find-xmx-range'] < record['find-xmx-max'] - record['find-xmx-min']
return [
'tools/run_on_app.py',
'--compiler=r8',
'--compiler-build=lib',
- '--app=%s' % record['app'],
- '--version=%s' % record['version'],
+ '--app=%s' % app_data.GetName(),
+ '--version=%s' % app_data.GetLatestVersion(),
'--no-debug',
'--no-build',
'--find-min-xmx',
@@ -113,27 +80,29 @@
'--find-min-xmx-range-size=%s' % record['find-xmx-range'],
'--find-min-xmx-archive']
-def compile_with_memory_max_command(record):
+def compile_with_memory_max_command(app_data):
# TODO(b/152939233): Remove this special handling when fixed.
- factor = 1.25 if record['app'] == 'chrome' else 1.15
+ factor = 1.25 if app_data.GetName() == 'chrome' else 1.15
+ record = app_data.GetMemoryData(app_data.GetLatestVersion())
return [] if 'skip-find-xmx-max' in record else [
'tools/run_on_app.py',
'--compiler=r8',
'--compiler-build=lib',
- '--app=%s' % record['app'],
- '--version=%s' % record['version'],
+ '--app=%s' % app_data.GetName(),
+ '--version=%s' % app_data.GetLatestVersion(),
'--no-debug',
'--no-build',
'--max-memory=%s' % int(record['oom-threshold'] * factor)
]
-def compile_with_memory_min_command(record):
+def compile_with_memory_min_command(app_data):
+ record = app_data.GetMemoryData(app_data.GetLatestVersion())
return [
'tools/run_on_app.py',
'--compiler=r8',
'--compiler-build=lib',
- '--app=%s' % record['app'],
- '--version=%s' % record['version'],
+ '--app=%s' % app_data.GetName(),
+ '--version=%s' % app_data.GetLatestVersion(),
'--no-debug',
'--no-build',
'--expect-oom',
@@ -176,16 +145,23 @@
default=False, action='store_true')
return result.parse_args()
-def get_own_file_content():
+def get_file_contents():
+ contents = []
with open(sys.argv[0], 'r') as us:
- return us.read()
+ contents.append(us.read())
+ for app_data in BENCHMARK_APPS:
+ with open(app_data.__file__, 'r') as us:
+ contents.append(us.read())
+ return contents
-def restart_if_new_version(original_content):
- new_content = get_own_file_content()
- log('Lengths %s %s' % (len(original_content), len(new_content)))
+def restart_if_new_version(original_contents):
+ new_contents = get_file_contents()
+ log('Lengths %s %s' % (
+ [len(data) for data in original_contents],
+ [len(data) for data in new_contents]))
log('is main %s ' % utils.is_main())
# Restart if the script got updated.
- if new_content != original_content:
+ if new_contents != original_contents:
log('Restarting tools/internal_test.py, content changed')
os.execv(sys.argv[0], sys.argv)
@@ -313,7 +289,7 @@
def run_continuously():
# If this script changes, we will restart ourselves
- own_content = get_own_file_content()
+ own_content = get_file_contents()
while True:
restart_if_new_version(own_content)
print_magic_file_state()
diff --git a/tools/iosched_data.py b/tools/iosched_data.py
index 5aac7b0..edd0663 100644
--- a/tools/iosched_data.py
+++ b/tools/iosched_data.py
@@ -176,3 +176,19 @@
},
},
}
+
+def GetLatestVersion():
+ return '2019'
+
+def GetName():
+ return 'iosched'
+
+def GetMemoryData(version):
+ assert version == '2019'
+ return {
+ 'find-xmx-min': 128,
+ 'find-xmx-max': 1024,
+ 'find-xmx-range': 16,
+ # TODO(b/183371778): Figure out why the need to bump this.
+ 'oom-threshold': 329,
+ }
diff --git a/tools/r8_data.py b/tools/r8_data.py
index c4c509f..6818af3 100644
--- a/tools/r8_data.py
+++ b/tools/r8_data.py
@@ -8,7 +8,7 @@
ANDROID_L_API = '21'
VERSIONS = {
- 'cf': {
+ '1.2.11-dev': {
'deploy': {
'inputs': [utils.PINNED_R8_JAR],
'pgconf': [os.path.join(utils.REPO_ROOT, 'src', 'main', 'keep.txt')],
@@ -22,3 +22,18 @@
}
}
}
+
+def GetLatestVersion():
+ return '1.2.11-dev'
+
+def GetName():
+ return 'r8'
+
+def GetMemoryData(version):
+ assert version == '1.2.11-dev'
+ return {
+ 'find-xmx-min': 128,
+ 'find-xmx-max': 400,
+ 'find-xmx-range': 16,
+ 'oom-threshold': 247,
+ }
diff --git a/tools/youtube_data.py b/tools/youtube_data.py
index 827041a..64bc995 100644
--- a/tools/youtube_data.py
+++ b/tools/youtube_data.py
@@ -115,3 +115,21 @@
}
},
}
+
+def GetLatestVersion():
+ return LATEST_VERSION
+
+def GetName():
+ return 'youtube'
+
+def GetMemoryData(version):
+ assert version == '16.20'
+ return {
+ 'find-xmx-min': 2800,
+ 'find-xmx-max': 3200,
+ 'find-xmx-range': 64,
+ 'oom-threshold': 3000,
+ # TODO(b/143431825): Youtube can OOM randomly in memory configurations
+ # that should work.
+ 'skip-find-xmx-max': True,
+ }