Skip to content

Conversation

@zhiqiu
Copy link
Contributor

@zhiqiu zhiqiu commented Apr 8, 2022

PR types

Bug fixes

PR changes

Others

Describe

fix bug that no thread is waked up when adding task to threadpool

For better performance, when AddTask is called, if there are still active thread (blocked_ != num_threads) in threadpool, notify is not called.

In very rare cases, the last active thread of a threadpool is running in WaitForWork, and in that case, the thread that calling AddTask may read the blocked_ before its blocked_++, thus blocked_ != num_threads and do not call notify. While, the last active thread is going to wait state, which result in the added task is not executed. And the whole program hangs.

For example, in the following figure, the task added to pool 0 (host pool) is not executed, and the program hangs because the deps of op 5 can not be reduced to 1.

image

@paddle-bot-old
Copy link

paddle-bot-old bot commented Apr 8, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See [Paddle CI Manual(https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/dev_guides/git_guides/paddle_ci_manual_cn.html) for details.

liutiexing
liutiexing previously approved these changes Apr 8, 2022
@zhiqiu zhiqiu merged commit f581f5b into PaddlePaddle:develop Apr 9, 2022
zhiqiu added a commit to zhiqiu/Paddle that referenced this pull request Apr 9, 2022
…eadpool (PaddlePaddle#41567)

* fix bug that no thread is waked up when adding task to threadpool

* fix typo
douch pushed a commit to douch/Paddle that referenced this pull request Apr 10, 2022
…eadpool (PaddlePaddle#41567)

* fix bug that no thread is waked up when adding task to threadpool

* fix typo
phlrain pushed a commit that referenced this pull request Apr 11, 2022
…eadpool (#41567) (#41575)

* fix bug that no thread is waked up when adding task to threadpool

* fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants