PDA

View Full Version : Threads vs Forking


rob
June 1st, 2005, 08:53 PM
I was wondering if anyone had any experience in benchmarking Ruby threads vs. forking vs. inline execution, and if so, what conclusions did they find?

presidentbeef
June 16th, 2005, 04:48 PM
I haven't actually done any bookmarking or testing of Ruby threads vs. forking in Ruby, but I expect the difference would be the same as threads vs. forking generally.

The problem with threads in Ruby, though, is that they are implemented in user-space for portability, so you aren't able to take full advantage of, let's say, hyperthreaded processors (or multi-processor systems). So, using separate processes will get you more of a 'real' parallel program.

I think that, with Ruby, using threads should be done when it is conceptually easier/better to do so, but not for performance (unless each thread is doing some kind of asynchronous device i/o or something).
Depends on the situation, I guess. :)