Some coroutines are very likely to get cancelled a short time after they are launched, making the CancellationException stacktrace calculation into a large portion of the runtime.
Examples:
This calls for an API that allows not populating the stacktraces but instead using a CancellationException object created in advance.
Options:
- Cancel-site:
cancel already can accept custom CancellationException variants, and withTimeout* could also be parameterized to allow this.
- Throw-site:
suspendCancellableContinuation could react to a special CoroutineContextElement specifying that the cancellation exception of the suspended coroutine itself does not need to be instantiated.