6 ms·
Spinning up a new process is much more overhead than creating a thread. (You're going to execve, right?) Since you're usually reaching for threads when you woul
by saagarjha 7y ago
Spinning up a new process is much more overhead than creating a thread. (You're going to execve, right?) Since you're usually reaching for threads when you would like extra performance, in this case creating a new process and dealing with its issues (how do I synchronize execution? How do I share data?) can be quite prohibitive.
(I should also note that the tooling for debugging and analyzing multithreaded programs has gotten much better recently, and claiming that language designers are lying to you and pinning the blame on runtime bugs is somewhat bogus since such bugs are clearly way outside the realm of why you should not use something for almost all applications, and affect non-multithreaded programs as well.)
- moonchild 7y agoA lot of the time, you can set up your shared state ahead of time and then fork. Still likely more overhead than just creating a thread, but not as much as an exec. Ultimately, the question of how (and when) to parallelize is very domain- and problem-specific. Multithreading, multiprocessing, coroutines, and xargs -P will all be the right solution sometimes.
- deleted 7y ago[deleted]