2

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!

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 Answers1

0

You are looking for a bottleneck. So you need to understand your software first and what it does. In games your would check GPU or CPU for bottlenecks, for instance.

Your i3 only has 4 cores, just because it's new, doesn't mean it's good. For decent developing, this is way to little. This will be a bottleneck. A HD in 2022 for developing is a desastre. An AVD can get 15 gigs big over time. Your poor old HD has to read and copy all that to ram, partially. Upgrade to SSD.

Do the following:

  • Triple check you updated the emulator from within AS
  • create a new device, don't modify any settings, they are usually fine.
  • open two consoles and run "atop" in one ( bottleneck detection cpu + storage) and "htop" (multi threading cpu , memory overview) in the other. Get familiar with those tools.
  • now start the fresh and new emulator device from AS and wait until it's fully booted and did it's software update checks( the Google image will try to update all its internal apps once it's online!)
  • monitor htop + atop during all this and also once you run your app.

If the HD is the bottleneck (atop shows it in red) try to disable hibernating / snapshots inside AVD settings. The emulator stores snapshots constantly by default.This is fine for fast SSD, but might be slower with hd. (Guessing)

If your cpu is the bottleneck, there's hardly anything you can do. The best solution then would be to plug in a hardware Android device via USB and use the computer only for Android studio. In short not run the emulator at all. That's how I do it on my backup laptop (also a weak Intel i3). I upgraded my main to an AMD Ryzen 9 5900X. That has 12 cores,24 threads. Just to give you an idea what people use for developing. Good luck

CaptainCrunch
  • 201
  • 1
  • 1