I would like to run a large number of intensive processes in parallel, where I loop over different parameters with for loops. A number of answers to similar questions mention that running processes in parallel can be done with xargs, but none of them seem to mention if or how this can be done if the parameters change for each command.
As an example (pseudo code):
for paramA in 1 2 3
for paramB in 1 2 3
./intensiveCommand $paramA $paramB
end
end
I would like to parallellize intensiveCommand
Or is there an easier way then using xargs?
Parallel job execution helps systems scale in performance by making optimal use of hardware resources. If your system's CPUs and disk controllers are already heavily loaded, you need to lighten the system's load or increase the hardware resources before using parallel execution to improve performance.
You can take advantage of the cluster even better when running your jobs in parallel than in series. This way, you could execute much more tasks at once (simultaneously) and achieve a faster result. The image above depicts how a task is serially executed by a single processor.
GitLab provides a method to make clones of a job and run them in parallel for faster execution using the parallel: keyword. While parallel jobs may not help in reducing the consumption of CI minutes, they definitely help increase work productivity.
You can use GNU parallel. It has a --load
option avoid overloading the computer.
parallel --load 100% ./intensiveCommand ::: 1 2 3 ::: 1 2 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With