diff options
-rw-r--r-- | bbot/machine.cxx | 18 |
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. // |