Skip to content

Commit 8c8ff2d

Browse files
authored
Merge pull request #399 from faster-cpython/clang-separate
Separate clang from tail calling
2 parents 7f388c7 + fa56386 commit 8c8ff2d

File tree

6 files changed

+73
-30
lines changed

6 files changed

+73
-30
lines changed

CHANGELOG.md

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,63 @@
22

33
## v2.0.0
44

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

8-
**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.
7+
Most of the code to orchestrate the benchmarks at a high level has moved from
8+
GitHub Actions `.yml` files to Python code in `workflow.py`. In the future, this
9+
will allow supporting more workflow engines beyond just GitHub Actions.
910

10-
### New configuration
11+
**Migration note**: After running `python -m bench_runner install` to update
12+
your local files, be sure to add the new `workflow_bootstrap.py` file to your
13+
git repository.
14+
15+
### Decoupling compiler configuration from tail-calling
16+
17+
Previously, bench_runner had a flag, `CLANG`, that both (a) built with clang 19
18+
or later and (b) built the tail calling interpreter. This has been replaced with
19+
a new flag `TAILCALL` that only sets the flags to build with the tail calling
20+
interpreter. It is now up to the user to select a machine configured with a
21+
compiler that supports the tail calling interpreter.
22+
23+
For machines with a clang-19 or later installed these example machine
24+
configurations could be used in your `bench_runner.toml`. The exact details will
25+
depend on your distribution and method of installing clang, etc.:
26+
27+
```toml
28+
[runners.linux_clang]
29+
os = "linux"
30+
arch = "x86_64"
31+
hostname = "pyperf"
32+
github_runner_name = "linux-x86_64-linux"
33+
include_in_all = false
34+
[runners.linux_clang.env]
35+
CC = "$(which clang-19)"
36+
LLVM_AR = "$(which llvm-ar-19)"
37+
LLVM_PROFDATA = "$(which llvm-profdata-19)"
38+
39+
[runners.darwin_clang19]
40+
os = "darwin"
41+
arch = "arm64"
42+
hostname = "CPythons-Mac-mini.local"
43+
github_runner_name = "darwin-arm64-darwin"
44+
[runners.darwin_clang19.env]
45+
PATH = "$(brew --prefix llvm)/bin:$PATH"
46+
CC = "$(brew --prefix llvm)/bin/clang"
47+
LDFLAGS = "-L$(brew --prefix llvm)/lib"
48+
CFLAGS = "-L$(brew --prefix llvm)/include"
49+
50+
[runners.pythonperf1_clang]
51+
os = "windows"
52+
arch = "x86_64"
53+
hostname = "WIN-5FKPU9U7KDT"
54+
github_runner_name = "windows-x86_64-pythonperf1"
55+
include_in_all = false
56+
[runners.pythonperf1_clang.env]
57+
BUILD_DEST = "PCBuild/amd64"
58+
PYTHON_CONFIGURE_FLAGS = '`"/p:PlatformToolset=clangcl`" `"/p:LLVMInstallDir=C:\Program Files\LLVM`" `"/p:LLVMToolsVersion=19.1.6`"'
59+
```
60+
61+
### Controlling number of cores used for builds
1162

1263
Runners have a new configuration `use_cores` to control the number of CPU cores
1364
used to build CPython. By default, this will use all available cores, but some

bench_runner/flags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Flag:
1717
Flag("tier2", "PYTHON_UOPS", "tier 2 interpreter", "T2"),
1818
Flag("jit", "JIT", "JIT", "JIT"),
1919
Flag("nogil", "NOGIL", "free threading", "NOGIL"),
20-
Flag("clang", "CLANG", "build with latest clang and tailcall", "CLANG"),
20+
Flag("tailcall", "TAILCALL", "tail-calling interpreter", "TAILCALL"),
2121
]
2222

2323

bench_runner/plot.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,16 @@ def get_comparison_value(ref, r):
437437
cfg["runners"], cfg["names"], cfg["colors"], cfg["styles"], cfg["markers"]
438438
):
439439
runner_results = commits.get(runner, {})
440-
base_results = runner_results.get("", {})
440+
# For tailcall, we want to compare against the default compiler
441+
# which is a different "machine"
442+
if flag == "TAILCALL":
443+
# It's ok if the removesuffix fails -- it's fine to compare with
444+
# the same machine if the "default" equivalent isn't available.
445+
base_results = commits.get(runner.removesuffix("_clang"), {}).get(
446+
"", {}
447+
)
448+
else:
449+
base_results = runner_results.get("", {})
441450

442451
line = []
443452
for cpython_hash, r in runner_results.get(flag, {}).items():

bench_runner/scripts/workflow.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,6 @@ def compile_unix(cpython: PathLike, flags: list[str], pgo: bool, pystats: bool)
135135
cfg = config.get_config_for_current_runner()
136136

137137
env = os.environ.copy()
138-
if "CLANG" in flags:
139-
match util.get_simple_platform():
140-
case "linux":
141-
env["CC"] = util.safe_which("clang-19")
142-
env["LLVM_AR"] = util.safe_which("llvm-ar-19")
143-
env["LLVM_PROFDATA"] = util.safe_which("llvm-profdata-19")
144-
case "macos":
145-
llvm_prefix = util.get_brew_prefix("llvm")
146-
env["PATH"] = f"{llvm_prefix}/bin:{env['PATH']}"
147-
env["CC"] = f"{llvm_prefix}/bin/clang"
148-
env["LDFLAGS"] = f"-L{llvm_prefix}/lib"
149-
env["CFLAGS"] = f"-I{llvm_prefix}/include"
150138

151139
if util.get_simple_platform() == "macos":
152140
openssl_prefix = util.get_brew_prefix("[email protected]")
@@ -165,7 +153,7 @@ def compile_unix(cpython: PathLike, flags: list[str], pgo: bool, pystats: bool)
165153
args.append("--enable-experimental-jit=yes")
166154
if "NOGIL" in flags:
167155
args.append("--disable-gil")
168-
if "CLANG" in flags:
156+
if "TAILCALL" in flags:
169157
args.append("--with-tail-call-interp")
170158
args.append("--enable-option-checking=fatal")
171159
if configure_flags := os.environ.get("PYTHON_CONFIGURE_FLAGS"):
@@ -199,15 +187,10 @@ def compile_windows(
199187
args.append("--experimental-jit-interpreter")
200188
if "NOGIL" in flags:
201189
args.append("--disable-gil")
202-
if "CLANG" in flags:
203-
args.extend(
204-
[
205-
"--tail-call-interp",
206-
'"/p:PlatformToolset=clangcl"',
207-
'"/p:LLVMInstallDir=C:\\Program Files\\LLVM"',
208-
'"/p:LLVMToolsVersion=19.1.6"',
209-
]
210-
)
190+
if "TAILCALL" in flags:
191+
args.append("--tail-call-interp")
192+
if configure_flags := os.environ.get("PYTHON_CONFIGURE_FLAGS"):
193+
args.extend(shlex.split(configure_flags))
211194

212195
with contextlib.chdir(cpython):
213196
subprocess.check_call(

bench_runner/templates/_weekly.src.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
tier2: false
8080
jit: false
8181
nogil: false
82-
clang: true
82+
tailcall: true
8383
secrets: inherit
8484

8585
pystats:

tests/test_gh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ def get_args(args, **kwargs):
5959
"-f",
6060
"nogil=false",
6161
"-f",
62-
"clang=false",
62+
"tailcall=false",
6363
]

0 commit comments

Comments
 (0)