# coroutines


05/04/2017, 6:58 AM
The other difference in implementation details concern state spilling. Quasar spills stack to heap only when suspension does happen. Kotlin spills the stack to heap before every invocation of
suspend fun
(this is covered in the spec quite well) in anticipation of suspension, even if that invocation will decide not to suspend. So here is the full table of differences:
Copy code
spill on suspend        restore on resume
Quasar            LAZY                    EAGER
Kotlin            EAGER                   LAZY
You can interpret it in this way: Quasar is optimised for the code that rarely suspends, while Kotlin coroutines are optimised for the code that often suspends. This properly of Kotlin coroutines is not an accident, since they were originally optimised for an efficient implementation of
pair that should work almost as fast as a manual implementation of the
. However, we have a lot of room to tweak those performance trade-offs in future updates (even without breaking compatibility) as we get more data on how coroutines get actually used in the wild.
👍 12
stackoverflow 1


05/04/2017, 1:01 PM
elizarov: this definitely should go in the coroutines docs ☺️
👍 2