sickcodes / Docker-OSX

Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
https://hub.docker.com/r/sickcodes/docker-osx
GNU General Public License v3.0
36.21k stars 1.79k forks source link

Recommendations on performance tuning #20

Open anh-collab opened 4 years ago

anh-collab commented 4 years ago

Thanks for this project! This is extremely awesome and it allows many people like me who cannot Hackintosh to enjoy the benefits of MacOS.

However, I do want to explore more on the performance potential of this setup. I am running a Docker in Ubuntu 20.04 DDE and experiencing some lags. While it's understandable that VMs would always have a performance penalty, is there anything we could do to optimize the performance of this?

For example, tuning QEMU + KVM, using a specific Linux distro that optimizes Dockers (Alpine?), or maybe turning off the host's GUI and processes somehow?

I am new to this whole virtualization thing so pardon me if this sounds unreasonable. Nevertheless, I would love to learn more about the potentials of this project!

sickcodes commented 4 years ago

Thanks for your comments!

I just had a look at some of the packages for alpine and it could be done.

When I started writing the Dockerfile it was a lot bigger. Removing the tun/tap bridge networking and just keeping it simple, it reduced the packages.

Docker and virt-manager version both run same for me.

I'd say swithing to Alpine wouldn't make a big difference currently, Arch docker starts with zero processes anyway: docker run -it archlinux ps aux. If someone else has any tips about base systems, would be great to hear.

You can read about the passthrough notes and options at Dhiru Kholia's repo which this Dockerfile "stands on the shoulders" of: https://github.com/kholia/osx-kvm

anh-collab commented 4 years ago

You can read about the passthrough notes and options at Dhiru Kholia's repo which this Dockerfile "stands on the shoulders" of: https://github.com/kholia/osx-kvm

Thanks! Just a quick question tho: I cannot figure out how to pass my Meta/Super key or command shortcuts like Ctrl + Tab to OSX. Do you have any idea? Should I make this a separate issue?

sickcodes commented 4 years ago

I don’t know the keyboard combos but you can play around on the host using xdotool.

I can’t do much even with the virt manager version.

If you must send that key, see if you can find a key code for super meta on xdotool.

https://sick.codes/paste-clipboard-linux-xdotool-ctrl-v-terminal-type/

https://askubuntu.com/questions/695017/why-does-my-xdotool-key-command-not-work

The VNC version might be better for key presses. Sometimes my one flips the caps lock, sometimes it never stops typing

Calinou commented 4 years ago

I think a macOS VM/container will always feel slow unless you can get GPU acceleration to work. Tuning QEMU or making the container smaller won't help with that. Unfortunately, it's very difficult to get working GPU acceleration in a macOS VM (if even possible nowadays).

sickcodes commented 4 years ago

Thanks for the comments @Calinou. I tried to passthrough my GPU into the container but I have an AMD Laptop GPU that isn't compatible (attempted a few months ago).

GPU pass-through to the container is certainly possible, I believe trivial for AMD GPU users, someone could try https://github.com/kholia/OSX-KVM/blob/master/notes.md and if it's all good we can add the option.

askz commented 4 years ago

Any thoughts on increasing virtual disk throughput ? I'm running on NVMe and can't get more than ~30Mo/s of disk io in the vm..

sickcodes commented 4 years ago

Im adding all sorts of new features right now

felipeborba-dev commented 4 years ago

@sickcodes I have an RX 580, I can do the tests