-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Introduce a priority queue #9389
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
Merged
+116
−4
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "bundler/installer/parallel_installer" | ||
| require "bundler/rubygems_gem_installer" | ||
| require "rubygems/remote_fetcher" | ||
| require "bundler" | ||
|
|
||
| RSpec.describe Bundler::ParallelInstaller do | ||
| describe "priority queue" do | ||
| before do | ||
| require "support/artifice/compact_index" | ||
|
|
||
| @previous_client = Gem::Request::ConnectionPools.client | ||
| Gem::Request::ConnectionPools.client = Gem::Net::HTTP | ||
| Gem::RemoteFetcher.fetcher.close_all | ||
|
|
||
| build_repo2 do | ||
| build_gem "gem_with_extension", &:add_c_extension | ||
| build_gem "gem_without_extension" | ||
| end | ||
|
|
||
| gemfile <<~G | ||
| source "https://gem.repo2" | ||
|
|
||
| gem "gem_with_extension" | ||
| gem "gem_without_extension" | ||
| G | ||
| lockfile <<~L | ||
| GEM | ||
| remote: https://gem.repo2/ | ||
| specs: | ||
| gem_with_extension (1.0) | ||
| gem_without_extension (1.0) | ||
|
|
||
| DEPENDENCIES | ||
| gem_with_extension | ||
| gem_without_extension | ||
| L | ||
|
|
||
| @old_ui = Bundler.ui | ||
| Bundler.ui = Bundler::UI::Silent.new | ||
| end | ||
|
|
||
| after do | ||
| Bundler.ui = @old_ui | ||
| Gem::Request::ConnectionPools.client = @previous_client | ||
| Artifice.deactivate | ||
| end | ||
|
|
||
| let(:definition) do | ||
| allow(Bundler).to receive(:root) { bundled_app } | ||
|
|
||
| definition = Bundler::Definition.build(bundled_app.join("Gemfile"), bundled_app.join("Gemfile.lock"), false) | ||
| definition.tap(&:setup_domain!) | ||
| end | ||
| let(:installer) { Bundler::Installer.new(bundled_app, definition) } | ||
|
|
||
| it "queues native extensions in priority" do | ||
| parallel_installer = Bundler::ParallelInstaller.new(installer, definition.specs, 2, false, true) | ||
| worker_pool = parallel_installer.send(:worker_pool) | ||
| expected = 6 # Enqueue to download bundler and the 2 gems. Enqueue to install Bundler and the 2 gems. | ||
|
|
||
| expect(worker_pool).to receive(:enq).exactly(expected).times.and_wrap_original do |original_enq, spec, opts| | ||
| unless opts.nil? # Enqueued for download, no priority | ||
| if spec.name == "gem_with_extension" | ||
| expect(opts).to eq({ priority: true }) | ||
| else | ||
| expect(opts).to eq({ priority: false }) | ||
| end | ||
| end | ||
|
|
||
| opts ||= {} | ||
| original_enq.call(spec, **opts) | ||
| end | ||
|
|
||
| parallel_installer.call | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since installed is defined above, I think we should use that here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
installedis a different state thatinstallable.installedmeans that the spec is fully installed and there is nothing else to do.installablemeans that the spec is downloaded and can be installed immediately (either because its a pure ruby gem, or because it's a native extension gem and its dependencies are installed)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh whoops I read it wrong. 🤦🏼♀️