python / python/cpython

profiling: flamegraph export fails with RecursionError on a deeply recursive program

Đang mở
#156,545 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.

stdlib topic-profiling 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:

The sampling profiler's flamegraph export (profiling.sampling.stack_collector.FlamegraphCollector.export) builds the flamegraph tree with a recursive walk (convert_children) and then serializes it with json.dumps — both recurse to the depth of the deepest sampled stack. The remote unwinder captures up to MAX_FRAMES (1536) frames, but export runs at the default recursion limit (1000), so profiling a program that recurses deeper than ~1000 makes export() raise RecursionError and write no flamegraph. Both --flamegraph and --diff-flamegraph are affected (the diff collector inherits export).

Reachable when profiling a program that raised its own recursion limit and recurses deeply (recursive-descent parsers, tree/graph walkers, deep serializers).

CPython versions tested on:

CPython main

Operating systems tested on:

Linux, macOS

Linked PRs
  • gh-156546

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 trong profiling/sampling/stack_collector.py tại FlamegraphCollector.export và lượt duyệt convert_children của nó. Tái hiện bằng một chương trình đệ quy sâu có giới hạn đệ quy vượt quá độ sâu stack được thu thập, sử dụng cả --flamegraph và --diff-flamegraph. Được xem là hoàn tất khi cả hai đường dẫn export đều tạo ra một flamegraph mà không có RecursionError; xem lại PR được liên kết gh-156546 để biết công việc đang được thực hiệ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ệ
python
Lĩnh vực
observability, performance
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả 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.