From 75c6d73966dad2f871eb504678a4d4b9962bdd3b Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Wed, 24 Sep 2014 16:24:20 +0000 Subject: [PATCH] Use threads for parallelization * The parallelization runner almost immediately calls a fork and gets blocked on waitpid() releasing the GIL. * Threads have lower resource usage than processes * There is a chance mutant will get faster on smaller machines and might scale better on bigger. --- lib/mutant.rb | 2 +- lib/mutant/cli.rb | 4 ++-- lib/mutant/config.rb | 2 +- lib/mutant/reporter/cli/printer.rb | 2 +- lib/mutant/runner.rb | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/mutant.rb b/lib/mutant.rb index 267dfc1b..e9f12146 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -221,7 +221,7 @@ module Mutant isolation: Mutant::Isolation::Fork, reporter: Reporter::CLI.build($stdout), zombie: false, - processes: Mutant.ci? ? CI_DEFAULT_PROCESSOR_COUNT : Parallel.processor_count, + jobs: Mutant.ci? ? CI_DEFAULT_PROCESSOR_COUNT : Parallel.processor_count, expected_coverage: 100.0 ) end # Config diff --git a/lib/mutant/cli.rb b/lib/mutant/cli.rb index 1f7b64c7..3da12b44 100644 --- a/lib/mutant/cli.rb +++ b/lib/mutant/cli.rb @@ -112,8 +112,8 @@ module Mutant opts.on('-r', '--require NAME', 'Require file with NAME') do |name| add(:requires, name) end - opts.on('-j', '--jobs NUMBER', 'Number of kill processes. Defaults to number of processors.') do |number| - update(processes: Integer(number)) + opts.on('-j', '--jobs NUMBER', 'Number of kill jobs. Defaults to number of processors.') do |number| + update(jobs: Integer(number)) end end diff --git a/lib/mutant/config.rb b/lib/mutant/config.rb index 1e3cc2d8..4818082a 100644 --- a/lib/mutant/config.rb +++ b/lib/mutant/config.rb @@ -10,7 +10,7 @@ module Mutant :reporter, :isolation, :fail_fast, - :processes, + :jobs, :zombie, :expected_coverage ) diff --git a/lib/mutant/reporter/cli/printer.rb b/lib/mutant/reporter/cli/printer.rb index 31b3f7ba..ea47c2a8 100644 --- a/lib/mutant/reporter/cli/printer.rb +++ b/lib/mutant/reporter/cli/printer.rb @@ -177,7 +177,7 @@ module Mutant info 'Matcher: %s', object.matcher_config.inspect info 'Integration: %s', object.integration.name info 'Expect Coverage: %0.2f%%', object.expected_coverage.inspect - info 'Processes: %d', object.processes + info 'Jobs: %d', object.jobs info 'Includes: %s', object.includes.inspect info 'Requires: %s', object.requires.inspect self diff --git a/lib/mutant/runner.rb b/lib/mutant/runner.rb index 54f042ac..ccf04e51 100644 --- a/lib/mutant/runner.rb +++ b/lib/mutant/runner.rb @@ -46,9 +46,9 @@ module Mutant def run Parallel.map( @mutations, - in_processes: config.processes, - finish: method(:finish), - start: method(:start), + in_threads: config.jobs, + finish: method(:finish), + start: method(:start), &method(:run_mutation) ) end