-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Release reusability token when suspendCancellableCoroutineReusable's … #3634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…block throws an exception Otherwise, continuation instance is left in REUSABLE_CLAIMED state that asynchronous resumer awaits in an infinite spin-loop, potentially causing deadlock with 100% CPU consumption. Originally, the bug was reproduced on old (pre-#3020) implementation where this very pattern was encountered: it was possible to fail owner's invariant check right in the supplied 'block'. This is no longer the case, so the situation is emulated manually (but still is possible in production environments, e.g. when OOM is thrown). Also, suspendCancellableCoroutineReusable is removed from obsolete BroadcastChannel implementation. Fixes #3613
Also filed #3635 to eventually address the issue in a more systematic and graceful manner |
* Note that this implementation always invokes [suspendCancellableCoroutineReusable], | ||
* as we do not care about broadcasts performance -- they are already deprecated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Note that this implementation always invokes [suspendCancellableCoroutineReusable], | |
* as we do not care about broadcasts performance -- they are already deprecated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what did this comment mean? suspendCancellableCoroutineReusable
is a slower internal version of suspendCancellableCoroutine
that we use internally as a performance de-optimization, and now that BroadcastChannel
is deprecated, we're free to make it fast, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is just a miswording, asked Nikita to verify just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was "it doesn't have non-suspending fast-path"
Co-authored-by: Dmitry Khalanskiy <[email protected]>
…block throws an exception
Otherwise, continuation instance is left in REUSABLE_CLAIMED state that asynchronous resumer awaits in an infinite spin-loop, potentially causing deadlock with 100% CPU consumption. Originally, the bug was reproduced on old (pre-#3020) implementation where this very pattern was encountered: it was possible to fail owner's invariant check right in the supplied 'block'. This is no longer the case, so the situation is emulated manually (but still is possible in production environments, e.g. when OOM is thrown). Also, suspendCancellableCoroutineReusable is removed from obsolete BroadcastChannel implementation.
Fixes #3613