Skip to content
Merged
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
59 changes: 55 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,63 @@

## v2.0.0

Most of the work has moved from GitHub Actions `.yml` files to Python code in `workflow.py`.
In the future, this will allow supporting more workflow engines beyond just GitHub Actions.
### Moving more code to Python

**Migration note**: After running `python -m bench_runner install` to update your local files, but sure to add the new `workflow_bootstrap.py` file to your git repository.
Most of the code to orchestrate the benchmarks at a high level has moved from
GitHub Actions `.yml` files to Python code in `workflow.py`. In the future, this
will allow supporting more workflow engines beyond just GitHub Actions.

### New configuration
**Migration note**: After running `python -m bench_runner install` to update
your local files, be sure to add the new `workflow_bootstrap.py` file to your
git repository.

### Decoupling compiler configuration from tail-calling

Previously, bench_runner had a flag, `CLANG`, that both (a) built with clang 19
or later and (b) built the tail calling interpreter. This has been replaced with
a new flag `TAILCALL` that only sets the flags to build with the tail calling
interpreter. It is now up to the user to select a machine configured with a
compiler that supports the tail calling interpreter.

For machines with a clang-19 or later installed these example machine
configurations could be used in your `bench_runner.toml`. The exact details will
depend on your distribution and method of installing clang, etc.:

```toml
[runners.linux_clang]
os = "linux"
arch = "x86_64"
hostname = "pyperf"
github_runner_name = "linux-x86_64-linux"
include_in_all = false
[runners.linux_clang.env]
CC = "$(which clang-19)"
LLVM_AR = "$(which llvm-ar-19)"
LLVM_PROFDATA = "$(which llvm-profdata-19)"

[runners.darwin_clang19]
os = "darwin"
arch = "arm64"
hostname = "CPythons-Mac-mini.local"
github_runner_name = "darwin-arm64-darwin"
[runners.darwin_clang19.env]
PATH = "$(brew --prefix llvm)/bin:$PATH"
CC = "$(brew --prefix llvm)/bin/clang"
LDFLAGS = "-L$(brew --prefix llvm)/lib"
CFLAGS = "-L$(brew --prefix llvm)/include"

[runners.pythonperf1_clang]
os = "windows"
arch = "x86_64"
hostname = "WIN-5FKPU9U7KDT"
github_runner_name = "windows-x86_64-pythonperf1"
include_in_all = false
[runners.pythonperf1_clang.env]
BUILD_DEST = "PCBuild/amd64"
PYTHON_CONFIGURE_FLAGS = '`"/p:PlatformToolset=clangcl`" `"/p:LLVMInstallDir=C:\Program Files\LLVM`" `"/p:LLVMToolsVersion=19.1.6`"'
```

### Controlling number of cores used for builds

Runners have a new configuration `use_cores` to control the number of CPU cores
used to build CPython. By default, this will use all available cores, but some
Expand Down
2 changes: 1 addition & 1 deletion bench_runner/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Flag:
Flag("tier2", "PYTHON_UOPS", "tier 2 interpreter", "T2"),
Flag("jit", "JIT", "JIT", "JIT"),
Flag("nogil", "NOGIL", "free threading", "NOGIL"),
Flag("clang", "CLANG", "build with latest clang and tailcall", "CLANG"),
Flag("tailcall", "TAILCALL", "tail-calling interpreter", "TAILCALL"),
]


Expand Down
11 changes: 10 additions & 1 deletion bench_runner/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,16 @@ def get_comparison_value(ref, r):
cfg["runners"], cfg["names"], cfg["colors"], cfg["styles"], cfg["markers"]
):
runner_results = commits.get(runner, {})
base_results = runner_results.get("", {})
# For tailcall, we want to compare against the default compiler
# which is a different "machine"
if flag == "TAILCALL":
# It's ok if the removesuffix fails -- it's fine to compare with
# the same machine if the "default" equivalent isn't available.
base_results = commits.get(runner.removesuffix("_clang"), {}).get(
"", {}
)
else:
base_results = runner_results.get("", {})

line = []
for cpython_hash, r in runner_results.get(flag, {}).items():
Expand Down
27 changes: 5 additions & 22 deletions bench_runner/scripts/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,6 @@ def compile_unix(cpython: PathLike, flags: list[str], pgo: bool, pystats: bool)
cfg = config.get_config_for_current_runner()

env = os.environ.copy()
if "CLANG" in flags:
match util.get_simple_platform():
case "linux":
env["CC"] = util.safe_which("clang-19")
env["LLVM_AR"] = util.safe_which("llvm-ar-19")
env["LLVM_PROFDATA"] = util.safe_which("llvm-profdata-19")
case "macos":
llvm_prefix = util.get_brew_prefix("llvm")
env["PATH"] = f"{llvm_prefix}/bin:{env['PATH']}"
env["CC"] = f"{llvm_prefix}/bin/clang"
env["LDFLAGS"] = f"-L{llvm_prefix}/lib"
env["CFLAGS"] = f"-I{llvm_prefix}/include"

if util.get_simple_platform() == "macos":
openssl_prefix = util.get_brew_prefix("openssl@1.1")
Expand All @@ -165,7 +153,7 @@ def compile_unix(cpython: PathLike, flags: list[str], pgo: bool, pystats: bool)
args.append("--enable-experimental-jit=yes")
if "NOGIL" in flags:
args.append("--disable-gil")
if "CLANG" in flags:
if "TAILCALL" in flags:
args.append("--with-tail-call-interp")
args.append("--enable-option-checking=fatal")
if configure_flags := os.environ.get("PYTHON_CONFIGURE_FLAGS"):
Expand Down Expand Up @@ -199,15 +187,10 @@ def compile_windows(
args.append("--experimental-jit-interpreter")
if "NOGIL" in flags:
args.append("--disable-gil")
if "CLANG" in flags:
args.extend(
[
"--tail-call-interp",
'"/p:PlatformToolset=clangcl"',
'"/p:LLVMInstallDir=C:\\Program Files\\LLVM"',
'"/p:LLVMToolsVersion=19.1.6"',
]
)
if "TAILCALL" in flags:
args.append("--tail-call-interp")
if configure_flags := os.environ.get("PYTHON_CONFIGURE_FLAGS"):
args.extend(shlex.split(configure_flags))

with contextlib.chdir(cpython):
subprocess.check_call(
Expand Down
2 changes: 1 addition & 1 deletion bench_runner/templates/_weekly.src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
tier2: false
jit: false
nogil: false
clang: true
tailcall: true
secrets: inherit

pystats:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ def get_args(args, **kwargs):
"-f",
"nogil=false",
"-f",
"clang=false",
"tailcall=false",
]