python / python/cpython

Add streaming to `profiling.sampling`

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

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

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

Feature or enhancement

Proposal:

Right now, profiling.sampling has roughly two modes: live with the TUI, and snapshot-at-the-end (except binary? but see the note below.) There's nothing that streams the data continously as it comes. This would be ideal for long-running headless profiling.

This one is less defined than #145411, so there are more open questions:

  • Should it stream raw or agreggate data? What should be the window?
  • What should be the format? Unfortunately, from what I checked the current binary format is not really well-suited for streaming, as it saves the dictionaries only on finalize.
  • What should be the transport layers for streaming?
  • What should be the types of messages?
  • What should be the configuration flags?
  • How the backpressure should be handled? Should it drop the oldest? All the oldest?

My hunch is:

  • support both raw and aggregate and assume that aggregate is just a different message type.
  • start with something simple as JSONL
  • I have mixed feelings about the transport layer. The stdout sounds great on paper but it's a mixed-use channel right now and there's a question around blocking by slower consumers. Maybe for debugging? Unix socket is good but not perfectly portable
  • as for backpressure, I would just drop the oldest by default, but only the raw, agg and heartbeat messages.

For starters:

  • --stream unix:/tmp/tachyon-stream.sock or --stream file:/tmp/tachyon-stream.sock (later: --stream tcp:127.0.0.1:1234)
  • --stream-types meta|str_def|frame_def|raw|agg:5s|loss|heartbeat|end|error (comma separated; note the agg:5s here; we it could be extended to heartbeat:1s etc. in the future)
  • --stream-format jsonl

Then, in the next phases we could think of --stream-drop-policy etc.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

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 bằng cách đọc phần triển khai profiling.sampling và thảo luận liên quan trong issue #145411. Xem xét các loại stream được đề xuất, định dạng JSONL, các transports và các câu hỏi về backpressure trước khi thu hẹp thiết kế. Công việc được xem là hoàn tất khi có phạm vi streaming đã được thống nhất và một cấu hình hỗ trợ profiling headless chạy trong thời gian dài.

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
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
Ít trao đổi
Độ rõ ràng
Cần làm rõ
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.