From 3e527b9df0d9eb7a42b3fa05745224f00fcb9e19 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Apr 2017 09:01:09 +0200 Subject: Don't commit all available RAM to VM --- bbot/machine.cxx | 18 ++++++++++++++++-- 1 file 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. // -- cgit v1.1