macOS app nap: how to disable for VirtualBox (#18678)

Discussions related to using VirtualBox on Mac OS X hosts.

macOS app nap: how to disable for VirtualBox (#18678)

Postby PikeSandwich » 18. May 2019, 16:54


ModEdit; related ticket: #18678: macOS app nap: effecting performance of VirtualBox VM

Hi,

It seems that macOS app nap is kicking in for VirtualBox guest VMs. Although not always possible, a workaround is to run the VM headless and app nap doesn't seem to be a factor in that case.

My question is, does Virtual Box have a setting to disable app nap? Note please don't suggest using the old "Finder → get info → unclick app nap" solution as it doesn't work for macOS apps built on 10.9 and newer. I've grep'd virtual box community edition source code and there doesn't seem to be anywhere that it uses apple API to inform macOS of activity that is not suitable for app nap.

Also I suspect this might be a major contributor to poor experience of Virtual Box on macOS for many users. Imagine, minimizing your guest, and any jobs it might do in the background are more likely to queue up because it's running at 10% or less power, and then when you open the window it starts to get busy, exactly at the moment you want to interact with guest. Or ssh into a linux guest? So minimize the window because you don't need it. app nap kicks in because minimized window, and now your ssh commands/compiles/builds/etc run at 10% or less speed.
Last edited by socratis on 28. May 2019, 00:30, edited 1 time in total.
Reason: Added ticket related information.
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby socratis » 18. May 2019, 19:25

PikeSandwich wrote:Also I suspect this might be a major contributor to poor experience of Virtual Box on macOS for many users.
I don't remember anyone complaining particularly about that.

PikeSandwich wrote:Imagine, minimizing your guest, and any jobs it might do in the background are more likely to queue up because it's running at 10% or less power
Minimizing or hiding? And how do you know that it's running at 10% of its capabilities? What tasks are your guests running? And what guest are we talking about?

We need something more than generic statements I'm afraid if we're going to have a fruitful discussion. From the exact steps to a complete VBox.log. We need to see a complete VBox.log, from a complete VM run, where the problem occurs:
  • Start the VM from cold-boot (not from a paused or saved state) / Observe problem / Shutdown the VM (force close it if you have to).
  • With the VM completely shut down (not paused or saved), right-click on the VM in the VirtualBox Manager and select "Show Log".
  • Save only the first "VBox.log", ZIP it and attach it to your response. See the "Upload attachment" tab below the reply form.
Image
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 25220
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 18. May 2019, 23:15

steps taken:

0. rm `VBox.log`
1. launch linux guest with head
2. ssh into linux guest
3. launch `spin.rb` script to loop/bump counter, and every 1.0 second emit count/reset-count, output is @440,000/s
4. minimize (yellow button on macOS host) guest head
5. watch `Activity Monitor.app` CPU tab with added field `App Nap` and filter on `virtualbox`, `VirtualBox VM` nap=`no`
6. watch `Intel Power Gadget.app` Frequency monitor, core pegged at turbo rate of 4.0GHz
7. wait for something around 30-60 seconds passes
8. notice #3 changed output from @440,000/s → @120,000/s
9. notice #5 changed nap from `no` → `yes`
10. notice #6 changed from 4.0GHz → 2.0GHz and stabilized at 1.5GHz
11. wait an arbitrary 45 seconds or so
12. un-minimize previously minimized guest head (from step #4)
13. notice #3, #5, #6 change back to output @440,000/s, nap=`no`, core=4.0GHz
14. shutdown linux guest
15. save `VBox.log`
Attachments
spin.log.gz
(1.16 KiB) Downloaded 8 times
spin.rb.gz
ruby script to output count/s
(176 Bytes) Downloaded 7 times
VBox.log.gz
(34.66 KiB) Downloaded 8 times
Last edited by PikeSandwich on 18. May 2019, 23:24, edited 1 time in total.
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 18. May 2019, 23:22

- added screenshots from activity monitor and intel power gadget
- first 4.0GHz range in frequency chart is when spin.rb was launched
- then as soon as activity monitor indicated change from app nap=`no` → `yes` it fell off to 2.0GHz and under
- then my user action of un-minimizing guest head caused things to speed up again (nap=yes, and 4.0GHz)
Attachments
activity.jpg
activity monitor showing nap=yes
activity.jpg (72.55 KiB) Viewed 672 times
frequency.png
core frequency
frequency.png (95.58 KiB) Viewed 672 times
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby socratis » 19. May 2019, 08:05

First of all, thank you for the really detailed recipe.

I couldn't reproduce it on a 10.11.6 host with a Mint19 guest. I could try it on a 10.14 OSX host, but I'd like to avoid the downtime. I see the "VirtualBox" process going to AppNap=Yes, but not the "VirtualBoxVM" process.

Another really important difference is that I don't have the Intel Power Gadget installed, and I haven't installed it because it wants to install an "EnergyDriver.kext". I don't like 3rd party kexts. Could you uninstall it and try again?

BTW,
00:00:01.040052 File system of '/tank00/virtualbox/ubuntu1904/ubuntu1904.vdi' is apfs
What's "/tank00/..." and why is it not "/Volumes/..."? Has Apple changed its tactics with APFS? I don't recall something similar.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 25220
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 19. May 2019, 12:52

socratis wrote:I couldn't reproduce it on a 10.11.6 host with a Mint19 guest. I could try it on a 10.14 OSX host, but I'd like to avoid the downtime. I see the "VirtualBox" process going to AppNap=Yes, but not the "VirtualBoxVM" process.

just pure speculation, maybe something changed with AppNap between 10.11.6 and 10.14.x where before it did not consider a `VirtualBox VM` head and now (at least with 10.14.x, or earlier) it does, or VirtualBox for 10.11 is different enough this behaviour comes into play? I'm assuming vbox 6.x doesn't run on macOS 10.11?

more info on my host system; very clean 10.14.15 system, and aside from power gadget that I installed for the express purpose of digging into this issue, I only have "com.apple" kext drivers:
Code: Select all   Expand viewCollapse view
kextstat| grep -iv com.apple
Index Refs Address            Size       Wired      Name (Version) UUID <Linked Against>
  168    3 0xffffff7f851f0000 0xf0000    0xf0000    org.virtualbox.kext.VBoxDrv (6.0.8) BA29BAA2-1460-3F53-BF68-E672C5115BF1 <8 6 5 3 1>
  172    0 0xffffff7f852e0000 0x8000     0x8000     org.virtualbox.kext.VBoxUSB (6.0.8) 9331EE7C-CCD1-3E6D-B1FA-5D1036B0C0FF <171 168 57 8 6 5 3 1>
  173    0 0xffffff7f852e8000 0x5000     0x5000     org.virtualbox.kext.VBoxNetFlt (6.0.8) 4F577315-BF94-3C7A-974B-48ECBE38B445 <168 8 6 5 3 1>
  174    0 0xffffff7f852ed000 0x6000     0x6000     org.virtualbox.kext.VBoxNetAdp (6.0.8) 3793177D-4D36-37D6-8B61-50E941DFC8FF <168 6 5 1


socratis wrote:IAnother really important difference is that I don't have the Intel Power Gadget installed, and I haven't installed it because it wants to install an "EnergyDriver.kext". I don't like 3rd party kexts. Could you uninstall it and try again?

tried again → uninstalled intel power gadget, rebooted, verified kext is gone, launched linux guest, run spin.rb, and have confirmation on identical AppNap=`yes` and spin.rb performance degradation, @440,000 when nap=no, and @110,000 when nap=yes.

00:00:01.040052 File system of '/tank00/virtualbox/ubuntu1904/ubuntu1904.vdi' is apfs
What's "/tank00/..." and why is it not "/Volumes/..."? Has Apple changed its tactics with APFS? I don't recall something similar.

`/tank00` is a manually created directory, nothing to do with Apple standards/policies, that I created, owned by same account running parallels, same filesystem as `/`. It's just a placeholder for extra future storage.
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 19. May 2019, 13:14

Noticed something else peculiar... when the linux guest is running performant (not degraded), and spin.rb is the only activity, `VirtualBox VM` reports as 100% cpu on host activity monitor, and host top. Now here's the peculiar thing, when AppNap=yes and guest is degraded, the vm continues to show as 100% cpu even though spin.rb throughput drops to 25% or less.

More speculation on my part, I wonder what a linux kernel, or vbox provider layer (or whatever it's architecturally called), does when the host OS doesn't schedule the vm as frequently (ie: AppNap=yes), I bet this leads to excessive CPU spinning so even though my user-space spin.rb has dropped in performance, the actual effect of Apple's AppNap=`yes` with a VM is no power savings at all, and a considerable drop in throughput. Lose-Lose.
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 19. May 2019, 20:26

looks like someone else discovered the same issue, ratio of performance degradation seems consistent with this issue:
https://discussions.apple.com/thread/250276999
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby socratis » 19. May 2019, 20:45

Excellent find!!! 8)
Can you try one thing? Instead of minimizing the VM, hide it. See what happens...
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 25220
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 20. May 2019, 04:19

socratis wrote:Can you try one thing? Instead of minimizing the VM, hide it. See what happens...

test → instead of minimizing the head with yellow button, `⌘H` (command-H) used to hide head window
result → performance degrades when AppNap engages; performance restored when AppNap disengages
PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox

Postby socratis » 20. May 2019, 04:46

That's very unfortunate. These kinds of problems that are reproducible, should be reported to the bug tracker. Either search for an appropriate bug (I don't think I've seen one), or open a new bug report where you'll attach your logs and other vital information.

It would also help if you can post the bug report number here so other can see the progress, add information, or see the final resolution.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 25220
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: macOS app nap: how to disable for VirtualBox

Postby PikeSandwich » 27. May 2019, 17:55

PikeSandwich
 
Posts: 10
Joined: 18. May 2019, 14:38

Re: macOS app nap: how to disable for VirtualBox (#18678)

Postby socratis » 28. May 2019, 00:37

Thanks for the update. I edited the first post and the thread title to include the ticket.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 25220
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5


Return to VirtualBox on Mac OS X Hosts

Who is online

Users browsing this forum: Google [Bot], Jean Marie and 23 guests