Skip to content

Commit 3d8f8e0

Browse files
committed
[Compile perf] Use lit tmpdir in scale-test, rdar://29090287
1 parent 9875f3b commit 3d8f8e0

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

test/lit.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,9 @@ config.substitutions.append(('%utils', config.swift_utils))
976976
config.substitutions.append(('%line-directive', config.line_directive))
977977
config.substitutions.append(('%gyb', config.gyb))
978978
config.substitutions.append(('%rth', config.rth))
979-
config.substitutions.append(('%scale-test', config.scale_test))
980-
979+
config.substitutions.append(('%scale-test',
980+
'{} --swiftc-binary={} --tmpdir=%t'.format(
981+
config.scale_test, config.swiftc)))
981982
config.substitutions.append(('%target-sil-opt', config.target_sil_opt))
982983
config.substitutions.append(('%target-sil-extract', config.target_sil_extract))
983984
config.substitutions.append(

utils/scale-test

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# values.
1313
#
1414

15-
import gyb, os, os.path, subprocess
15+
import gyb, os, os.path, shutil, subprocess
1616

1717
def find_which(p):
1818
for d in os.environ["PATH"].split(os.pathsep):
@@ -38,20 +38,23 @@ def has_debuginfo(swiftc):
3838

3939

4040
def write_input_file(args, ast, d, n):
41-
ifile = os.path.join(d, "in%d.swift" % n)
42-
with open(ifile,'w+') as f:
41+
fname = "in%d.swift" % n
42+
pathname = os.path.join(d, fname)
43+
with open(pathname,'w+') as f:
4344
f.write(gyb.execute_template(ast, '', N=n))
44-
return ifile
45+
return fname
4546

4647

4748
def run_once_with_primary(args, ast, rng, primary_idx):
48-
import sys, shutil, tempfile, json
49+
import sys, tempfile, json
4950
r = {}
5051
try:
51-
d = tempfile.mkdtemp()
52+
if args.tmpdir != None and not os.path.exists(args.tmpdir):
53+
os.makedirs(args.tmpdir, 0700)
54+
d = tempfile.mkdtemp(dir=args.tmpdir)
5255
inputs = [write_input_file(args, ast, d, i) for i in rng]
5356
primary = inputs[primary_idx]
54-
ofile = os.path.join(d, "out.o")
57+
ofile = "out.o"
5558

5659
mode = "-c"
5760
if args.parse:
@@ -81,26 +84,26 @@ def run_once_with_primary(args, ast, rng, primary_idx):
8184
print "running: " + " ".join(command)
8285

8386
if args.dtrace:
84-
trace = os.path.join(d, "trace.txt")
87+
trace = "trace.txt"
8588
script = "pid$target:swiftc:*%s*:entry { @[probefunc] = count() }" % args.select
8689
subprocess.check_call(
8790
["sudo", "dtrace", "-q",
8891
"-o", trace,
8992
"-b", "256",
9093
"-n", script,
91-
"-c", " ".join(command)])
94+
"-c", " ".join(command)], cwd=d)
9295
r = {fields[0]: int(fields[1]) for fields in
93-
[line.split() for line in open(trace)]
96+
[line.split() for line in open(os.path.join(d, trace))]
9497
if len(fields) == 2}
9598
else:
9699
if args.debug:
97100
command = ["lldb", "--"] + command
98-
stats = os.path.join(d, "stats.json")
101+
stats = "stats.json"
99102
argv = command + ["-Xllvm", "-stats",
100103
"-Xllvm", "-stats-json",
101104
"-Xllvm", "-info-output-file=" + stats]
102-
subprocess.check_call(argv)
103-
with open(stats) as f:
105+
subprocess.check_call(argv, cwd=d)
106+
with open(os.path.join(d, stats)) as f:
104107
r = json.load(f)
105108
finally:
106109
shutil.rmtree(d)
@@ -241,6 +244,9 @@ def main():
241244
parser.add_argument(
242245
'--swiftc-binary',
243246
default="swiftc", help='swift binary to execute')
247+
parser.add_argument(
248+
'--tmpdir', type=str,
249+
default=None, help='directory to create tempfiles in')
244250
parser.add_argument(
245251
'--select',
246252
default="", help='substring of counters/symbols to restrict attention to')

validation-test/compiler_scale/scale_neighbouring_getset.gyb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// RUN: %scale-test --sum-multi --parse --begin 5 --end 16 --step 5 --select typeCheckAbstractFunctionBody %s
22
// REQUIRES: OS=macosx, tools-release
33

4-
// FIXME: this test has been failing in CI
5-
// REQUIRES: rdar29090287
6-
74
struct Struct${N} {
85
% if int(N) > 1:
96
var Field : Struct${int(N)-1}?

0 commit comments

Comments
 (0)