Skip to content

[benchmark] Groundwork for Robust Measurements #30158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4dfb3c4
Revert "[NFC][Python: black] Reformatted the benchmark Python sources…
palimondo Mar 1, 2020
ac294f3
[benchmark] Fix parsing delta zeroed metadata
palimondo Jul 29, 2019
9f7e782
[benchmark] PerformanceTestResults merge samples
palimondo Aug 3, 2019
e3a639a
[benchmark] Don’t justify last column in reports
palimondo Sep 16, 2019
979aced
[benchmark] BenchmarkDriver min-samples & metadata
palimondo Jul 30, 2019
6ee22de
[benchmark] [Gardening] Fix assertEqual naming
palimondo Nov 13, 2019
ed5940e
[benchmark] Report ventiles for dubious results
palimondo Feb 19, 2020
ef2993a
[benchmark] Retire old num-iters in verbose format
palimondo Nov 13, 2019
05b2009
[benchmark] Add tests for all_samples
palimondo Nov 13, 2019
5342ab3
[benchmark] Refactor: store num_iters on PTS
palimondo Nov 13, 2019
15dcdaf
[benchmark] Refactor: remove class Sample
palimondo Nov 13, 2019
6f0eb7b
[benchmark] Refactor: simpler exclude_outliers
palimondo Nov 14, 2019
abacc9f
[benchmark] Refactor: remove redundant _runtimes
palimondo Feb 19, 2020
cafb644
[benchmark] More immutable PerformanceTestSamples
palimondo Nov 14, 2019
bbdcaf8
[benchmark] Fix crash in oversampled results
palimondo Nov 21, 2019
dd2d83d
[benchmark] Collate metadata when merging PTRs
palimondo Feb 27, 2020
7d25484
[benchmark] Keep merged independent run samples
palimondo Feb 27, 2020
3f93e31
[benchmark] Override all_samples on merged results
palimondo Feb 29, 2020
85260ca
[benchmark] Dubious indicator for changes only
palimondo Mar 1, 2020
08047e4
[benchmark] Python 3 Support
palimondo Mar 1, 2020
bf06df6
[Gardening] Refactored runtimes correction for SO
palimondo Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ filename =
./benchmark/scripts/Benchmark_Driver,
./benchmark/scripts/Benchmark_DTrace.in,
./benchmark/scripts/Benchmark_GuardMalloc.in,
./benchmark/scripts/Benchmark_QuickCheck.in,
./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in,
./benchmark/scripts/run_smoke_bench,

./docs/scripts/ns-html2rst,

./test/Driver/Inputs/fake-toolchain/clang++,
./test/Driver/Inputs/fake-toolchain/ld,

./utils/80+-check,
Expand All @@ -31,6 +30,7 @@ filename =
./utils/recursive-lipo,
./utils/round-trip-syntax-test,
./utils/rth,
./utils/run-remote,
./utils/run-test,
./utils/scale-test,
./utils/submit-benchmark-results,
Expand Down
73 changes: 31 additions & 42 deletions benchmark/scripts/Benchmark_DTrace.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,61 @@ import sys

DRIVER_LIBRARY_PATH = "@PATH_TO_DRIVER_LIBRARY@"
sys.path.append(DRIVER_LIBRARY_PATH)
DTRACE_PATH = os.path.join(DRIVER_LIBRARY_PATH, "swift_stats.d")
DTRACE_PATH = os.path.join(DRIVER_LIBRARY_PATH, 'swift_stats.d')

import perf_test_driver # noqa (E402 module level import not at top of file)

# Regexes for the XFAIL_LIST. Matches against '([Onone|O|Osize],TestName)'
XFAIL_LIST = []
XFAIL_LIST = [
]


class DTraceResult(perf_test_driver.Result):

def __init__(self, name, status, output, csv_output):
perf_test_driver.Result.__init__(self, name, status, output, XFAIL_LIST)
perf_test_driver.Result.__init__(
self, name, status, output, XFAIL_LIST)
self.csv_output = csv_output

def is_failure(self):
return not bool(self.status)

@classmethod
def data_headers(cls):
return ["Name", "Result", "Total RR Opts", "Total RR Opts/Iter"]
return [
'Name', 'Result', 'Total RR Opts', 'Total RR Opts/Iter']

@classmethod
def data_format(cls, max_test_len):
non_name_headers = DTraceResult.data_headers()[1:]
fmt = ("{:<%d}" % (max_test_len + 5)) + "".join(
["{:<%d}" % (len(h) + 2) for h in non_name_headers]
)
fmt = ('{:<%d}' % (max_test_len + 5)) + \
''.join(['{:<%d}' % (len(h) + 2) for h in non_name_headers])
return fmt

@classmethod
def print_data_header(cls, max_test_len, csv_output):
headers = cls.data_headers()
if csv_output:
print(",".join(headers))
print(','.join(headers))
return
print(cls.data_format(max_test_len).format(*headers))

def print_data(self, max_test_len):
result = [self.get_name(), self.get_result()] + map(str, self.output)
if self.csv_output:
print(",".join(result))
print(','.join(result))
return

print(DTraceResult.data_format(max_test_len).format(*result))


class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):

def __init__(self, binary, xfail_list, csv_output):
perf_test_driver.BenchmarkDriver.__init__(
self, binary, xfail_list, enable_parallel=True, opt_levels=["O"]
)
self, binary, xfail_list,
enable_parallel=True,
opt_levels=['O'])
self.csv_output = csv_output

def print_data_header(self, max_test_len):
Expand All @@ -78,37 +83,23 @@ class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):
return {}

def process_input(self, data):
test_name = "({}_{})".format(data["opt"], data["test_name"])
test_name = '({}_{})'.format(data['opt'], data['test_name'])
print("Running {}...".format(test_name))
sys.stdout.flush()

def get_results_with_iters(iters):
e = os.environ
e["SWIFT_DETERMINISTIC_HASHING"] = "1"
p = subprocess.Popen(
[
"sudo",
"dtrace",
"-s",
DTRACE_PATH,
"-c",
"%s %s %s %s"
% (
data["path"],
data["test_name"],
"--num-iters=%d" % iters,
"--num-samples=2",
),
],
stdout=subprocess.PIPE,
stderr=open("/dev/null", "w"),
env=e,
)
e['SWIFT_DETERMINISTIC_HASHING'] = '1'
p = subprocess.Popen([
'sudo', 'dtrace', '-s', DTRACE_PATH,
'-c', '%s %s %s %s' % (data['path'], data['test_name'],
'--num-iters=%d' % iters,
'--num-samples=2')
], stdout=subprocess.PIPE, stderr=open('/dev/null', 'w'), env=e)
results = [x for x in p.communicate()[0].split("\n") if len(x) > 0]
return [
x.split(",")[1] for x in results[results.index("DTRACE RESULTS") + 1 :]
]

x.split(',')[1] for x in
results[results.index('DTRACE RESULTS') + 1:]]
iter_2_results = get_results_with_iters(2)
iter_3_results = get_results_with_iters(3)
iter_5_results = get_results_with_iters(5)
Expand Down Expand Up @@ -145,18 +136,16 @@ SWIFT_BIN_DIR = os.path.dirname(os.path.abspath(__file__))
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"-filter",
'-filter',
type=str,
default=None,
help="Filter out any test that does not match the given regex",
)
help='Filter out any test that does not match the given regex')
parser.add_argument(
"--emit-csv",
'--emit-csv',
default=False,
action="store_true",
action='store_true',
help="Emit csv output",
dest="csv_output",
)
dest='csv_output')
return parser.parse_args()


Expand Down
Loading