In a project I ran into something that affected th...
# coroutines
a
In a project I ran into something that affected the performance. I implemented 2 methods for comparisons on speed.
without_actor
runs in about ~10ms for 100_000 messages
with_actor
runs in about ~4000ms for 100_000 messages Is this caused by some context switching what is happening internally, or related how locking is done internally?
b
there are multiple reasons, first of all your actor is launched on global scope which uses default dispatcher, that means your base thread is always sending message to second thread and awaits response from it. You can clearly see how it affects your performance by launching actor in Dispatchers.Unconfined (I see ~x4-x5 speedup for actor case). But it's still 10x times slower than
without_actor
.
without_actor
basically has no suspension points