How to Control App Priorities with Ananicy in Linux

Ananicy Control Apps Featured

Auto Nice Daemon is ancient, and changing your software priorities manually is annoying. Isn’t there a modern way to control how many resources each program should use? Meet Ananicy (ANother Auto NICe daemon), a modern auto-nice solution, with which you can create profiles for your software to prioritize the apps you care about. Let’s see how you can do that.

Installation

Ananicy needs systemd to work, so it isn’t compatible with every distribution under the sun. To install it on Ubuntu, Mint, Debian, and compatible distributions, use:

git clone https://github.com/Nefelim4ag/Ananicy.git
./Ananicy/package.sh debian
sudo dpkg -i ./Ananicy/ananicy-*.deb
Ananicy Control Apps Git Clone

If you are on Arch, Manjaro, or another similar distribution, you can install it with:

git clone https://github.com/Nefelim4ag/Ananicy.git /tmp/ananicy
cd /tmp/ananicy
sudo make install

Ananicy also relies on schedtool, so if it’s not already installed, make sure to add this, too. You can do that on Debian-compatible and Arch-compatible distributions, respectively, with:

# Debian/Ubuntu
sudo apt install schedtool
 
# Arch Linux
sudo pacman -S schedtool

With everything set up, enable its daemon to have it always active and monitoring your applications:

sudo systemctl enable ananicy
Ananicy Control Apps Enable Ananicy

To start the actual application, use:

sudo systemctl start ananicy

If you are on a low-powered system, where every piece of software is fighting for resources, it may start feeling somewhat more responsive right away.

Check the Presets

Ananicy comes pre-bundled with a bunch of rules for many popular applications. To check them out, fire up your favorite terminal and pay a visit to Ananicy’s rules directory:

cd /etc/ananicy.d/00-default/
Ananicy Control Apps Presets

The rules for each application are stored in separate files. For example, to check out the preset rules for the popular qBittorrent filesharing client, you could use:

sudo nano qBittorrent.rules

You can use those as a base for your own rules.

Add your own rules

To create rules for an application, you should know its process name. Thankfully, on Linux, that’s usually the same as the application’s name. You can use the top command to verify the process name.

Also read: The Power-User’s Guide to htop

Locate a process that is hogging your computer and note down its name. Let’s use the timeshift app as our example.

Create a new text file in Ananicy’s rules directory. It’s better if you use the application’s name for easier future reference. Make sure to have your file end with “.rules” for Ananicy to recognize it as a rules file.

sudo nano timeshift.rules
Ananicy Control Apps Create Custom Rule

The easiest way to create a rule for a piece of software is by only stating its name and classifying its type. Ananicy comes with predefined types for games, multimedia apps, document editors, etc. To check them out, use the command:

ananicy dump types
Ananicy Control Apps Dump Types

Each of those comes with different nice, ionice, cgroup, and other values, but it’s suggested you don’t go further than tweaking an application’s nice value. However, for applications that read and write a lot to your storage, it’s also worth defining their input-output priority using the ioclass parameter.

With all that in mind, we are ready to craft our own custom rule:

{ "name": "timeshift", "type": "BG_CPUIO", "nice": 17, "ioclass": "idle" }
Ananicy Control Apps Custom Timeshift Rule

The above rule:

  • States the application’s name
  • Defines its type
  • Assigns it a different nice priority compared to the presets
  • Sets its input/output priority as idle

Theoretically, you only have to state an application’s name, and everything else is optional. Practically, if you do only that, Ananicy will only acknowledge the app’s existence but not try to control it. For that, you will have to define its type at least.

Its type comes with different predefined nice and input/output values, and you’ll probably find one that matches how you want to restrict a piece of software. Sometimes, though, like in our case with timeshift, you may want to tweak them further. That’s when you will have to explicitly state the nice or ioclass value you want if it’s different than the one included in Ananicy’s type preset.

The BG_CPUIO preset we selected matches our application’s type since, as a backup solution, it usually runs in the background but can eat up a lot of processing cycles while performing continuous reads and writes. However, the BG_CPUIO preset would assign it the lowest possible nice and ionice values, which could make a backup process take ages. Because of this, we increased the nice value to 17 and the ioclass to best-effort, to somewhat speed up the process.

Let’s take a look at another example. Batman: Arkham City’s “Joker’s Carnival” DLC is one of my favorite pieces of gaming. Its action relies on fluid motion, though, and I could feel it stuttering in Linux Mint whenever another piece of software is running in the background. Thus, for this one, I wanted to do the opposite – increase its priority over everything else.

Ananicy Control Apps Batman In Action

By checking Linux Mint’s System Monitor after running the game through Steam with Proton, we can see its process name as “BatmanAC.exe.” To give it a nice boost with Ananicy, I created a new rule called “BatmanAC_ody.rules” like before. However, in this case, its contents were:

{ "name": "BatmanAC.exe", "type": "Game"}
Ananicy Control Apps Custom Batman Rule

That was enough since the “Game” type comes with a “-5” nice value, prioritizing an app over everything else. Thus, you don’t have to explicitly state the nice value yourself or craft more complicated rules.

One restart later, for good measure, and Ananicy will be active, ready to spring into action to tweak your software’s priorities. The value you see for the BatmanAC.exe process in the screenshot below was assigned automatically, without needing any user intervention.

Ananicy Control Apps Batman System Monitor

Note that you don’t have to do this for all your software, but pulling the reins on the most demanding background processes and boosting the more interactive ones can make a world of difference to how using your computer feels. It can minimize stuttering and provide a smoother experience all around.

Are you already using Ananicy or another similar solution that allows you to control how your computer’s resources are assigned to your apps? Are you manually renicing your software? Tell us in the comments section below.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Odysseas Kourafalos

OK's real life started at around 10, when he got his first computer - a Commodore 128. Since then, he's been melting keycaps by typing 24/7, trying to spread The Word Of Tech to anyone interested enough to listen. Or, rather, read.