mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00

This sets the macOS QoS class of the renderer thread. Apple recommends[1] that all threads should have a QoS class set, and there are many benefits[2] to that, mainly around power management moreso than performance I'd expect. In this commit, I start by setting the QoS class of the renderer thread. By default, the renderer thread is set to user interactive, because it is a UI thread after all. But under some conditions we downgrade: - If the surface is not visible at all (i.e. another window is fully covering it or its minimized), we set the QoS class to utility. This is lower than the default, previous QoS and should help macOS unschedule the workload or move it to a different core. - If the surface is visible but not focused, we set the QoS class to user initiated. This is lower than user interactive but higher than default. The renderer should remain responsive but not consume as much time as it would if it was user interactive. I'm unable to see any noticable difference in anything from these changes. Unfortunately it doesn't seem like Apple provides good tools to play around with this. We should continue to apply QoS classes to our other threads on macOS. [1]: https://developer.apple.com/documentation/apple-silicon/tuning-your-code-s-performance-for-apple-silicon?preferredLanguage=occl [2]: https://blog.xoria.org/macos-tips-threading/