2 ms·
For computation-bound processes, having more than one thread per CPU just means you pay task-switching fees unnecessarily. In fact, "I'm just starting with Erl
by jerf 10y ago
For computation-bound processes, having more than one thread per CPU just means you pay task-switching fees unnecessarily.
In fact, "I'm just starting with Erlang/Haskell/Go and I wanted to play with parallelization so I took the first 100 million integers and spawned a thread to add each individual pair together in a distributed fashion and it's ten thousand times slower than just using a C loop, WTF?" is a very popular post on the relevant language forums. In that situation what happens is because the "payload" of each thread is a single machine-language instruction (give or take loading and saving to memory), all you see is the overhead of starting, stopping, and joining threads. (Or processes or greenlets or whatever.)
Key search is embarrassingly parallel, which is basically a term of art that means "it's so easy anything works".