Reputation: 12605
I have some image processing to do that involves a lot of CPU crunching.
At the moment I have a ruby script that does the crunching, but it does so one image at a time. I'm aware I can use threads to make things sorta-kinda parallel, but in MRI, it seems that still isn't going to actually hit more than one processor(?)
So, at the moment I'm doing the rather clumsy:
system("ruby image_runner.rb 0 1 3 & ruby image_runner.rb 3 2 3 & ruby image_runner.rb 6 3 3")
It works, it's much faster than threads...but it's none too pretty.
So, is there a more elegant way to dispatch ruby processes to recruit as much CPU crunching power as possible?
Upvotes: 0
Views: 32
Reputation: 37409
try using fork
:
image_runner.rb
[[0,1,3], [3,2,3], [6,3,3]].each do |x, y, z|
Process.fork do
# ... do work for x, y, z
end
end
Upvotes: 1