lima icon indicating copy to clipboard operation
lima copied to clipboard

VM fails to start on M1 CPU when CPU cores set to more than the host has

Open bowlofeggs opened this issue 2 years ago • 7 comments

Description

Greetings,

I recently discovered why https://github.com/abiosoft/colima was taking so long to start on an M1, and recently refused to start at all. The symptom I had been observing was a seeming timeout. I would see lots of logs with Waiting for the essential requirement 1 of 3: "ssh" printed to the terminal, and then ultimately it would bail out saying that ssh never came up (I assume this is a timeout.)

It turned out that if you set the number of CPU cores that the guest uses to be higher than the number of cores the M1 has, you end up with devastating performance. I had assumed incorrectly that the M1 had SMT, and so I had set the guest to use 16 cores since the M1 I use has 8 physical cores (plus 2 low power cores).

I am unsure if it is slow because it starts to use the low power cores, or if it's just a bug in the hypervisor, or both.

I have a few suggestions as to how lima could help users like me who make such poor assumptions, and all of them involve detecting the number of threads supported by the physical hardware:

  • Log a warning if the user configured more cores than the hardware supports.
  • Exit with an error if the user configured more cores than the hardware supports.
  • Correct to min(num_cores_detected, num_cores_requested) and log a warning.

This is MacOS 13.4 with vz virtualization.

bowlofeggs avatar Jun 12 '23 21:06 bowlofeggs

Correct to min(num_cores_detected, num_cores_requested) and log a warning.

SGTM

AkihiroSuda avatar Jun 13 '23 04:06 AkihiroSuda

Hello, my friend @BajuMcBites and I are students at UT Austin and after taking a virtualization class, we wanted to contribute to this project. Could we be assigned this issue? Thanks.

NotPranav0 avatar Apr 03 '24 22:04 NotPranav0

Could we be assigned this issue?

I've assigned the issue to you; I couldn't add your friend; maybe they need to comment on the issue first? Anyways, it doesn't matter; just create a PR and we can discuss from there.

jandubois avatar Apr 04 '24 16:04 jandubois

Hello, I am @NotPranav0's partner. Thanks.

BajuMcBites avatar Apr 04 '24 19:04 BajuMcBites

Hello, I am @NotPranav0's partner.

Thanks, that seems to have enabled it. I've assigned you as well now.

jandubois avatar Apr 04 '24 19:04 jandubois

Hey, we've managed to figure out the issue. Can we just make a new branch and submit a PR?

NotPranav0 avatar Apr 15 '24 23:04 NotPranav0

Hey, we've managed to figure out the issue. Can we just make a new branch and submit a PR?

Yes, please, thanks

AkihiroSuda avatar Apr 16 '24 00:04 AkihiroSuda