python / python/cpython

JIT: Set the IP and check for invalidation in `POP_TOP` only if `Py_Dealloc` is called.

Đang mở
#152,106 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

3.16 interpreter-core performance topic-JIT type-feature
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ả

The optimizer removes many POP_TOPs, but quite a few remain.

The code for POP_TOP looks like this:

    inst(POP_TOP, (value --)) {
        PyStackRef_XCLOSE(value);
    }

which is fine for the interprete but in the JIT, as POP_TOP is marked as escaping, we need to set the IP before and check for invalidation afterwards.

What we could do, is have a version of POP_TOP that sets the IP and checks for invalidation only if Py_Dealloc is called, so we don't need to add SET_IP and CHECK_VALIDITY.

The new form of POP_TOP would look like this:

    op(_POP_TOP_SET_IP_CHECK_INVALID, (value --)) {
        if (do_decref_and_refcnt_is_zero(value)) {
            SET_IP()
            Py_Dealloc()
            CHECK_VALID();
        }
   }

_POP_TOP_SET_IP_CHECK_INVALID should be inserted in the same pass that we insert _SET_IP and _CHECK_VALIDITY as we know whether we need to insert those uops, and leave POP_TOP alone in those cases.

Overall, this should speed things up as it doesn't increase the overall code size, but it does execute less code in many cases.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Kiểm tra triển khai JIT của POP_TOP và pass chèn _SET_IP và _CHECK_VALIDITY. Truy vết do_decref_and_refcnt_is_zero cùng các đường dẫn SET_IP, Py_Dealloc và CHECK_VALID hiện có; hoàn tất nghĩa là dạng chuyên biệt chỉ được chèn ở nơi cần thiết, trong khi POP_TOP vẫn không thay đổi ở những nơi khác và hành vi invalidation được giữ nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, python
Lĩnh vực
compilers, performance
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.