Skip to content

Commit

Permalink
muvm: remove RAM special case for 8GB machines
Browse files Browse the repository at this point in the history
Now that muvm is able to request the guest to decrease its file cache
and the root cause for the premature OOM has been indentified, let's
remove the check for 8GB machines that limited the microVM to be
smaller than 5GB, and just set it to be 80% of the host RAM, just as
we do with systems with other configurations.

In practice, this enables 8GB machines to run more games out of the
box (tested with multiple Steam games on a MacBook Air M1 with 8GB).

Signed-off-by: Sergio Lopez <[email protected]>
  • Loading branch information
slp committed Dec 9, 2024
1 parent 2ba2dab commit ae8b243
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions crates/muvm/src/bin/muvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,11 @@ fn main() -> Result<ExitCode> {
let sysinfo = sysinfo().context("Failed to get system information")?;
let ram_total_mib = (sysinfo.ram_total() / (1024 * 1024)) as u32;

let ram_mib = if let Some(ram_mib) = options.mem {
ram_mib
} else {
// By default, set the microVM RAM to be 80% of the system's RAM.
let guest_ram = (ram_total_mib as f64 * 0.8) as u32;
// Ensure we leave 3072 MiB free for the host + VRAM to avoid
// compromising the host's stability. This mainly applies to systems
// with 8GB of RAM.
let guest_ram = if ram_total_mib
.checked_sub(guest_ram)
.context("Failed to calculate the amount of free RAM")?
< 3072
{
ram_total_mib
.checked_sub(3072)
.context("Systems with less than 3072 MiB of RAM are not supported")?
} else {
guest_ram
};
MiB::from(guest_ram)
};
// By default, set the microVM RAM to be 80% of the system's RAM.
let ram_mib = options
.mem
.unwrap_or(MiB::from((ram_total_mib as f64 * 0.8) as u32));

// By default, HK sets the heap size to be half the size of the *guest* memory.
// Since commit 167744dc it's also possible to override the heap size by setting
// the HK_SYSMEM environment variable.
Expand Down

0 comments on commit ae8b243

Please sign in to comment.