I’ve just switched to Kotlin 1.3. Dropped GlobalScope here and there (yeah, yeah, I’ll refactor it later). Unfortunately, Default Dispatcher now creates tens of threads instead of 4 (# of CPU cores). CPU load has increased by about 200%, the extra time is spent in
Could I have done something wrong to exhibit this non-obvious behavior? I’ll probably have to switch to newFixedThreadContext dispatchers, although I’m actually pretty happy with the idea of using the default one for most tasks.
Edit: Might be caused by recent changes in Ktor.io.
Edit 2: Might be caused by the loss of control over HttpClient’s dispatcher (it uses DefaultDispatcher now).
Edit 3: I’ve replaced GlobalScope with MyGlobalScope in my code and replaced CIO-based HttpClient with Apache-based. Some DefaultDispatcher threads are gone. Performance has improved a lot, but those DefaultDispatcher threads, which seem to do nothing but park(), are still giving me a headache.