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

job_queue: avoid hard-coding limit for long-running jobs #17

Merged
merged 1 commit into from
May 11, 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
4 changes: 3 additions & 1 deletion src/job_queue.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require_relative "queue_types"
require_relative "shared_state"

# A variation of `Thread::Queue` that allows us to prioritise certain types of jobs.
Expand All @@ -22,8 +23,9 @@ def pop
@mutex.synchronize do
loop do
running_long_build_count = SharedState.instance.running_jobs(@queue_type).count(&:long_build?)
long_build_slots = QueueTypes.slots(@queue_type) / 2

if running_long_build_count < 6 && !@queue[:long].empty?
if running_long_build_count < long_build_slots && !@queue[:long].empty?
break @queue[:long].shift
elsif !@queue[:default].empty?
break @queue[:default].shift
Expand Down