aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-20 09:01:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-20 09:01:09 +0200
commit3e527b9df0d9eb7a42b3fa05745224f00fcb9e19 (patch)
tree24f9f90180ad59674d637a8b58cacf83b1732fbf
parentd7acd335af45cd6cc0a85ce7ad058c3ac703e8cf (diff)
Don't commit all available RAM to VM
-rw-r--r--bbot/machine.cxx18
1 files changed, 16 insertions, 2 deletions
diff --git a/bbot/machine.cxx b/bbot/machine.cxx
index cb835bd..db596cd 100644
--- a/bbot/machine.cxx
+++ b/bbot/machine.cxx
@@ -166,6 +166,20 @@ namespace bbot
//
// 2. echo system_powerdown | socat - UNIX-CONNECT:.../monitor
//
+
+ // We probably don't want to commit all the available RAM to the VM since
+ // some of it could be used on the host side for caching, etc. So the
+ // heuristics that we will use is 4G or 1G per CPU, whichever is greater
+ // and the rest divide equally between the host and the VM.
+ //
+ size_t cpu (ops.cpu ());
+ size_t ram ((cpu < 4 ? 4 : cpu) * 1024 * 1024); // Kb.
+
+ if (ram > ops.ram ())
+ ram = ops.ram ();
+ else
+ ram += (ops.ram () - ram) / 2;
+
proc = run_io_start (
trace,
fdnull (),
@@ -178,9 +192,9 @@ namespace bbot
//
// Machine.
//
- "-m", to_string (ops.ram () / 1024) + "M",
+ "-m", to_string (ram / 1024) + "M",
"-cpu", "host",
- "-smp", ops.cpu (),
+ "-smp", cpu,
//
// Network.
//