Dynamic, window focus-based CPU pinning

Hey there. Inspired by other threads on CPU pinning on Qubes (linked below) I’ve created a solution to dynamically pin VMs’ vCPUs based on which one is currently focused.

Check the project out at: GitHub - Atrate/qubes-window-boost: Dynamically pin Qubes domains to vCPUs based on the focused window . Contributions welcome :).

TLDR:

This script is designed for QubesOS. It automatically reads the current focused window’s parent VM and pins the VM to all CPU cores (or to performance cores, this only needs one line’s worth of changes). The default assumption is that all VMs are by default pinned to E-cores on asymmetrical CPUs and they get given access to all cores when in focus for additional snappiness and performance. See CPU Pinning Alder Lake for information on how to set up the prerequisite core pinning required for this script to run well.

2 Likes

This sounds great.

What happens if you switch from a qube to the other multiple times per minute? The overhead of calling xl should be large?

I’ve not noticed the overhead to matter. Pinning/unpinning takes only a fraction of a second (at least in userspace) and watching the pins confirms that there doesn’t seem to be a noticeable delay.
watch -d -n 1 "xl vcpu-list | tr -s ' ' | cut -d' ' -f 1,7 | uniq | column -t"