Skip to content

Commit 94825b1

Browse files
authored
Merge pull request #37708 from eeckstein/fix_benchmark_run
benchmarks: fix smoke test run by setting the dynamic library path
2 parents 16846db + abcae7b commit 94825b1

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

benchmark/scripts/Benchmark_Driver

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import glob
3131
import logging
3232
import math
3333
import os
34+
import platform
3435
import re
3536
import subprocess
3637
import sys
@@ -54,6 +55,16 @@ class BenchmarkDriver(object):
5455
Optional parameters are for injecting dependencies -- used for testing.
5556
"""
5657
self.args = args
58+
self.run_env = os.environ.copy()
59+
if hasattr(args, 'libdir') and args.libdir:
60+
# The benchmark binaries should pick up the built swift libraries
61+
# automatically, because their RPATH should point to ../lib/swift
62+
# But it does not harm to additionally set the dynamic library path,
63+
# e.g. as a workaround to rdar://78584073
64+
if platform.system() == "Darwin":
65+
self.run_env["DYLD_LIBRARY_PATH"] = args.libdir
66+
elif platform.system() == "Linux":
67+
self.run_env["LD_LIBRARY_PATH"] = args.libdir
5768
self._subprocess = _subprocess or subprocess
5869
self.all_tests = []
5970
self.test_number = {}
@@ -66,7 +77,8 @@ class BenchmarkDriver(object):
6677

6778
def _invoke(self, cmd):
6879
return self._subprocess.check_output(
69-
cmd, stderr=self._subprocess.STDOUT, universal_newlines=True
80+
cmd, stderr=self._subprocess.STDOUT, universal_newlines=True,
81+
env=self.run_env
7082
)
7183

7284
@property

benchmark/scripts/run_smoke_bench

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ VERBOSE = False
4848
class DriverArgs(object):
4949
"""Arguments for BenchmarkDriver."""
5050

51-
def __init__(self, tests, optimization="O", architecture=None):
51+
def __init__(self, benchmark_dir, architecture, platform, optimization="O"):
5252
"""Initialize with path to the build-dir and optimization level."""
5353
self.benchmarks = None
5454
self.filters = None
55-
self.tests = os.path.join(tests, "bin")
55+
self.tests = os.path.join(benchmark_dir, "bin")
5656
self.optimization = optimization
5757
self.architecture = architecture
58+
self.libdir = os.path.join(benchmark_dir, "lib", "swift", platform)
5859

5960

6061
def log(msg):
@@ -165,7 +166,8 @@ def test_opt_levels(args):
165166
args.num_samples,
166167
args.num_reruns,
167168
output_file,
168-
args.arch
169+
args.arch,
170+
args.platform
169171
):
170172
changes = True
171173

@@ -232,7 +234,7 @@ def merge(results, other_results):
232234

233235
def test_performance(
234236
opt_level, old_dir, new_dir, threshold, num_samples, num_reruns,
235-
output_file, arch
237+
output_file, arch, platform
236238
):
237239
"""Detect performance changes in benchmarks.
238240
@@ -242,7 +244,8 @@ def test_performance(
242244

243245
i, unchanged_length_count = 0, 0
244246
old, new = [
245-
BenchmarkDriver(DriverArgs(dir, optimization=opt_level, architecture=arch))
247+
BenchmarkDriver(DriverArgs(dir, architecture=arch, platform=platform,
248+
optimization=opt_level))
246249
for dir in [old_dir, new_dir]
247250
]
248251
results = [measure(driver, driver.tests, i) for driver in [old, new]]
@@ -382,8 +385,10 @@ performance team (@eeckstein).
382385

383386

384387
def check_added(args, output_file=None):
385-
old = BenchmarkDriver(DriverArgs(args.oldbuilddir[0], architecture=args.arch))
386-
new = BenchmarkDriver(DriverArgs(args.newbuilddir[0], architecture=args.arch))
388+
old = BenchmarkDriver(DriverArgs(args.oldbuilddir[0], architecture=args.arch,
389+
platform=args.platform))
390+
new = BenchmarkDriver(DriverArgs(args.newbuilddir[0], architecture=args.arch,
391+
platform=args.platform))
387392
added = set(new.tests).difference(set(old.tests))
388393
new.tests = list(added)
389394
doctor = BenchmarkDoctor(args, driver=new)

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def _check_output(
186186
stderr=None,
187187
shell=False,
188188
universal_newlines=False,
189+
env=None
189190
):
190191
return self.record_and_respond(args, stdin, stdout, stderr, shell)
191192

0 commit comments

Comments
 (0)