python / python/cpython

`test_profiling` sometimes times out under TSan

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

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

tests 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ả

We don't currently run test_profiling in the TSan CI, but the context is that I'm trying to get the entire test suite running under thread sanitizer (TSan).

Some of the tests in test_profiling fail to attach in time when run with thread sanitizer, because the sanitizer makes everything slower. This is especially the case when running tests in parallel with -j.

Here's a example:

ERROR: test_run_failed_script_live (test.test_profiling.test_sampling_profiler.test_live_collector_ui.TestLiveModeErrors.test_run_failed_script_live)
Test that running a failing script exits with clean error.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 279, in _run_with_sync
    _wait_for_ready_signal(sync_sock, process, _SYNC_TIMEOUT_SEC)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 223, in _wait_for_ready_signal
    raise socket.timeout("timed out")
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 1110, in _handle_live_run
    process = _run_with_sync(cmd, suppress_output=True)
  File "/home/sgross/tsan-cpython/Lib/profiling/sampling/cli.py", line 289, in _run_with_sync
    raise RuntimeError(
        "Process failed to signal readiness within timeout"
    )
RuntimeError: Process failed to signal readiness within timeout

I think the problem is that the the _SYNC_TIMEOUT_SEC of 5 seconds isn't enough in this case:

https://github.com/python/cpython/blob/4f9a8d075ee52b8f56aca14102c8bf9fd6f3c512/Lib/profiling/sampling/cli.py#L78

Here are some options to consider:

  1. Make _SYNC_TIMEOUT_SEC configurable via a command line option and specify a larger value for the tests (i.e., SHORT_TIMEOUT)
  2. Make _SYNC_TIMEOUT_SEC configurable via environment variable
  3. Skip these tests under TSan
  4. ???

cc @pablogsal

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 tại Lib/profiling/sampling/cli.py ở _SYNC_TIMEOUT_SEC và _wait_for_ready_signal, sau đó kiểm tra trường hợp test_profiling bị lỗi test_run_failed_script_live. Chạy các bài kiểm thử profiling dưới TSan, bao gồm cả việc thực thi song song với -j, và so sánh các quy ước kiểm thử hiện có cho hành vi dành riêng cho sanitizer. Hoàn tất khi các bài kiểm thử bị ảnh hưởng luôn hoàn thành đáng tin cậy dưới TSan mà không làm suy giảm độ bao phủ kiểm thử thông thường.

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, testing
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
38/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.