There is a simple fix to the lags/hangs after 5 minutes of idle. Simply disable the offending mediaanalysisd which is part of Apple's video processing framework. Photos will just work fine, you'll only miss some metadata on videos, but it's not a big deal.
Enter the following command in Terminal:
sudo rm /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist
and then log out/in. Problem solved.
If you prefer more elegant solutions, you can use the launchctl unload command instead of the simple delete. For a comlete peace of mind, you can also disable photoanalysisd.
"I had this problem on High Sierra and fixed it with this terminal command:
sudo rm /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist"
This is not a true solution. It's avoiding the problem. Mediaanalysisd is a machine learning system process that scans your photos and adds what it learns from Apple big data about said pics to your spotlight, Photos app, Siri etc etc. No plist, no sweet 'oh my spotlight gets me when I search for Sarah's dog'. Same for Siri too, which needs this process to understand images past the file size.
The process is mainly executed as GPGPU code on your graphics card, so if you're using non-Apple EFI (in your video card), and don't have a perfect DSDT it's possible to get the lag/console issues because the amount of GPU power you have at your disposal is miscalculated and the GPU still has to try to provide 60fps to the display. Hell even if you do if there isn't a direct equivalent card it could be likely.
Most commonly it seems to be happening to Nvidia GPUs because the soft switcher makes it quite easy to have a 650ti be pre-calculated to perform like a 660ti, especially with confusing names and DevIDs focused on 'getting it to work' and not 'getting it to imitate perfectly'.
com.apple.xpc.launchd[1] (com.apple.DumpGPURestart): Service only ran for 0 seconds. Pushing respawn out by 10 seconds
RequireScreenSleep = :true;
launchctl disable gui/$UID/com.apple.mediaanalysisd