Hacker News new | ask | show | jobs
by yafetn 971 days ago
Lest someone new to Kotlin only reads the title and decides to spawn bare threads all over the place, don’t. At first pass, it's not clear to me what the actual work the author is doing in his benchmark. Instead, I’d point to the excellent work of Marcin Moskala’s Kt.Academy[0] and other resources on the topic.

[0] https://kt.academy/article/cc-best-practices

1 comments

There aren’t numbers in your reference, just a set of recommendations. The author of the post tried to compare the performance overheads of using Coroutines over threads, that’s all.
The issue with OPs is that it's really a case where coroutines would have any advantage so it's kind of pointless.
What, you mean using threads doesn't automatically make your machine slow to a crawl because of le ""context switches""??

Heresy! But my async!

I agree OP could have been more elaborate, but the main takeaway is that goroutines still cost at least 50% that of normal threads (though this needs to be verified in normal servers as well, not just smartphones). With goroutines, though usually supported by runtime systems (e.g., in Go), applications are responsible to manage tasks (e.g., HTTP requests) in order to harvest goroutines benefits, whereas this is easier with threads.

Edited for clarification.