Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruby-3.3 Process.warmup #1413

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ jobs:
name: Base steps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check Whitespace
run: git diff --check -- HEAD~1
ruby-spec:
@@ -27,7 +27,7 @@ jobs:
- os: macos-latest
ruby: ruby-3.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
@@ -50,7 +50,7 @@ jobs:
- os: macos-latest
ruby: ruby-3.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
@@ -75,7 +75,7 @@ jobs:
- os: macos-latest
ruby: ruby-3.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
@@ -95,7 +95,7 @@ jobs:
ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
@@ -111,7 +111,7 @@ jobs:
ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
@@ -127,7 +127,7 @@ jobs:
ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
@@ -143,7 +143,7 @@ jobs:
ruby: [ruby-3.0, ruby-3.1.2, ruby-3.1, ruby-3.2, ruby-3.3]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
11 changes: 7 additions & 4 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# v0.11.28

* Fix CLI parsing issue where arguments given to `mutant environment` where silently ignored.
[#1416](https://github.com/mbj/mutant/pull/1416)
* [#1416](https://github.com/mbj/mutant/pull/1416)
Fix CLI parsing issue where arguments given to `mutant environment` where silently ignored.

* Change to report efficiency instead of overhead.
* [#1415](https://github.com/mbj/mutant/pull/1415)
Change to report efficiency instead of overhead.
Efficiency is defined by `killtime / runtime`.

[#1415](https://github.com/mbj/mutant/pull/1415)
* [#1413](https://github.com/mbj/mutant/pull/1413)

Add `Process.warmup` optimization for ruby-3.3+ which yields a noticable speed improvement.

# v0.11.27 2023-12-01

2 changes: 2 additions & 0 deletions lib/mutant/mutation/runner.rb
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ def self.call(env)
def self.run_mutation_analysis(env)
reporter = reporter(env)

env.world.process_warmup

env
.record(:analysis) { run_driver(reporter, async_driver(env)) }
.tap { |result| env.record(:report) { reporter.report(result) } }
4 changes: 4 additions & 0 deletions lib/mutant/world.rb
Original file line number Diff line number Diff line change
@@ -82,5 +82,9 @@ def deadline(allowed_time)
def record(name, &block)
recorder.record(name, &block)
end

def process_warmup
process.warmup if process.respond_to?(:warmup)
end
end # World
end # Mutant
14 changes: 13 additions & 1 deletion spec/unit/mutant/mutation/runner_spec.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
let(:emit_mutation_worker_process_start) { instance_double(Proc) }
let(:env_result) { instance_double(Mutant::Result::Env) }
let(:reporter) { instance_double(Mutant::Reporter, delay: delay) }
let(:world) { fake_world }
let(:world) { instance_double(Mutant::World) }
let(:timer) { instance_double(Mutant::Timer) }

let(:env) do
instance_double(
@@ -55,6 +56,7 @@
end

before do
allow(world).to receive_messages(timer: timer)
allow(world.timer).to receive_messages(now: 1.0)
end

@@ -70,6 +72,11 @@ def apply
selector: :start,
arguments: [env]
},
{
receiver: world,
selector: :process_warmup,
arguments: []
},
{
receiver: env,
selector: :record,
@@ -147,6 +154,11 @@ def apply
selector: :start,
arguments: [env]
},
{
receiver: world,
selector: :process_warmup,
arguments: []
},
{
receiver: env,
selector: :record,
39 changes: 39 additions & 0 deletions spec/unit/mutant/world_spec.rb
Original file line number Diff line number Diff line change
@@ -140,4 +140,43 @@ def apply
end
end
end

describe '#process_warmup' do
let(:process) { double(Process) }

subject { super().with(process: process) }

def apply
subject.process_warmup
end

before do
allow(process).to receive_messages(
respond_to?: respond_to?,
warmup: process
)
end

context 'when process supports warmup' do
let(:respond_to?) { true }

it 'performs warmup' do
apply

expect(process).to have_received(:respond_to?).with(:warmup).ordered
expect(process).to have_received(:warmup).ordered
end
end

context 'when process supports warmup' do
let(:respond_to?) { false }

it 'performs warmup' do
apply

expect(process).to have_received(:respond_to?).with(:warmup)
expect(process).to_not have_received(:warmup)
end
end
end
end