Document how to add a bytecode specialization
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- compilers, documentation
Hướng nghiên cứu
Sử dụng PR 116385 và đề cương gồm chín bước làm tài liệu nguồn. Trước tiên, hãy xem lại các thay đổi được tham chiếu và những tệp được nêu—Python/bytecodes.c, Include/internal/pycore_code.h, Python/specialize.c, Lib/opcode.py và Include/internal/pycore_magic_number.h—sau đó chọn vị trí phù hợp trong devguide hoặc tài liệu CPython. Công việc được xem là hoàn tất khi một người mới có thể làm theo workflow specialization và kiểm tra nó bằng make regen-all hoặc build.bat --regen.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
How to add a new bytecode specialization is knowledge only a few of us remember right now. We should document this somewhere (devguide or CPython, I don't mind). Hopefully a new contributor can pick this up!
There reference is this PR: https://github.com/python/cpython/pull/116385/files
Assuming you found an instruction that serves as a good specialization candidate. Let's use the example of CONTAINS_OP:
- Set the original
CONTAINS_OPto a uop by changing it fromCONTAINS_OPto_CONTAINS_OPinPython/bytecodes.c. The instruction definition should also change frominsttoop. - Add the uop that calls a specializing function. In this case
_SPECIALIZE_CONTAINS_OP. - The original
CONTAINS_OPis now a new macro consisting of_SPECIALIZE_CONTAINS_OP + _CONTAINS_OP. - Define the cache structure in
Include/internal/pycore_code.h. At the very least, a 16-bit counter is needed. - Write the specializing function itself in
Python/specialize.c. Refer to any other function in that file for the format. - Remember to update operation stats by calling
add_stat_dictinPython/specialize.c. - Add the cache layout in
Lib/opcode.pyso that Python'sdismodule will know how to represent it properly. - Bump magic number in
Include/internal/pycore_magic_number.h. - Run
make regen-allon *nix orbuild.bat --regenon PC.
- Ngôn ngữ chính
- Python
- Star
- 2.1k
- Fork
- 1k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 12
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.
Issue khác của python/devguide
-
type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
topic-building python type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
needs: decision topic-test type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
topic-dev process type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Tất cả issue của python/devguide
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·