Let's say I have a motherboard with 4 CPUs.
Each of the CPUs has 8 cores/16 threads according to Intel.

Now, let's say I have some insane string manipulation task that will take days to finish.
Is there a way to calculate how many forks and threads would yield the best performance?
I'm not sure how many forks and threads I should launch. Plus, I'm not sure if starting threads would even benefit me?

I'm specifically interested in Ruby as I'm not sure how Ruby 2 Threads compare to e.g. C++ Threads.