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
Coroutines debugger should keep weak references to running coroutines #2129
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elizarov
force-pushed
the
debugger-leak
branch
3 times, most recently
from
July 8, 2020 22:33
a752e35
to
43e6e23
Compare
It should not prevent garbage-collection of coroutines that were otherwise lost, which included the following practically-useful cases: * Synchronous coroutines (iterator/sequence). * Lazy coroutines that were not started. * Abandoned coroutines that suspend forever without strong references to them in GlobalScope. Two kinds of tests cover this functionality: * A test via FieldWalker ensures that debugger impl does not keep a strong reference. This tests works fast and provides good diagnostics if anything goes wrong, but it is fragile, as futures changes to debugger my introduce static references to running coroutines elsewhere. * A stress-test that ensures that no OOM indeed happens when you run a lot of such lost coroutines. Longer-running, more stable to code change, but fragile in a difference sense as it may accidentally start passing in the future if lots of memory get allocated for tests. Fixes #2117
…ying on hardcoded period Also, don't check ref queue on every put (not needed in practice)
qwwdfsad
requested changes
Jul 14, 2020
kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/jvm/src/debug/internal/DebugCoroutineInfoImpl.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/jvm/src/debug/internal/ConcurrentWeakMap.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/jvm/src/debug/internal/ConcurrentWeakMap.kt
Outdated
Show resolved
Hide resolved
qwwdfsad
reviewed
Jul 16, 2020
kotlinx-coroutines-core/jvm/src/debug/internal/DebugCoroutineInfoImpl.kt
Outdated
Show resolved
Hide resolved
qwwdfsad
approved these changes
Jul 16, 2020
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.
LGTM module proposed changes
kotlinx-coroutines-core/jvm/src/debug/internal/DebugCoroutineInfoImpl.kt
Show resolved
Hide resolved
recheej
pushed a commit
to recheej/kotlinx.coroutines
that referenced
this pull request
Dec 28, 2020
…Kotlin#2129) It should not prevent garbage-collection of coroutines that were otherwise lost, which included the following practically-useful cases: * Synchronous coroutines (iterator/sequence). * Lazy coroutines that were not started. * Abandoned coroutines that suspend forever without strong references to them in GlobalScope. Two kinds of tests cover this functionality: * A test via FieldWalker ensures that debugger impl does not keep a strong reference. This tests works fast and provides good diagnostics if anything goes wrong, but it is fragile, as futures changes to debugger my introduce static references to running coroutines elsewhere. * A stress-test that ensures that no OOM indeed happens when you run a lot of such lost coroutines. Longer-running, more stable to code change, but fragile in a difference sense as it may accidentally start passing in the future if lots of memory get allocated for tests. Fixes Kotlin#2117
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It should not prevent garbage-collection of coroutines that were otherwise lost, which included the following practically-useful cases:
Two kinds of tests cover this functionality:
Fixes #2117