Skip to content

Commit 112421c

Browse files
authored
Merge pull request swiftlang#96 from graydon/misc-run_cperf-fixes
Misc run cperf fixes
2 parents 0866392 + f2f6c0b commit 112421c

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

run_cperf

+44-11
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ NEW_INSTANCE = 'new'
2929

3030

3131
def get_workspace_for_instance(instance, args):
32-
return common.private_workspace(
33-
os.path.join(args.swift_branch, instance))
32+
if instance == OLD_INSTANCE and args.old_workspace is not None:
33+
return args.old_workspace
34+
elif instance == NEW_INSTANCE and args.new_workspace is not None:
35+
return args.new_workspace
36+
else:
37+
return common.private_workspace(
38+
os.path.join(args.swift_branch, instance))
3439

3540

3641
def setup_workspace(instance, workspace, args):
@@ -84,6 +89,7 @@ def main():
8489
with open(ws_comment, 'w') as f:
8590
f.write("Compilation-performance test failed")
8691

92+
failures = []
8793
for instance in instances:
8894
workspace = get_workspace_for_instance(instance, args)
8995

@@ -95,9 +101,9 @@ def main():
95101
build_swift_toolchain(workspace, args)
96102

97103
if not args.skip_runner:
98-
execute_runner(instance, workspace, configs, args)
104+
failures += execute_runner(instance, workspace, configs, args)
99105

100-
regressions = analyze_results(configs, args)
106+
regressions = analyze_results(configs, failures, args)
101107

102108
# Crude hack to write output to workspace when in CI,
103109
# regardless of --output passed.
@@ -143,8 +149,12 @@ def get_sandbox_profile_flags():
143149
return sandbox_flags
144150

145151

146-
def get_swiftc_path(workspace):
147-
if platform.system() == 'Darwin':
152+
def get_swiftc_path(instance, workspace, args):
153+
if instance == OLD_INSTANCE and args.old_swiftc is not None:
154+
return args.old_swiftc
155+
elif instance == NEW_INSTANCE and args.new_swiftc is not None:
156+
return args.new_swiftc
157+
elif platform.system() == 'Darwin':
148158
swiftc_path = os.path.join(workspace, 'build/compat_macos/install/toolchain/usr/bin/swiftc')
149159
elif platform.system() == 'Linux':
150160
swiftc_path = os.path.join(workspace, 'build/compat_linux/install/usr/bin/swiftc')
@@ -245,7 +255,7 @@ def get_stats_dir(instance, variant):
245255

246256

247257
def get_actual_config_and_flags(config, stats):
248-
flags = ("-stats-output-dir '%s'" % stats)
258+
flags = ("-stats-output-dir " + stats)
249259
# Handle pseudo-configs
250260
if config == 'wmo-onone':
251261
flags += ' -wmo -Onone '
@@ -262,29 +272,41 @@ def get_variant(config, args):
262272

263273
def execute_runner(instance, workspace, configs, args):
264274
projects = get_projects(args.suite)
265-
swiftc_path = get_swiftc_path(workspace)
275+
swiftc_path = get_swiftc_path(instance, workspace, args)
276+
failures = []
266277
for config in configs:
267278
variant = get_variant(config, args)
268279
stats = get_stats_dir(instance, variant)
269280
if os.path.exists(stats):
270281
shutil.rmtree(stats)
271282
os.makedirs(stats)
272283
(config, flags) = get_actual_config_and_flags(config, stats)
284+
actions = 'action.startswith("BuildSwiftPackage")'
285+
if platform.system() == 'Darwin':
286+
# Darwin can handle xcodebuild as well
287+
actions = 'action.startswith("Build")'
273288
runner_command = [
274289
'./runner.py',
275290
'--swiftc', swiftc_path,
276291
'--projects', projects,
277292
'--build-config', config,
278293
'--swift-version', '3',
279-
'--include-actions', 'action.startswith("Build")',
294+
'--include-actions', actions,
280295
'--swift-branch', args.swift_branch,
281296
'--add-swift-flags', flags,
282297
]
283298
if args.sandbox:
284299
runner_command += get_sandbox_profile_flags()
285300
if args.verbose:
286301
runner_command += ["--verbose"]
287-
common.check_execute(runner_command, timeout=9999999)
302+
try:
303+
common.check_execute(runner_command, timeout=9999999)
304+
except common.ExecuteCommandFailure:
305+
fail_logs = [ re.sub('FAIL_.*_(\\w+).log', '\\1', n)
306+
for n in os.listdir(".")
307+
if re.match('FAIL.*.log', n)]
308+
failures += (fail_logs if len(fail_logs) != 0 else ["unknown"])
309+
return failures
288310

289311

290312
def get_table_name(reference, subset, variant):
@@ -328,7 +350,7 @@ def get_baseline_name(variant):
328350
'cperf-baselines', variant + '.csv')
329351

330352

331-
def analyze_results(configs, args):
353+
def analyze_results(configs, failures, args):
332354
# Make a separate random run_id for each comment, to uniquify links.
333355
run_id = hex(random.randint(1, 2**63))[2:]
334356
old_ws = get_workspace_for_instance(OLD_INSTANCE, args)
@@ -383,6 +405,9 @@ def analyze_results(configs, args):
383405
out = args.output
384406
regressions = any(x != 0 for x in returncodes)
385407
out.write("# Summary for %s %s\n\n" % (args.swift_branch, args.suite))
408+
if len(failures) != 0:
409+
out.write("**Unexpected test results, stats may be off for %s**\n\n" %
410+
", ".join(set(failures)))
386411
if regressions:
387412
out.write("**Regressions found (see below)**\n\n")
388413
else:
@@ -477,6 +502,14 @@ def parse_args():
477502
action='store_true')
478503
parser.add_argument('--setup-workspaces-for-pr',
479504
type=int, default=None)
505+
parser.add_argument('--old-workspace',
506+
type=str, default=None)
507+
parser.add_argument('--new-workspace',
508+
type=str, default=None)
509+
parser.add_argument('--old-swiftc',
510+
type=str, default=None)
511+
parser.add_argument('--new-swiftc',
512+
type=str, default=None)
480513
return parser.parse_args()
481514

482515

0 commit comments

Comments
 (0)