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
Consider the following code that reads some bytes in a loop:
suspend fun foo() {
while (true) {
val bytes = readBytes(buf) // suspending
if (bytes < 0) break
}
}
where readBytes is written via suspendCancellableCoroutine. The problem is that each readBytes invocation allocates a new CancellableContinuationImpl object and some auxiliary ones to track parent's cancellation. This is unacceptable for high-performance IO code and a standard solution need to be provided for that. For 1.0 release we are looking for an experimental implementation of such an API that relies on new feature in 1.3 coroutines: ContinuationInterceptor.releaseInterceptedContinuation.
The text was updated successfully, but these errors were encountered:
…formance intrinsic which allows to reuse cancellation machinery and opens the way to garbage-free channels:
* Make AbstractContinuation reusable
* Add additional field to DispatchedContinuation to cache cancellable continuation
* Use suspendAtomicCancellableCoroutineReusable in channels (+15% of performance on ping-pong)
* Detect calls to tryResume and forbid cancellation reusing in order to make channels work with selects
* Fix benchmarks on 1.3
Fixes#534
Consider the following code that reads some bytes in a loop:
where
readBytes
is written viasuspendCancellableCoroutine
. The problem is that eachreadBytes
invocation allocates a newCancellableContinuationImpl
object and some auxiliary ones to track parent's cancellation. This is unacceptable for high-performance IO code and a standard solution need to be provided for that. For 1.0 release we are looking for an experimental implementation of such an API that relies on new feature in 1.3 coroutines:ContinuationInterceptor.releaseInterceptedContinuation
.The text was updated successfully, but these errors were encountered: