JIT x Free-Threading
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Feature or enhancement
Proposal:
This provides an alternative design to https://github.com/python/cpython/issues/133171. I have a branch where all tests (including FT) pass.
Part 1:
For the first and simplest part, we could add a watcher/callback to thread creation. When multiple threads are created, we simply invalidate the executor as _CHECK_VALIDITY fails.
This means single threaded code gets all the benefits of JIT in the future, while multi-threaded code will lose all the benefits. However, both can coexist at the same time in the same build. We will finally get JIT + FT in a limited form. Pending part 2.
Part 2:
If we detect multiple threads are running, we turn off the non-thread safe optimizations, and redo the trace with those optimizations off. If we detect only a single thread, we follow part 1 and run till we get invalidated. This allows single threaded code to run faster, while multi-threaded code will run a little slower. Note that all optimizations I've proposed for the JIT in the past 6 months and in the future are FT safe (in theory. whether they are implemented in practice is different).
Together, part 1 and part 2 get the best of both worlds: for single-threaded code, we get max performance, even recovering some of the perf single-threaded perf lost from FT. In part 2, we get max compatibility with multiple threads.
We need both parts to get the max perf out of the JIT on FT.
Follow-up after this:
- Lock/unlock removal in FT code.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
https://github.com/python/cpython/issues/133171
Linked PRs
- gh-141595
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách đọc cuộc thảo luận được liên kết trong issue 133171 và phần công việc liên quan trong PR 141595. Đề xuất này không nêu tên tệp hoặc test nào; để hoàn thành, cần thống nhất và triển khai cả hai phần JIT và free-threading, sau đó chạy toàn bộ test suite, bao gồm cả các test free-threading.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- compilers, performance
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100