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.

10
  • 1
    How much is "more RAM"? Considering Android hardware devices a phone with 2GB RAM would be low-end hardware. A typical Android phone has 4-8 GB RAM. That the emulator starts so fast is because it does not start-up, instead it uses a sort of hibernate (suspend to disk) technology. Have you checked that your HDD is not the problem? PCs nowadays use SSDs - even a middle-class SATA SSD is usually 400% faster than a HDD.
    – Robert
    Aug 16, 2022 at 7:13
  • @Robert I tried 5 GB RAM as well and no difference I also now just tried 8 GB ram no difference still incosistent. Also I did not understand what you said about hibernating. Aug 16, 2022 at 7:20
  • @Robert I don't know how I can 'check' whether the problem is with my HDD without comparing it with an SSD. Unfortunately I presume it's probably due to it being an HDD, but I find it hard to believe that there aren't any optimizations I can make so it runs faster. If I could buy an SSD i would, but I can't as my parents will not let me because I come from a very strict family ! Very frustrated. If there is anything I can do so it is more consistent, do let me know. Aug 16, 2022 at 7:22
  • The common way to check if an HDD is used intensively is look at it's usage. On Linux AFAIK there is iotop. And if the low-speed times correlate with the high HDD usage the with a high chance you know why the emulator is slow.
    – Robert
    Aug 16, 2022 at 7:32
  • @Robert Thanks! Aug 16, 2022 at 7:45

1 Answer 1

0
+100

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

6
  • Thanks for your answer, but I can't find the option for disabling snapshots inside the AVD settings. Aug 25, 2022 at 21:41
  • I will give you the bounty now since it expires in 6 hours and no one has actually given an answer. I will mark it as the correct solution if you can assist me as to where/how I can find the option of disabling hibernating/snapshots as I cannot find it thus far. Thanks, also your PC build is insane lol Aug 26, 2022 at 0:09
  • @thebluepandabear there's two options: first the avd settings. Select cold boot: screenshot: i.stack.imgur.com/Lk14v.png secondly while the emulator is running in the floating menu hit the three dots for the emulator options (extended controls) here's the full documentation , jump to snapshots > extended controls Aug 26, 2022 at 6:40
  • I find it quite strange when you say that the emulator stores snapshots constantly by default. From my observations, the emulator only stores a snapshot before you exit the emulator as per their description: "Starts from the state when the device last exited". Storing snapshots constantly doesn't make sense if the user hasn't exited yet, so I think what you're saying is incorrect. I will report to you back and tell you if I get performance improvements. Aug 26, 2022 at 6:42
  • I'm at 'snapshots' > 'extended controls' -- what should I do now? I don't see any options for hibernating inside the snapshot settings: i.imgur.com/NL6AibV.png Aug 26, 2022 at 6:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .