kotlinx.coroutines: Optimize `runBlocking` and `EventLoop` implementations
EventLoopBase implementation class should allocate both queue and delayed lazily, moreover, a queue shall not be allocated as long as there is at most one queued task (optimization that is similar to JobSupport)
DispatchedContinuation shall extend QueuedTask, so that common case of EventLoop usage does not involve creation of objects at all.
- Consider providing a reusable version of
EventLoop implementation, so that performance-sensitive code can create a single instance that is reused for multiple sequential invocations of runBlocking.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (12 by maintainers)
Commits related to this issue
No. Saving small object to
ThreadLocalis usually counter-productive. Access toThreadLocalis typically more expensive than allocation/collection of small objects. TheadLocal pooling is usually beneficial only for very large objects.