【问题标题】:Rake equivalent of make -j (--jobs)耙相当于 make -j (--jobs)
【发布时间】:2015-01-28 15:51:24
【问题描述】:

make 命令允许 -j (--jobs) 选项记录如下:

-j [jobs], --jobs[=jobs]
     Specifies the number of jobs (commands) to run simultaneously.  If there is more than one -j  option,
     the  last  one  is effective.  If the -j option is given without an argument, make will not limit the
     number of jobs that can run simultaneously.

在当今甚至手机都有多个内核和/或处理器的时代,我希望我的构建系统能够处理多线程处理。

设置rake 的最佳方式是什么,这样我可以确保最多有 3 个任务始终在运行?

【问题讨论】:

    标签: ruby multithreading rake rakefile


    【解决方案1】:

    是的,rake 允许作业并行运行。要设置并行度,请使用-j 开关。来自rake --help

    -j, --jobs [NUMBER] Specifies the maximum number of tasks to execute in parallel. (default is number of CPU cores + 4)
    

    但是,作业本身必须写成多任务,而不是任务。所以不是像这样定义任务:

    namespace :mynamespace  do
      desc "description"
      task task_name: :environment do
        your_code
      end
    end
    

    使用多任务:

    namespace :mynamespace  do
      desc "description"
      multitask task_name: :environment do
        your_code
      end
    end
    

    【讨论】:

      【解决方案2】:

      有一篇关于rake MultiTask的博文,但是它支持-j参数作为-m进行并行化。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-05-29
        • 2020-01-20
        • 1970-01-01
        • 1970-01-01
        • 2010-11-17
        • 2017-03-17
        • 2010-12-06
        相关资源
        最近更新 更多