python / python/cpython

perf_jit activated from a subinterpreter publishes JIT executors with the trampoline's unwind info

Đang mở
#157,247 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.

interpreter-core topic-JIT type-bug
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ả

Bug report

Bug description:

sys.activate_stack_trampoline() refuses to run while the JIT is active, but it only checks the current interpreter, and the perf state is process-wide. A subinterpreter can activate perf_jit while the main interpreter keeps its JIT.

import sys
from concurrent import interpreters

interpreters.create().exec("import sys; sys.activate_stack_trampoline('perf_jit')")

def hot(n):
    t = 0
    for i in range(n):
        t += i & 3
    return t

for _ in range(50):
    hot(100000)

With PYTHON_JIT=1 ./python buggy_stuff.py on a --enable-experimental-jit build, the resulting /tmp/jit-.dump holds the JIT's executors (records named py::jit:executor), and every one of them is tagged with the unwind information of the 8-byte perf trampoline. Executor frames look different, so perf produces wrong stacks for samples inside JIT code.

Found while working on https://github.com/python/cpython/pull/157246

CPython versions tested on:

CPython main branch, 3.16

Operating systems tested on:

Linux

Linked PRs
  • gh-157258
  • gh-157324

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

Bắt đầu với sys.activate_stack_trampoline(), tùy chọn perf_jit và cách tái hiện bằng subinterpreter trong issue; chạy nó trên một bản build Linux có JIT thử nghiệm với PYTHON_JIT=1 và kiểm tra /tmp/jit-.dump được tạo ra. Theo dõi cách các JIT executor nhận thông tin unwind, và coi issue là đã được giải quyết khi các executor frame không còn được gắn thẻ bằng unwind data của 8-byte perf trampoline.

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
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/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.