diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-05-15 09:54:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-05-15 09:54:02 +0200 |
commit | 91f15d09253e4ae369dafc1c11d4c72c7a93cb0c (patch) | |
tree | ab64f9f6b2c6e1b32af94499efbd3ba82a54dd36 | |
parent | 46ea50772238213fd1696b9d0094714c77faed9c (diff) |
Redo priority monitor mode detection to obtain priority range
-rw-r--r-- | bbot/agent/agent.cxx | 51 |
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; } |