aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/agent/agent.cli6
-rw-r--r--bbot/agent/agent.cxx16
-rw-r--r--bbot/agent/machine.cxx13
-rw-r--r--bbot/agent/machine.hxx3
4 files changed, 28 insertions, 10 deletions
diff --git a/bbot/agent/agent.cli b/bbot/agent/agent.cli
index 1046685..0a9147c 100644
--- a/bbot/agent/agent.cli
+++ b/bbot/agent/agent.cli
@@ -60,7 +60,11 @@ namespace bbot
number (\cb{--cpu}) is boosted to the full number of available hardware
threads (or, to view it another way, the fourth priority level has 20
possible values, not 10, with the first 0-9 being without the boost while
- the last 10-19 being with the boost).
+ the last 10-19 being with the boost). Note that this boosting semantics
+ may not be accurate if the agent is executed with CPU affinity. Also note
+ that there is no corresponding RAM boosting and it's possible that in some
+ configurations the amount of RAM will be insufficient for the boosted CPU
+ count.
Note that the priority levels are hierarchical in a sense that within a
given higher level URLs can be further prioritized using the lower
diff --git a/bbot/agent/agent.cxx b/bbot/agent/agent.cxx
index 67cf57f..9aba216 100644
--- a/bbot/agent/agent.cxx
+++ b/bbot/agent/agent.cxx
@@ -23,6 +23,7 @@
#include <map>
#include <atomic>
#include <chrono>
+#include <thread> // thread::hardware_concurrency()
#include <random>
#include <iomanip> // setw()
#include <iostream>
@@ -1250,7 +1251,8 @@ perform_task (toolchain_lock tl, // Note: assumes ownership.
machine_lock& ml,
const dir_path& md,
const bootstrapped_machine_manifest& mm,
- const task_manifest& tm)
+ const task_manifest& tm,
+ optional<size_t> boost_cpus)
try
{
tracer trace ("perform_task", md.string ().c_str ());
@@ -1399,7 +1401,8 @@ try
mm.machine.mac,
ops.bridge (),
tftpd.port (),
- tm.interactive.has_value ()));
+ tm.interactive.has_value (),
+ boost_cpus));
auto mg (
make_exception_guard (
@@ -2525,8 +2528,15 @@ try
}
}
+ // Check if we need to boost the number of CPUs to the full hardware
+ // concurrency.
+ //
+ optional<size_t> bcpus;
+ if (prio >= 10000)
+ bcpus = std::thread::hardware_concurrency ();
+
pm->lock.perform_task (tl, prio);
- r = perform_task (move (tl), pm->lock, pm->path, pm->manifest, t);
+ r = perform_task (move (tl), pm->lock, pm->path, pm->manifest, t, bcpus);
}
catch (const interrupt&)
{
diff --git a/bbot/agent/machine.cxx b/bbot/agent/machine.cxx
index 8308989..16f0525 100644
--- a/bbot/agent/machine.cxx
+++ b/bbot/agent/machine.cxx
@@ -172,7 +172,8 @@ namespace bbot
const optional<string>& mac,
const string& br_iface,
uint16_t tftp_port,
- bool pub_vnc);
+ bool pub_vnc,
+ optional<size_t> boost_cpus = nullopt);
virtual bool
shutdown (size_t& seconds) override;
@@ -216,7 +217,8 @@ namespace bbot
const optional<string>& omac,
const string& br,
uint16_t port,
- bool pub_vnc)
+ bool pub_vnc,
+ optional<size_t> bcpus)
: machine (mm.mac ? *mm.mac : // Fixed mac from machine manifest.
omac ? *omac : // Generated mac from previous bootstrap.
generate_mac ()),
@@ -249,7 +251,7 @@ namespace bbot
// Note that for best results you may want to adjust (e.g., by over-
// committing) the number of CPUs to be power of 2.
//
- size_t cpus (ops.cpu ()), cores (cpus);
+ size_t cpus (bcpus ? *bcpus : ops.cpu ()), cores (cpus);
size_t sockets (cores >= 16 && cores % 4 == 0 ? 2 :
cores >= 64 && cores % 8 == 0 ? 4 : 1);
@@ -672,13 +674,14 @@ namespace bbot
const optional<string>& mac,
const string& br_iface,
uint16_t tftp_port,
- bool pub_vnc)
+ bool pub_vnc,
+ optional<size_t> bcpus)
{
switch (mm.type)
{
case machine_type::kvm:
return make_unique<kvm_machine> (
- md, mm, mac, br_iface, tftp_port, pub_vnc);
+ md, mm, mac, br_iface, tftp_port, pub_vnc, bcpus);
case machine_type::nspawn:
assert (false); //@@ TODO
diff --git a/bbot/agent/machine.hxx b/bbot/agent/machine.hxx
index adace1f..0bb74b9 100644
--- a/bbot/agent/machine.hxx
+++ b/bbot/agent/machine.hxx
@@ -84,7 +84,8 @@ namespace bbot
const optional<string>& mac,
const string& br_iface,
uint16_t tftp_port,
- bool pub_vnc);
+ bool pub_vnc,
+ optional<size_t> boost_cpus = nullopt);
// Return the machine's public or private VNC session endpoint in the
// '<ip>:<port>' form.