Repository navigation
[Data] Avoid counting terminal waits as output backpressure - #67374
owenowenisme merged 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the end-of-stream terminal checks and output backpressure tracking in DataOpTask to use non-blocking, rate-limited checks and prevent terminal checks from being misclassified as backpressure. It also adds corresponding unit tests. The review feedback suggests initializing _next_terminal_check_s to None instead of 0.0 and updating the rate-limiting check to handle this, preventing potential issues on platforms where time.monotonic() might return negative values.
Signed-off-by: Yin-1022 <kv.huang931022@gmail.com>
9b2e18f to
7326d2d
Compare
Jadiouo
left a comment
There was a problem hiding this comment.
Verified against base ce4256e and head 7326d2d (Python 3.13, CPU only).
- The repro from #67312 gives
_total_output_backpressure_s= 10.0 on base and 0 with the PR. - The new tests:
test_terminal_wait_not_counted_as_output_backpressurefails on base (assert 10.0 == 0), the other two pass on both, and all three pass with the PR. The fulltest_streaming_executor.pypasses (57 passed). - With a patched clock: a pending block/meta pair after the stream is exhausted still counts, an interval closed by a positive budget is counted as before, and I saw no double counting.
The gemini comments about _next_terminal_check_s refer to the earlier commit 9b2e18f and don't apply to the current diff.
LGTM.
Signed-off-by: Yin-1022 <kv.huang931022@gmail.com>
Description
DataOpTaskcurrently starts output-backpressure accounting whenevermax_bytes_to_read == 0.However, a zero output-read budget does not always mean that the task still has unread output.
After the stream is exhausted and all block/metadata refs have been consumed, the task may only be waiting for terminal completion. In that state, the terminal-only wait should not contribute to
task_output_backpressure_s.This became more visible while reviewing #67180.
That change allows exhausted tasks to finalize even when the output-read budget is zero, but the existing backpressure accounting still starts before the terminal check.
As a result, the interval between stream exhaustion and terminal completion can still be counted as output backpressure.
In normal execution this interval is usually small, so this is primarily a metrics accounting correctness cleanup.
Changes
Before / After Comparison
Before:
After:
If the stream is already exhausted and no block or metadata refs remain pending:
Actual unread output continues to be accounted for, including the case where the generator stream is exhausted but a block/metadata pair has already been pulled and remains pending inside
DataOpTask.Related issues
Fixes #67312
Related to #67180.
#67180 fixes task finalization when the output-read budget is zero.
This change is independent and only adjusts the output-backpressure metric so that terminal-only waiting time is not included once no unread output remains.
Additional information
The regression behavior was verified before and after the change:
10.0seconds of output backpressure;0.The full
TestDataOpTasktest class passes with the change.The production change is intentionally small and does not modify task scheduling, output-read budgeting, or terminal-finalization behavior.