is it possible to use DefaultDispatcher's pool as ...
# ktor
e
is it possible to use DefaultDispatcher's pool as netty worker pool to avoid context switches? Not sure if it's a big deal anyway, but still?
c
It is possible only in ktor for now and makes sense only if you are launching coroutines on the default dispatchers
all call handlers are running on netty's pool
however there are two dispatchers in netty and call handlers are always redispatches by default to guard against users who are running blocking code in handlers
To eliminate this context switch you can use option
shareWorkGroup
e
It is possible only in ktor for now
you mean CIO Engine?
c
No, I mean that you can't modify it as we use netty's thread pool for dispatching
e
as far as I understand,
shareWorkGroup
will still use
NettyWorkerPool
instead of
DefaultDispatcher
c
Yes, but there is no need to do this unless you launch something on the default dispatcher
e
I have plenty of switches to IO context and it would be nice to avoid switch to another thread
c
shareWorkGroup
= true should make everything work on the same thread pool. Netty does always pin execution to exact thread so there should be no context switch but redispatch may introduce a delay
e
ok, i got it. thanks!