Don't check whether a plugin needs to be installed:#9328
Merged
colby-swandale merged 1 commit intoruby:masterfrom Feb 20, 2026
Merged
Don't check whether a plugin needs to be installed:#9328colby-swandale merged 1 commit intoruby:masterfrom
colby-swandale merged 1 commit intoruby:masterfrom
Conversation
- ### Problem When Bundler installs gems, it checks whether a gem plugin needs to be installed. This check (`Dir.glob`) is expensive and is hotspot when profiling Bundler. ### Details Bundler makes a check to see if a gemspec stub exists for the gem being installed. If a gemspec stub already exists and its version is the same as the gem being installed, then Bundler assumes that the gem plugin was already generated in the past and there is no need to generate it again. This check was added for performance purpose but it's counter productive and has the opposite effect. The vast majority of gems don't have a plugin and we are incurring the cost of doing a `Dir.glob` for *every* gems to account for the small percentage of gems that may have a plugin to install. So it's actually much faster to always reinstall plugins for the few gems that have ones, than to make a check for all gems. Another advantage with this change is that if someone accidentaly bust the `plugins` folder but don't bust the `specifications` one, then Bundler will correctly regenerate plugins (where as before it wouldn't). I tried running this patch on a Gemfile containing 400 gems and this patch shoves around a second. ### Solution Always install plugins, no matter if one of the same version already exist.
7f1a586 to
d8d21c7
Compare
colby-swandale
approved these changes
Feb 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When Bundler installs gems, it checks whether a gem plugin needs to be installed. This check (
Dir.glob) is expensive and is a hotspot when profiling Bundler.Details
Bundler makes a check to see if a gemspec stub exists for the gem being installed. If a gemspec stub already exists and its version is the same as the gem being installed, then Bundler assumes that the gem plugin was already generated in the past and there is no need to generate it again. This check was added for performance purpose but it's counter productive and has the opposite effect.
The vast majority of gems don't have a plugin and we are incurring the cost of doing a
Dir.globfor every gems to account for the small percentage of gems that may have a plugin to install.So it's actually faster to always reinstall plugins for the few gems that have ones, than to make a check for all gems.
Another advantage with this change is that if someone accidentaly bust the
pluginsfolder but don't bust thespecificationsone, then Bundler will correctly regenerate plugins (where as before it wouldn't).I tried running this patch on a Gemfile containing 400 gems and this patch shoves around a second.
Solution
Always install plugins, no matter if one of the same version already exist.
I felt like it wasn't need to add a test for this change, but let me know if you'd prefer having one.
Make sure the following tasks are checked