Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .github/workflows/intel-library-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,26 @@ jobs:
apt-get install -y --no-install-recommends bzip2 gdb ;;
wasm)
apt-get install -y --no-install-recommends curl xz-utils perl util-linux ;;
wasm-selfbuild)
apt-get install -y --no-install-recommends curl xz-utils perl nodejs npm ;;
index-cpp|simdjson|internal) ;;
*) exit 2 ;;
esac
git config --global --add safe.directory /work/source
git config --global --add safe.directory /work/tools
make -C dev cppgm -j16
jobs=16
if [ "$SUITE" = wasm-selfbuild ]; then jobs=2; fi
python3 -u ../tools/scripts/intel_library_benchmarks.py run \
--suite "$SUITE" --source /work/source --jobs 16
--suite "$SUITE" --source /work/source --jobs "$jobs"
'
- name: Report
if: always()
env:
SUITE: ${{ inputs.suite }}
run: |
report="source/obj/$SUITE/details.md"
if [ "$SUITE" = wasm-selfbuild ]; then report="source/obj/$SUITE/summary.md"; fi
if [ -f "$report" ]; then cat "$report" >> "$GITHUB_STEP_SUMMARY"; fi
- name: Collect results and diagnostics
if: always()
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ on:
description: Intel runner label supplied by the temporary-runner helper
type: string
default: cppgm-intel
intel_suite:
description: Dedicated Intel measurement to run
type: choice
options: [wasm, wasm-selfbuild]
default: wasm

permissions:
contents: read

concurrency:
group: wasm-benchmarks-${{ github.ref }}-${{ inputs.platform || 'github' }}
group: wasm-benchmarks-${{ github.ref }}-${{ inputs.platform || 'github' }}-${{ inputs.intel_suite || 'wasm' }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -258,6 +263,6 @@ jobs:
contents: write
uses: ./.github/workflows/intel-library-benchmarks.yml
with:
suite: wasm
suite: ${{ inputs.intel_suite || 'wasm' }}
revision: ${{ inputs.revision || github.sha }}
runner_label: ${{ inputs.runner_label }}
12 changes: 11 additions & 1 deletion docs/performance/intel-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ python3 scripts/run_intel_benchmarks_once.py --plan \

Remove `--plan` to start. The suites run sequentially: public programs,
self-build/inception timing, index-cpp, simdjson scalar and SSE, Godot, Boost O3,
the internal C++ source subset, and Wasm O0/O3 kernels. Each suite gets a fresh temporary runner and Ubuntu 26.04 container. The
the internal C++ source subset, Wasm O0/O3 kernels, and the complete WASI compiler
self-build. Each suite gets a fresh temporary runner and Ubuntu 26.04 container. The
launcher waits for the suite and publication to pass before starting the next;
runner logs and measurements remain in the printed directory. Use `--suite NAME`
to refresh just one suite.

The WASI self-build is a separate suite (`--suite wasm-selfbuild`); kernel
measurements do not include it. It uses the same two workers, frozen inputs,
byte checks and paired timing blocks as the hosted comparison. Its results
populate the dedicated Intel row under `wasm-selfbuild`. To run it before merging
workflow changes, use `--ref BRANCH --revision COMPILER_COMMIT`; the WASI package,
source lists and recorded revision all come from that compiler checkout.
The launcher also supports older GitHub CLI versions that omit the dispatch URL,
identifying the completed job by its unique runner label and name.

The internal suite pins both archive checksums from before and after the
`cppgm-extended` to `cppgm` rename: only the archive's directory prefix changed.
It records the hash actually used, verifies every cohort source unit, and
Expand Down
24 changes: 13 additions & 11 deletions scripts/experimental/wasi_inception.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def next_word():
return "\n".join(lines) + "\n"


def source_sets(tools):
def source_sets(tools, repo_root=REPO):
"""Use the compiler's owning source lists, including each tool's entry point."""
makefile = "include dev/frontend_source_sets.mk\nlist:\n"
for name in tools:
makefile += "\t@printf '%s\\n' '" + name + "' $(FRONTEND_OBJ_BASENAMES_" + name + ") END\n"
lines = subprocess.check_output(["make", "-s", "-f", "-", "list"],
input=makefile.encode(), cwd=REPO).decode().splitlines()
input=makefile.encode(), cwd=repo_root).decode().splitlines()
result = {}
while lines:
name = lines.pop(0)
Expand All @@ -90,17 +90,18 @@ def source_sets(tools):
def prepare(args):
package = args.directory.resolve()
package.mkdir() # Never replace an existing experiment or its observations.
repo_root = getattr(args, 'repo_root', REPO).resolve(strict=True)
inputs = package / "inputs"
inputs.mkdir()
copy_tree(REPO / "dev/src", inputs / "dev/src")
copy_tree(repo_root / "dev/src", inputs / "dev/src")
tools = getattr(args, "reference_tools", ["cppgm"])
for name in tools:
shutil.copyfile(REPO / ("dev/" + name + ".cpp"), inputs / ("dev/" + name + ".cpp"))
shutil.copyfile(repo_root / ("dev/" + name + ".cpp"), inputs / ("dev/" + name + ".cpp"))
for name in ['LICENSE', 'NOTICE']:
shutil.copyfile(REPO / name, inputs / name)
shutil.copyfile(HERE / "wasi_host.h", inputs / "wasi_host.h")
shutil.copyfile(HERE / "wasi_stack.S", inputs / "wasi_stack.S")
tool_sources = source_sets(tools)
shutil.copyfile(repo_root / name, inputs / name)
shutil.copyfile(repo_root / "scripts/experimental/wasi_host.h", inputs / "wasi_host.h")
shutil.copyfile(repo_root / "scripts/experimental/wasi_stack.S", inputs / "wasi_stack.S")
tool_sources = source_sets(tools, repo_root)
x86_sources = list(tool_sources["cppgm"])
# These are supplied WASI command-host sources, shared by every exported
# tool. Native builds keep their owning frontend source sets unchanged.
Expand All @@ -109,7 +110,7 @@ def prepare(args):
sources.insert(-1, "dev/src/support/wasi_heap.cpp")
sources.insert(-1, "wasi_stack.S")
sources = tool_sources["cppgm"]
config = (REPO / "obj/generated/cppgm_builtin_host_config.h").read_text()
config = (repo_root / "obj/generated/cppgm_builtin_host_config.h").read_text()
paths = re.search(r"kStandardIncludePaths\[\] = \{(.*?)\};", config, re.S)
if paths is None:
raise RuntimeError("generated host configuration has no include path table")
Expand Down Expand Up @@ -184,9 +185,9 @@ def prepare(args):
for p in sorted((package / "shim").rglob("*")) if p.is_file()},
"runner_files": {name: digest((package / name).read_bytes()) for name in runners},
"sdk_version": (args.sdk / "VERSION").read_text(),
"revision": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=REPO).decode().strip(),
"revision": subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=repo_root).decode().strip(),
"tool_sources": tool_sources,
"dirty": bool(subprocess.check_output(["git", "status", "--porcelain"], cwd=REPO)),
"dirty": bool(subprocess.check_output(["git", "status", "--porcelain"], cwd=repo_root)),
"source_sha256": digest(json.dumps([(f['path'], f['sha256']) for f in files
if f['path'].startswith('dev/')]).encode())}
save(package / "manifest.json", manifest)
Expand Down Expand Up @@ -344,6 +345,7 @@ def main():
commands = parser.add_subparsers(dest="command", required=True)
pack = commands.add_parser("prepare")
pack.add_argument("--directory", required=True, type=Path)
pack.add_argument("--repo-root", type=Path, default=REPO)
pack.add_argument("--sdk", required=True, type=Path)
pack.add_argument("--compiler", type=Path, default=REPO / "dev/cppgm")
pack.add_argument("--shim", required=True, type=Path)
Expand Down
22 changes: 21 additions & 1 deletion scripts/intel_library_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
'boost': 'boost_benchmarks.py',
'internal': 'internal_cpp_benchmarks.py',
'wasm': 'wasm_benchmarks.pl',
'wasm-selfbuild': 'wasm_selfbuild_benchmarks.py',
}
DIRECTORY = Path(__file__).resolve().parent


def run_command(suite, source, jobs):
if suite == 'wasm-selfbuild':
return [sys.executable, str(DIRECTORY / SCRIPTS[suite]),
'--compiler', str(source / 'dev/cppgm'), '--repo-root', str(source),
'--output', str(source / 'obj' / suite), '--tools', str(source / 'obj/wasm-tools'),
'--shim', str(DIRECTORY / 'experimental/node_modules/@bjorn3/browser_wasi_shim'),
'--jobs', str(jobs)]
if suite == 'wasm':
return ['perl', str(DIRECTORY / SCRIPTS[suite]), '--compiler', str(source / 'dev/cppgm'),
'--repo-root', str(source), '--output', str(source / 'obj' / suite)]
Expand All @@ -31,6 +38,13 @@ def run_command(suite, source, jobs):

def run(args):
command = run_command(args.suite, args.source.resolve(strict=True), args.jobs)
if args.suite == 'wasm-selfbuild':
subprocess.run(['perl', str(DIRECTORY / 'install_wasm_tools.pl'), '--prefix',
str(args.source / 'obj/wasm-tools')], check=True)
subprocess.run(['npm', 'ci', '--ignore-scripts', '--prefix',
str(DIRECTORY / 'experimental')], check=True)
subprocess.run(command, check=True)
return
if args.suite == 'wasm':
tools = args.source / 'obj/wasm-tools'
subprocess.run(['perl', str(DIRECTORY / 'install_wasm_tools.pl'), '--prefix', str(tools),
Expand Down Expand Up @@ -61,7 +75,8 @@ def collect(source, target):
for path in source.rglob('*'):
relative = path.relative_to(source)
if ({'build', 'source'}.intersection(relative.parts) or not path.is_file()
or not (path.suffix in suffixes or path.suffix == '.stdin' or path.name in ('stdout', 'stderr')
or (relative.parts[:2] == ('package', 'inputs') and path.suffix != '.log')
or not (path.suffix in suffixes or path.suffix == '.stdin' or path.name in ('stdout', 'stderr', 'manifest.sha256')
or path.name.endswith('probe'))):
continue
destination = target / relative
Expand Down Expand Up @@ -93,6 +108,11 @@ def main():
elif args.command == 'collect':
collect(args.source, args.target)
else:
if args.suite == 'wasm-selfbuild':
subprocess.run([sys.executable, str(DIRECTORY / 'wasm_benchmark_results.py'), 'publish-selfbuild',
str(args.artifact), '--target', str(args.target), '--revision', args.revision,
'--run-url', args.run_url, '--platform', 'intel'], check=True)
return
if args.suite == 'wasm':
subprocess.run([sys.executable, str(DIRECTORY / 'wasm_benchmark_results.py'), 'publish',
str(args.artifact / 'O0'), str(args.artifact / 'O3'), '--target', str(args.target),
Expand Down
39 changes: 37 additions & 2 deletions scripts/run_intel_benchmarks_once.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Run trusted Intel benchmarks sequentially, with one temporary runner per job."""
import argparse
from datetime import datetime, timezone
import hashlib
import json
import os
Expand All @@ -12,6 +13,8 @@
import sys
import tarfile
import tempfile
import time
from urllib.parse import urlencode
import urllib.request

SUITES = {
Expand All @@ -23,6 +26,7 @@
'boost': 'boost.yml',
'internal': 'internal-cpp.yml',
'wasm': 'wasm.yml',
'wasm-selfbuild': 'wasm.yml',
}


Expand All @@ -48,9 +52,35 @@ def dispatch_command(args, revision, label):
'-f', f'runner_label={label}']
if args.course_quality and args.suite == 'public':
command += ['-f', 'course_quality=true']
if args.suite == 'wasm-selfbuild':
command += ['-f', 'intel_suite=wasm-selfbuild']
return command


def dispatched_run(repo, workflow, label, since, attempts=12):
"""Find this runner's job when older gh versions dispatch without a URL."""
query = urlencode(dict(event='workflow_dispatch', created='>=' + since, per_page=100))
for attempt in range(attempts):
matches = set()
page = 1
while True:
runs = github(f'repos/{repo}/actions/workflows/{workflow}/runs?{query}&page={page}')['workflow_runs']
for run in runs:
jobs = github(f'repos/{repo}/actions/runs/{run["id"]}/jobs?per_page=100')['jobs']
if any(label in job.get('labels', []) and job.get('runner_name') == label for job in jobs):
matches.add(str(run['id']))
if len(runs) < 100:
break
page += 1
if len(matches) > 1:
raise RuntimeError('multiple workflow runs used this supposedly unique runner')
if matches:
return matches.pop()
if attempt + 1 < attempts:
time.sleep(5)
raise RuntimeError('could not identify the dispatched run by its unique runner; check Actions')


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--repo', default='vishvananda/cppgm')
Expand All @@ -60,7 +90,7 @@ def main():
parser.add_argument('--listen', action='store_true', help='accept one manually queued job instead of dispatching')
parser.add_argument('--course-quality', action='store_true', help='also measure the optional course exercises')
parser.add_argument('--suite', choices=['all', *SUITES], default='all',
help='run all seven suites sequentially (default), or just one')
help='run all suites sequentially (default), or just one')
parser.add_argument('--plan', action='store_true', help='show the pinned campaign without registering runners or starting jobs')
args = parser.parse_args()
revision = github(f'repos/{args.repo}/commits/{args.revision}')['sha']
Expand Down Expand Up @@ -97,6 +127,7 @@ def main():
print(f'Runner files and logs: {directory}', flush=True)
registered = False
run_id = None
queued_at = None
try:
token = github('--method', 'POST', f'repos/{args.repo}/actions/runners/registration-token')['token']
with (directory / 'configure.log').open('wb') as log:
Expand All @@ -109,6 +140,7 @@ def main():
registered = True
if not args.listen:
# Queue the job for this runner's unique label, not any other runner.
queued_at = datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
output = subprocess.check_output(dispatch_command(args, revision, label), text=True)
print(output, end='', flush=True)
match = re.search(r'/actions/runs/(\d+)', output)
Expand All @@ -134,7 +166,10 @@ def main():
raise RuntimeError(f'runner exited {status}; see {directory / "runner.log"}')
if not args.listen:
if run_id is None:
raise RuntimeError('gh did not return the run URL; check Actions before starting another suite')
run_id = dispatched_run(args.repo, SUITES[args.suite], label, queued_at)
print(f'CI run: https://github.com/{args.repo}/actions/runs/{run_id}', flush=True)
(directory / 'run.json').write_text(json.dumps(dict(run_id=run_id, revision=revision,
workflow_ref=args.ref, runner_label=label), indent=2) + '\n')
# A healthy runner process does not imply a successful benchmark.
# Wait for validation and badge publication before the next suite.
subprocess.run(['gh', 'run', 'watch', run_id, '--repo', args.repo, '--exit-status'], check=True)
Expand Down
Loading
Loading