aboutsummaryrefslogtreecommitdiff
path: root/bbot/agent/agent.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bbot/agent/agent.cxx')
-rw-r--r--bbot/agent/agent.cxx51
1 files changed, 33 insertions, 18 deletions
diff --git a/bbot/agent/agent.cxx b/bbot/agent/agent.cxx
index 1647fcf..edd6422 100644
--- a/bbot/agent/agent.cxx
+++ b/bbot/agent/agent.cxx
@@ -2003,36 +2003,53 @@ try
toolchain_lock& tl (er.first);
bootstrapped_machines& ms (er.second);
- // Determine if we should operate in the priority monitor mode and, if so,
- // the lower bound on the priorities that we should consider.
+ // Determine the existing task priority range (using [0,0] if there are
+ // none) as well as whether we we should operate in the priority monitor
+ // mode.
//
- optional<uint64_t> prio_mon;
- if (inst_max != 0)
+ uint64_t prio_min (0);
+ uint64_t prio_max (0);
+ bool prio_mon (false);
{
- uint16_t busy (0); // Machines locked by other processes.
- optional<uint64_t> prio;
+ uint16_t busy (0); // Number of machines locked by other processes.
+ bool task (false); // There is a machine performaing a task.
for (const bootstrapped_machine& m: ms)
{
if (!m.lock.locked ())
{
++busy;
- if (m.lock.prio && (!prio || *m.lock.prio < *prio))
- prio = *m.lock.prio;
+
+ if (m.lock.prio) // Not bootstrapping/suspended.
+ {
+ task = true;
+
+ if (prio_min > *m.lock.prio)
+ prio_min = *m.lock.prio;
+
+ if (prio_max < *m.lock.prio)
+ prio_max = *m.lock.prio;
+ }
}
}
- assert (busy <= inst_max);
-
- if (busy == inst_max)
+ if (inst_max != 0)
{
- if (!prio) // All bootstrapping/suspended.
+ assert (busy <= inst_max);
+
+ if (busy == inst_max)
{
- sleep = rand_sleep ();
- continue;
- }
+ if (!task) // All bootstrapping/suspended.
+ {
+ sleep = rand_sleep ();
+ continue;
+ }
+
+ l1 ([&]{trace << "priority monitor, range [" << prio_min << ", "
+ << prio_max << "]";});
- prio_mon = *prio;
+ prio_mon = true;
+ }
}
}
@@ -2040,8 +2057,6 @@ try
//
if (prio_mon)
{
- l1 ([&]{trace << "priority monitor, lower bound " << *prio_mon;});
-
sleep = rand_sleep () / 2;
continue;
}