Skip to content
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

Enable the tail call interpreter on 3.14+ clang builds #524

Merged
merged 2 commits into from
Feb 12, 2025
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Feb 11, 2025

No description provided.

@charliermarsh
Copy link
Member

Coool

@@ -348,6 +348,12 @@ if [ "${PYBUILD_PLATFORM}" != "macos" ]; then
fi
fi

# On Python 3.14+, enable the tail calling interpreter which is more performant.
# https://docs.python.org/3.14/using/configure.html#cmdoption-with-tail-call-interp
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
Copy link

@Fidget-Spinner Fidget-Spinner Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the time being, you also need to check that the current toolchain is clang-19 or higher and the arch is aarch64/x86_64. GCC doesn't support this.

Btw, not sure why Aarch64-linux-gnu is failing. It's using gcc but I was under the impression that had clang support. That's a separate thing altogether though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use gcc when we cross-compile — #484 tracks switching to native runners so we can use clang and PGO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(there was some confusion about this in #484 (comment) so we'll see..)

@zanieb zanieb changed the title Enable the tail call interpreter on 3.14+ Enable the tail call interpreter on 3.14+ clang builds Feb 12, 2025
Copy link

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, to my untrained eye at least.

@Fidget-Spinner
Copy link

Fidget-Spinner commented Feb 12, 2025

If you want a quick and dirty test that it's doing something for performance. Try running alpha4 vs alpha5 on this short pystones benchmark script. I got a 25% speedup or so on my computer https://gist.github.com/Fidget-Spinner/e7bf204bf605680b0fc1540fe3777acf

Base automatically changed from zb/314a5 to main February 12, 2025 14:07
@zanieb zanieb added the ci:skip label Feb 12, 2025
@zanieb
Copy link
Member Author

zanieb commented Feb 12, 2025

CI passed on 1f3cccd — rebasing onto main

@zanieb
Copy link
Member Author

zanieb commented Feb 12, 2025

A quick bench of 2to3 on a not so quiet machine

a4.json
=======

Performance version: 1.11.0
Report on macOS-14.7.2-arm64-arm-64bit-Mach-O
Number of logical CPUs: 16
Start date: 2025-02-12 08:20:38.410341
End date: 2025-02-12 08:20:52.793913

a5.json
=======

Performance version: 1.11.0
Report on macOS-14.7.2-arm64-arm-64bit-Mach-O
Number of logical CPUs: 16
Start date: 2025-02-12 08:19:19.514312
End date: 2025-02-12 08:19:32.304519

### 2to3 ###
Mean +- std dev: 138 ms +- 5 ms -> 119 ms +- 2 ms: 1.15x faster
Significant (t=27.00)

And the pystones bench

❯ hyperfine "$(uv python find 3.14.0a4) ./pystones.py" "./python/install/bin/python ./pystones.py"
Benchmark 1: /Users/zb/.local/share/uv/python/cpython-3.14.0a4-macos-aarch64-none/bin/python3.14 ./pystones.py
  Time (mean ± σ):      73.0 ms ±   0.9 ms    [User: 69.9 ms, System: 2.4 ms]
  Range (min … max):    71.1 ms …  75.6 ms    40 runs
 
Benchmark 2: ./python/install/bin/python ./pystones.py
  Time (mean ± σ):      56.8 ms ±   1.0 ms    [User: 53.6 ms, System: 2.5 ms]
  Range (min … max):    55.5 ms …  60.8 ms    50 runs
 
Summary
  ./python/install/bin/python ./pystones.py ran
    1.28 ± 0.03 times faster than /Users/zb/.local/share/uv/python/cpython-3.14.0a4-macos-aarch64-none/bin/python3.14 ./pystones.py

@zanieb zanieb merged commit aa430e2 into main Feb 12, 2025
12 checks passed
@zanieb zanieb deleted the zb/tail-call branch February 12, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants