Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Bisect forker prep refactorings #2503

Merged
merged 5 commits into from
Jan 21, 2018

Conversation

myronmarston
Copy link
Member

I've been working on a substantial performance improvement to --bisect that works by swapping out Bisect::Runner (now called Bisect::ShellRunner as of this PR) with a new runner that uses fork { } instead of shelling out so we can pay the cost of booting RSpec and loading any --require files one time, instead of paying it for each subset spec run.

The new Bisect::ForkRunner will be coming in a later PR. This PR just does a bunch of prepatory refactoring that is needed for the new runner.

It is not going to be needed for the ForkRunner, but it will have
its own lifecycle to manage, so `start { }` makes a convenient
interface for both.
Also, rename the bisect formatter to indicate it communicates over DRb.
Also, move it to `utilities` as the server will not always be loaded.
This is useful for when you want to initialize your formatter
with extra state. The simplest approach is for you to instantiate
the formatter yourself instead of depending on RSpec to do it and
trying to update the formatter with your desired state later.
Copy link
Member

@xaviershay xaviershay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'm not too worried about the CLI API change, just wanted to call it out explicitly to make sure we capture it in a changelog.

@@ -203,8 +203,8 @@ def built_in_formatter(key)
ProgressFormatter
when 'j', 'json'
JsonFormatter
when 'bisect'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a change to the CLI API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a change to a private part of the CLI API. --format bisect has never been listed in the --help and isn't usable as a standalone formatter. In fact, if you run rspec --format bisect, it crashes:

  rspec-core git:(master) bin/rspec --format bisect
/Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:823:in `parse_uri': can't parse uri:druby://localhost: (DRb::DRbBadURI)
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:889:in `uri_option'
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:785:in `block in uri_option'
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:783:in `each'
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:783:in `uri_option'
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:1067:in `initialize'
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:1047:in `new'
	from /Users/myron/.rubies/ruby-2.1.7/lib/ruby/2.1.0/drb/drb.rb:1047:in `new_with_uri'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/formatters/bisect_formatter.rb:19:in `initialize'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/formatters.rb:148:in `new'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/formatters.rb:148:in `add'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration.rb:877:in `add_formatter'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration_options.rb:117:in `block in load_formatters_into'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration_options.rb:117:in `each'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration_options.rb:117:in `load_formatters_into'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration_options.rb:23:in `configure'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:99:in `setup'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:86:in `run'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:71:in `run'
	from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:45:in `invoke'
	from /Users/myron/code/rspec-dev/repos/rspec-core/exe/rspec:4:in `<top (required)>'
	from bin/rspec:14:in `load'
	from bin/rspec:14:in `<main>'

This "formatter" only exists for when users use rspec --bisect. In that case, the main bisect process boots a DRb server, and then adds --format bisect to each shell command it generates to run a subset of the suite, so that the specific test run can communicate the results back to the main process.

Since it's a private API, I don't think we should call it out in the changelog.

@myronmarston myronmarston merged commit 8492f12 into master Jan 21, 2018
@myronmarston myronmarston deleted the myron/bisect-forker-prep-refactorings branch January 21, 2018 03:35
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
…actorings

Bisect forker prep refactorings
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants