6

First of all, hopefully this is the right place to post this type of question - if it isn't, do let me know.

I have a relatively new PC with 16 GB RAM, 10th Gen Core i3, 4 physical and 4 virtual cores (hyperthreading), I do not have an SSD. It runs Linux Mint and uses the KVM.

The first year or so after buying my computer, the emulator worked great - it was fast and I was having a great time working on my apps.

A couple of weeks ago, I realized that the emulator would occassionally become slower (around 50-60 percent, to be exact) for around a minute or two, before then becoming very fast for around 1-3 minutes.

It's very strange, it goes like so:

  • Boot up emulator
  • Starts off blazingly fast
  • 2 minutes later it suddenly drops by around 50-60 percent in speed for around 1-2 minutes
  • Becomes blazingly fast again for some time

Here is my emulator configuration stats:

enter image description here enter image description here

(I sometimes use AOSP emulators, but in this case I will just give an example of the Google API emulator.)

This is incredibly frustrating - I use the emulator so many times, and I have a relatively new PC.

PC info:

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  8
  On-line CPU(s) list:   0-7
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Core(TM) i3-10105 CPU @ 3.70GHz
    CPU family:          6
    Model:               165
    Thread(s) per core:  2
    Core(s) per socket:  4
    Socket(s):           1
    Stepping:            3
    CPU max MHz:         4400.0000
    CPU min MHz:         800.0000
    BogoMIPS:            7399.70
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mc
                         a cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss 
                         ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art
                          arch_perfmon pebs bts rep_good nopl xtopology nonstop_
                         tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cp
                         l vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1
                          sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsav
                         e avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault
                          epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced 
                         tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase t
                         sc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed a
                         dx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsa
                         ves dtherm ida arat pln pts hwp hwp_notify hwp_act_wind
                         ow hwp_epp md_clear flush_l1d arch_capabilities
Virtualization features: 
  Virtualization:        VT-x
Caches (sum of all):     
  L1d:                   128 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    1 MiB (4 instances)
  L3:                    6 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-7
Vulnerabilities:         
  Itlb multihit:         KVM: Mitigation: Split huge pages
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Not affected
  Mmio stale data:       Mitigation; Clear CPU buffers; SMT vulnerable
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
                          and seccomp
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer
                          sanitization
  Spectre v2:            Mitigation; Enhanced IBRS, IBPB conditional, RSB fillin
                         g
  Srbds:                 Mitigation; Microcode
  Tsx async abort:       Not affected

Things I've tried:

  • allocate more RAM to the emu (5 GB and 8 GB) it actually felt slower and more incosistent with more ram
  • turn off other programs
  • different tweaks (none of which worked)

I am looking for help as to how I can improve the emulator speed, as it feels as though you need some sort of NASA computer or 32 GB RAM Core i9 12th generation with an RTX 3090 these days to actually get consistent QEMU performance - very frustrating!

Some people say it's due to emulator hibernation, but I don't know how to disable this.

I also sometimes get this:

enter image description here

... which may also be causing lag.

Any help would be appreciated -- the only fault I can think of with my PC is that I'm using a HDD, which may or may not be the root cause of this issue.

1

2 Answers 2

3

In my case, the issue seems to be the constant and excessive writing of snapshots to the disk by the emulator while it is running.

For now, this option isn't guaranteed to be available in all configurations.

To disable this behavior:

  1. Run your emulator, and click on the three dots (...) to open the settings:

    image

  2. In the settings, click "Snapshots":

    image

  3. Switch to the "Settings" section on top:

    image

  4. Set "Auto-save current state to Quickboot" to No:

    image

  5. It'll ask you to restart the emulator, click Yes:

    image

After this the emulator will shut down. If it doesn't restart automatically, go ahead and start it again manually.

Now you'll hopefully have the same fast performance as before!

NOTE: This fix breaks Quickboot entirely, and the emulator will always Cold boot when using this. Fair tradeoff in my opinion!

13
  • Unfortunately I do not have that setting, this is how it looks like for me: i.imgur.com/Nvi95Ux.png -- maybe it's because my default state is cold boot rather than quick boot, i don't know. I would also delete your old answer. Commented Sep 18, 2022 at 0:32
  • That's really weird... what's your emulator version? You can find it in the (...)>Help>About Commented Sep 18, 2022 at 0:36
  • Google Pixel 5 API 31 x86_64 set to ' cold boot '. Maybe the setting I have is the same as yours, but turning it to off is something I did a long time ago and it hasn't solved the issue, I suspect I just don't have your setting. Commented Sep 18, 2022 at 0:37
  • @thebluepandabear I also tried setting my current emulator to cold boot, yet I still have that option there. Commented Sep 18, 2022 at 0:38
  • Ok, well my version is 31.3.10-8807927. Commented Sep 18, 2022 at 0:38
2
+100

16GB is a bit low, especially as you're running a GUI as well, presumably running Android Studio as well, etc. Note that 32GB of RAM is far from exotic, especially if you're doing development work and running VMs (as you basically are with the Android Emulator). In fact, I'd personally say it's the minimum.

It's always difficult to conclusively answer a question like "why is my computer slow?," but have you checked your resource usage using (h)top and/or iotop? These tools will likely point you in the right direction.

  • allocate more RAM to the emu (5 GB and 8 GB) it actually felt slower and more incosistent with more ram

^^ This makes me suspect that you're using a lot of system memory and things are getting paged out, which will be extremely slow on a spinning disk.

1
  • I have used htop/iotop and there's hardly a difference in results when it was fast/slow. The only thing that is kind of helping is switching to a lower SDK level (Android 9) instead of Android 12 :P Idk what paging means, though I do suspect that my HDD is causing most issues. I'm thinking of switching to scrcpy with a Pixel 3 (arriving soon) instead of a QEMU, hopefully that does speed things up! Do you believe scrcpy speed is comparable to an emulator? Commented Aug 30, 2022 at 11:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.