Timeline for Does it ever make sense to use more concurrent processes than processor cores?
Current License: CC BY-SA 4.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 2, 2020 at 5:37 | comment | added | Jörg W Mittag | The requirement is, of course, that the tasks are "large" compared to the context switch time. | |
| Sep 2, 2020 at 5:36 | comment | added | Jörg W Mittag | If a thread is starved because there are other apps using the CPU, it will simply have its tasks stolen, so having "too many" threads is not an issue. And you know that you will at least need as many threads as you have parallel execution engines (cores, hyper threads, whatever you want to call them), so finding a "near optimal" number of threads is not an issue. | |
| Sep 2, 2020 at 5:34 | comment | added | Jörg W Mittag | That's why work stealing schedulers are popular (e.g. Scala's parallel collections as well as both popular actor frameworks for Scala use it, Clojure's concurrency engine use it, …) You spawn as many threads as you have parallel cores, divide your task by the number of threads, but whenever a thread is waiting, it will throw the task back into the queue and pick the next one, and if there isn't a next one, it will "steal" one from a different thread. So, by separating out the notion of "concurrent things to do" (task) from "parallel executor" (thread), you approach a fairly good sweet spot. | |
| Sep 1, 2020 at 14:53 | history | answered | gnasher729 | CC BY-SA 4.0 |