You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Chore](pipeline) some minor fix and refactor (#61768)
1. 调整了一些不必要的terminate调用
2. 修复set_thread_id处理的不对的问题,可能导致metric或者profile不对
3. 修复了_wake_by不是原子变量,debug string可能读的不对的问题
4. 把pipeline task的terminate方法改名为更直观的名字,避免与operator的terminate混淆
5. 一些注释更新
This pull request refactors the pipeline task termination logic to
improve thread safety and clarify responsibilities between dependency
unblocking and operator termination. The main change is replacing the
`terminate()` method of `PipelineTask` with a new method,
`unblock_all_dependencies()`, which is now responsible solely for
unblocking dependencies when a task is woken up early or canceled.
Operator termination remains the responsibility of the worker thread
within `execute()`, ensuring thread safety. This refactor also updates
related method calls and documentation for clarity.
**Refactoring of pipeline task termination and dependency management:**
* Replaced `PipelineTask::terminate()` with
`PipelineTask::unblock_all_dependencies()`, which now unblocks all
dependencies without terminating operators; updated all relevant call
sites and documentation to reflect this separation of concerns.
[[1]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL347-R347)
[[2]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL366-R367)
[[3]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL481-R496)
[[4]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL505-L507)
[[5]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL711-R714)
[[6]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL762-R768)
[[7]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fL877-R881)
[[8]](diffhunk://#diff-3643eb9cad1657c99d794887ca26a78d9641b1d1f5dde3c86444370b7ffc9548L260-R260)
[[9]](diffhunk://#diff-2aac108aa389c146aff5acf00160da6d60f736d9a941768b62cb594d8f4f2b39L128-R128)
[[10]](diffhunk://#diff-262afd1bf43b83333335fec0b00b65ab0b0241315fd3ceb98c5b3d568971052fL438-R438)
* Updated the comment and signature for `unblock_all_dependencies()` in
`pipeline_task.h` to clarify its purpose and thread-safety
considerations, emphasizing that operator termination must occur on the
worker thread.
**Thread safety improvements:**
* Changed `_wake_by` in `PipelineTask` from a plain `int` to
`std::atomic<int>` to ensure thread-safe updates when waking up tasks
early.
* Fixed the logic in `set_thread_id()` to only update `_thread_id` and
increment the counter when the thread ID actually changes.
0 commit comments