Skip to content

Commit ae8b243

Browse files
committed
muvm: remove RAM special case for 8GB machines
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]>
1 parent 2ba2dab commit ae8b243

1 file changed

Lines changed: 5 additions & 21 deletions

File tree

crates/muvm/src/bin/muvm.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,11 @@ fn main() -> Result<ExitCode> {
132132
let sysinfo = sysinfo().context("Failed to get system information")?;
133133
let ram_total_mib = (sysinfo.ram_total() / (1024 * 1024)) as u32;
134134

135-
let ram_mib = if let Some(ram_mib) = options.mem {
136-
ram_mib
137-
} else {
138-
// By default, set the microVM RAM to be 80% of the system's RAM.
139-
let guest_ram = (ram_total_mib as f64 * 0.8) as u32;
140-
// Ensure we leave 3072 MiB free for the host + VRAM to avoid
141-
// compromising the host's stability. This mainly applies to systems
142-
// with 8GB of RAM.
143-
let guest_ram = if ram_total_mib
144-
.checked_sub(guest_ram)
145-
.context("Failed to calculate the amount of free RAM")?
146-
< 3072
147-
{
148-
ram_total_mib
149-
.checked_sub(3072)
150-
.context("Systems with less than 3072 MiB of RAM are not supported")?
151-
} else {
152-
guest_ram
153-
};
154-
MiB::from(guest_ram)
155-
};
135+
// By default, set the microVM RAM to be 80% of the system's RAM.
136+
let ram_mib = options
137+
.mem
138+
.unwrap_or(MiB::from((ram_total_mib as f64 * 0.8) as u32));
139+
156140
// By default, HK sets the heap size to be half the size of the *guest* memory.
157141
// Since commit 167744dc it's also possible to override the heap size by setting
158142
// the HK_SYSMEM environment variable.

0 commit comments

Comments
 (0)