Wow! Thank you for the benchmark. I just reproduced it here with some changes to test different things but you’re right, in Ruby forking is way more expensive than creating new threads. I find this surprising because the OS calls in Linux are pretty cheap, as you can see in this benchmark:
http://www.bitsnbites.eu/benchmarking-os-primitives/
I’d love to see an explanation why it’s so much more expensive in Ruby.
Anyway, when part of the processing is CPU bound, you’ll find out that often, even with the higher cost of creating the process, processes will often lead to a better performance due to the GVL. In some cases you can use a pool of processes to distribute some tasks across many CPU cores. I did that when comparing the performance between an Elixir and Ruby based approach to Akita’s downloader here: