Skip to content

Commit 746ffc2

Browse files
hsbtclaude
andcommitted
Clarify build_jobs slot handling
Name the per-gem slot cap MAX_JOBS_PER_GEM with a comment explaining the limit, rename the local to acquired_jobs since it counts grabbed tokens rather than free ones, and rescue EOFError alongside IO::WaitReadable so a closed jobserver pipe falls back to a single job instead of raising. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3f67452 commit 746ffc2

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

bundler/lib/bundler/rubygems_gem_installer.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
module Bundler
66
class RubyGemsGemInstaller < Gem::Installer
7+
# Cap how many jobserver slots a single gem's `make` may grab so that one
8+
# gem with many recipes doesn't starve the others sharing the pool. Beyond
9+
# a handful of jobs the extra parallelism rarely pays off in practice.
10+
MAX_JOBS_PER_GEM = 3
11+
712
def check_executable_overwrite(filename)
813
# Bundler needs to install gems regardless of binstub overwriting
914
end
@@ -124,11 +129,11 @@ def generate_bin_script(filename, bindir)
124129
end
125130

126131
def build_jobs
127-
@jobserver_read_io&.read_nonblock(3, @jobserver_tokens)
128-
available_jobs = @jobserver_tokens.empty? ? nil : @jobserver_tokens.size
132+
@jobserver_read_io&.read_nonblock(MAX_JOBS_PER_GEM, @jobserver_tokens)
133+
acquired_jobs = @jobserver_tokens.empty? ? nil : @jobserver_tokens.size
129134

130-
available_jobs || Bundler.settings[:jobs] || super
131-
rescue IO::WaitReadable
135+
acquired_jobs || Bundler.settings[:jobs] || super
136+
rescue IO::WaitReadable, EOFError
132137
1
133138
end
134139

0 commit comments

Comments
 (0)