Skip to content

Commit

Permalink
queue-runner: switch to pseudorandom ordering of builds processing
Browse files Browse the repository at this point in the history
We don't rely on sequential / monotonic build IDs processing anymore, so
randomizing actually has the advantage of mixing builds for different
systems together, to avoid only one chunk of builds for a single system
getting processed while builders for other systems are starved.
  • Loading branch information
delroth authored and mweinelt committed Oct 19, 2024
1 parent a3fc251 commit 10282dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hydra-queue-runner/queue-monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool State::getQueuedBuilds(Connection & conn,
/* Grab the queued builds from the database, but don't process
them yet (since we don't want a long-running transaction). */
std::vector<BuildID> newIDs;
std::map<BuildID, Build::ptr> newBuildsByID;
std::unordered_map<BuildID, Build::ptr> newBuildsByID;
std::multimap<StorePath, BuildID> newBuildsByPath;

{
Expand All @@ -112,7 +112,7 @@ bool State::getQueuedBuilds(Connection & conn,
"jobsets.name as jobset, job, drvPath, maxsilent, timeout, timestamp, "
"globalPriority, priority from Builds "
"inner join jobsets on builds.jobset_id = jobsets.id "
"where finished = 0 order by globalPriority desc, builds.id");
"where finished = 0 order by globalPriority desc, random()");

for (auto const & row : res) {
auto builds_(builds.lock());
Expand Down

0 comments on commit 10282dc

Please sign in to comment.