-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why running the action on Linux VMs is slow #46
Comments
i just saw that windows machine has HAXM component installed |
Thanks! Definitely worth giving it a shot. I’ll creat a separate issue. |
macos minutes are x10 times more expensive than linux though - for private repos |
There is no better option at the moment @sisoje. Neither Linux nor Windows instances provided by Github action support hardware-accelerated VMs. |
I hope this isn't too off topic, I'm interested in furthering the development of running the emulator in CI on GNU/Linux. I've gotten the new emulator running under Docker in GitLab CI. It works without KVM, where its fast enough to run JUnit tests and really simple Espresso tests. It is too slow for more elaborate things. The big update is that it works with the default GitLab CI runners, e.g. without acceleration. It is important to use the Our Docker image and how its used is documented in our wiki https://gitlab.com/fdroid/wiki/-/wikis/Running-emulators-in-GitLab-CI |
Looks like some people are running their tests using ubuntu and are happy with ably/ably-flutter#232 (comment), even if it is slower. Me I would be interested too, because we have a very short tests suite and because the cost. I found their config here https://github.com/ably/ably-flutter/blob/2481f2ba55caf64c9f3df3e34afea1e5b0db966c/.github/workflows/flutter_integration.yaml |
There's potentially nested virt support on the larger runners: actions/runner-images#183 (comment) Has anyone gotten into the beta and been able to verify this? |
I ran a test on the Ubuntu 20.04 64 core "large runner" and from what I could tell there was no KVM support. See the run here: https://github.com/Expensify/App/actions/runs/3276676725/jobs/5393009096 Relevant Logs:
I'm happy to run any further tests if I've misconfigured anything in the test, just let me know. cc @hannojg |
👋 hello :) I am a PM at GitHub, if anyone fancies a chat about android nested virt testing on linux drop me an email on [email protected] - would love to talk about what we have upcoming |
@nebuk89 can't you share anything here? |
@JavierSegoviaCordoba I can do :D, to be a bit more centralised for everyone watching I wrote up where we are at under actions/runner-images#183 If y'all do any testing I would <3 feedback on the perf bits, I saw better perf on the 4-core than on the Macs which netted out pretty well :) |
Hi, I want to increase the performance of emulator booting with KVM.
I checked these. Everything seems to be OK but I could not understand why I am getting error while trying to do vm accelaration.
Environment info: Virtualization features: memory 32GiB System Memory Architecture: x86_64 |
FWIW, we started using a 4-core larger runner for our Android tests and it's been working great so far. The results are interesting. It's not any slower than macOS, but it's not dramatically faster either. However - it does seem to be more stable. When we were running on macOS, we frequently got failures booting the emulator before our tests could run at all. That doesn't seem to be happening after the switch. The downside is that the macOS runner was free (for public repos) and the 4-core Linux runner costs $0.016/min. We matrix for multiple versions of android, and run often, so it adds up. |
One gotcha I should mention. When first switching over, nothing worked. It crashed immediately when trying to start the emulator. The culprit turned out to be caching. We were using an AVD image built on macOS on the Linux runner. Easy fix - make sure that |
On the KVM setup, we use the bits mentioned here: - name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm |
Just did some benchmarking of the 4, 8, 16, 32 core linux agent with KVM enabled vs macOS The project I used was a non-compose project with about 10 UI tests. This was a fully fledged and shipped android application and not a sample app. The 4 core is super cheap and stable, and still significantly faster than macOS. (7min46sec vs 14min22sec total build + test time The 8 core seemed to be the most cost-efficient and was about 33% faster than the 4 core. The 16 core was a slight build improvement above the 8 core but almost the same testing time. The 32 core had negligible increases from the 16 core and the testing time sometimes still took longer. Seems like the 8 core will be what I'll be trying to use, and is still only .032 cents per minute compared to the .08 cents per minute of the macOS agent. 4 Core .016 cents per minute 8 Core .032 cents per minute 16 Core .064 cents per minute 32 Core: .128 cents per minute MacOS .08 cents per minute I actually ran this test with GMD and not ReactiveCircus but will do more benchmarking with avd caching + reactive circus later.
Linux is certainly not slow anymore! 😍 |
These tests do not work well on linux images that we are using (see ReactiveCircus/android-emulator-runner#46) This reverts commit df473cd.
@mrk-han Share the GHA config file? Was there anything special? |
I am glad this has helped folks out! Always feel free to reach out in the future <3 |
@nebuk89 - Alternatively, it would be awesome if the 4-core linux runner was free for public repos. In my case, when we switched from macOS to Linux for the KVM support, we drastically improved the stability of our test runs, but we also went from completely free to having a monthly cost associated with this. Our repo is public because its for an open source library, not an application. |
@mrk-han Thanks for posting the detailed diagnostic info from your test runs using the various XL Linux runners! Super super helpful 🙏 Wanted to follow-up on your last comment: did you ever have a chance to benchmark this with AVD Caching + |
Hey all, sorry I haven't followed up. We are actively working on migration plans still for the existing 2-core machines to enable this. I am sorry it has taken longer than I expected 😞 and please keep an eye here for me to follow up. |
This issue is no longer relevant as running hardware accelerated emulators with the upgraded free Linux runner is much faster than than the macOS runners: https://github.blog/2024-01-17-github-hosted-runners-double-the-power-for-open-source/ |
I'm trying to use Run echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
KERNEL=="kvm", GROUP="kvm", MODE="0[6](https://github.com/tofu-tech/laundry/actions/runs/7592535719/job/20681997439?pr=21#step:3:7)66", OPTIONS+="static_node=kvm"
Failed to open the device 'kvm': No such file or directory
Error: Process completed with exit code 1. Is there something else I need to do? Edit:
Edit2: |
Hi! Thanks for trying out this action.
I'd like to share a few words on the recently added Linux support to give you a bit of context on why it's much slower than running on
macos
.In general if you run this action on a Linux VM (e.g.
ubuntu-latest
), you'll get very few benefits over other CI solutions (perhaps other than easier configuration and less scripting) as there's no hardware acceleration on ubuntu VMs provided by GitHub Actions.While you can sort of have some versions of the emulators running without hardware acceleration, in practice you really need hardware acceleration enabled to run the Android Emulator, period. In fact I almost believe that the emulator binary should just not start at all and throw an error if it can't be hardware-accelerated, otherwise it defeats the purpose of having these modern
x86
,x86_64
system images.To give you a bit more context, I created this action solely to take advantage of the hardware acceleration support on the macos VM (enabled by HAXM which is installed on
macos
VMs), and never intended to add Linux support cause I know it won't be a good experience (at least not better than what you already have) without hardware acceleration.I wrote this article about running Android emulator on CI which should give you more context on running instrumentation tests on CI in general and why the lack of hardware acceleration support from the host machine is still the biggest challenge for running fast and stable instrumented tests on CI.
I understand this might be a bit of a disappointment for some of you, but unfortunately this is a much bigger problem than what can be solved / improved by a GitHub Action.
If you looked at the code, there's no magic at all. It basically automates the following process and makes it a little easier to configure for the common use cases:
As soon as you see "Emulator booted." in the log, the job of this action is basically done as from this point on the environment is handed over to your
script
so anything that works / doesn't work would not have much to do with the action itself, which only makes sure a live Emulator instance is available in the background.For those of you who are not fortunate enough to be able to use the macOS VM, as an alternative I'd encourage you to have a look at Cirrus CI which provides KVM-enabled Linux VMs and pricing seems pretty reasonable (100% free for opensource projects). I wrote a long article going over all the features relevant to Android and how you can optimize your pipeline etc. I also created some templates to help you get started.
Hope that gives you some context regarding the Linux support, why it's expected to be slow and the alternative you might want to look at.
Thanks!
The text was updated successfully, but these errors were encountered: