CPU spikes and performance problems changing window focus in Unity/Ubuntu 16.04.2

I'm experiencing weird performance issues changing window focus with Unity. It happens no matter the combination of applications I have open, though gets worse the more there are (whether they're terminal windows or Chromium windows).

For example, if I'm editing a text file with gedit and then click on Chromium, it will take an actual full second to change focus (and vice versa, so I can't start typing right away). Running 'top' in term while switching windows shows Xorg using ~50% CPU and compiz will using ~10%.

I'm running an i5-4670 with a GTX 1070. I'm using the 378.13 Nvidia drivers, and the Intel processor microcode firmware. Ubuntu 16.04.2.

Has anyone experienced this and found a solution? Thanks!

UPDATE: As indicated below, I've tried disabling intel_pstate and changing to the performance governor. I've also experimented with a single monitor configuration, as well as Unity's Low Graphics Mode. No dice on any of these unfortunately.


Solution 1:

I'm also seeing this on 16.04 with i5-4460 and a GTX 960 on a 32bit system (don't ask!) I don't see it with nouveau drivers but I do with the NVidia proprietary ones (all I've tested up to 381.13.)

Although not a proper solution, restarting unity by using unity --replace seems to work around the issue for that session. (You might need to try it again if it doesn't work first time.)

This could be related to bugs.launchpad.net/ubuntu/+source/unity/+bug/1300892. If you think that bug affects you then please do click "This bug affects me" at the top so that the maintainers get a good reflection of how many people this bug impacts as this is currently triaged as a low priority bug.

EDIT: It seems that adding the command /usr/bin/unity --replace command to "Startup Applications" does work okay as a kludgy but less temporary workaround. :)