You are not logged in.
I'm looking for some sort of program or configuration change that will give increased priority to whatever window is currently in focus, dynamically.
I found this VeryNice:
https://wiki.archlinux.org/index.php/Verynice
But it seems that with VeryNice you have to manually specify which programs should get improved nice levels. I need something that does it on the fly - whatever the currently focused window is gets improved priority.
I have spent a couple hours researching this with google but in the end I've just become confused and have to turn to here for help ![]()
EDIT: I should also add that one of the main problems here is I'm running 12 instances of the same process, switching between them frequently, and the one currently in focus needs to get maximum CPU priority (nice -20) at the expense of the others.
Last edited by Raize (2017-01-14 19:38:30)
Offline
Never mind, I found out how to make a bash script to do this.
Offline
Care to post. Whilst I'm unlikely to use it, I am curious as to the solution (after you posted I went hunting and drew a blank).
Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703
/ is the root of all problems.
Offline
In the end I based the solution on the assumption that whatever is the foreground window will have much higher CPU usage than the background windows.
So when the script detects one of the processes using over 15% CPU, it gives it maximum priority, and if the CPU usage drops below 15% again it gives it minimum priority, and cycles every half second.
It's a real edge case, but very useful for me.
Horrible amateur bodge-job code as follows:
THRESHOLD=15
FAST=-20 #priority niceness lvl
SLOW=19 #low priority
DELAY=0.5
IFS="
"
while true; do
top_out=$(top -b -n 1 | grep "name of process")
for i in $top_out; do
cpu_usage=$(echo -n "$i" | sed 's/\s\s*/ /g' | cut -d' ' -f8 | cut -d . -f 1)
echo $i
if [ "$cpu_usage" -gt "$THRESHOLD" ]; then
pid=$(echo -n "$i" | cut -b 1-5)
sudo renice -n "$FAST" -p "$pid"
fi
if [ "$cpu_usage" -lt "$THRESHOLD" ]; then
pid=$(echo -n "$i" | cut -b 1-5)
sudo renice -n "$SLOW" -p "$pid"
fi
done
sleep $DELAY
doneOffline
OK, but how do you go on if a CPU intensive process is running in the background, which will exceed the threshold? 3D render etc.
Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703
/ is the root of all problems.
Offline
I won't start background processes if I need the CPU for something else. That was one of the main reasons I went with Arch - I can customise it so it only does things when I tell it to - no automated updates stealing all the CPU at inopportune moments!
I only need the script for the situation where I'm switching between windows so often that the prioritisation needs to be automated.
I'm multiboxing games, if you're wondering what on earth I'm doing here. Got a nice +50% frames per second with this script...
Offline
OK, nice. I see it useful for that. I guess I came from a different angle, since a lot of what I do that eats CPU (and/or GPU) is of my own doing.
Although my CPU is getting long in the tooth, it's still more than capable, and for normal day to day use is just fine. If I'm rendering in Blender, or running a VM, I could probably say I wouldn't want that process crippling at all, anyway (I only ever run a VM on 3 cores, so that I have one available on the host, anyway).
It's nice to see how you solved it though, and I learned that renice really is on the fly. I previously assumed it had to be used at the start.
Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703
/ is the root of all problems.
Offline
My CPU is of similar vintage to yours (Xeon X5450 - similar to Core 2 Quad 9650, but with a socket mod to make it fit my motherboard) although I'm running it at 4GHz. In itself it's pretty good for almost decade-old parts, but I just like pushing everything to the limit.
I didn't actually expect renice to work as well as it did, and thought I would end up having to change core affinities on the fly with taskset. I'm glad it didn't come to that as it sounds like a recipe for crashes.
Offline