Performance Settings For Low Latency

From $ sudo lshw

Lubuntu 24.04 LTS

LXQt Desktop Environment (if applicable)

Problem Description:
I’m working on configuring some of the low latency settings mentioned below.
Will these settings survive a reboot or will a cronjob(s) need to be set?

The settings will not survive a reboot. You will have to manage your settings with some sort of automated startup script. I use a service.

You will want to experiment with your specific application to determine what settings are best.

As dsmythies says. You can use a startup script:

Create a service file:
sudo vi /etc/systemd/system/mykernelopts.service
Add the following content to the file:

[Unit]
Description=Enable Kernel options
After=sysinit.target

[Service]
Type=oneshot
ExecStart=/usr/bin/makesettingshappen.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Save the new file, exit vi then you can make the script to run with:
sudo vi /usr/bin/makesettingshappen.sh

and add this code:

#!/bin/bash
## Disable proactive memory compaction
echo 0 | tee /proc/sys/vm/compaction_proactiveness >/dev/null

## Disable kernel samepage merging
echo 0 | tee /sys/kernel/mm/ksm/run >/dev/null

## Trashing mitigation (prevent working set from getting evicted for 1000 millisec, this can help to mitigate stuttering behavior under memory pressure conditions)
echo 1000 | tee /sys/kernel/mm/lru_gen/min_ttl_ms >/dev/null

## Prevent stuttering behavior during intense I/O writes that may involve massive page cache flushing
echo 5 | tee /proc/sys/vm/dirty_ratio >/dev/null
echo 5 | tee /proc/sys/vm/dirty_background_ratio >/dev/null

Save the new file, exit vi and run:
chmod +x /usr/bin/makesettingshappen.sh

You can now enable (start at boot) and start the new service:
sudo systemctl daemon-reload
sudo systemctl enable mykernelopts.service
sudo systemctl start mykernelopts.service

1 Like

There may be a config file where these are set. Most likely sysctl.conf but I’m not familiar

A post was split to a new topic: Screen Resolution Issues on Lubuntu

Where do I put the above lines and do I create a cron/anacron script depending on where those are put??

The mentioned .conf file seems to be very limited in connections with the commands in my original post here.
Let me know if my config file needs to be shown here.
Currently it is the default…I customized nothing in that config file.
I’m just not certain that what I have is native to Lubuntu specifically or if it’s the same in all *buntu variants.

I don’t see the following in your guidance.
May I uncomment these or will they need to be somewhere else in another similar file?
(Notice the lines are commented out of the script command lines. I added it to the script in your guidance in preparation only)

### Uncomment to incorporate the command
# set the cpufreq governor to performance via:
# /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Using a terminal window, you type those commands: The second command enables the service so that it will self start upon future reboots; The third command starts the service now, resulting in your desired settings being set now; Myself, I don’t think the first command is needed, but it will rerun all generators, reload all unit files, and recreate the entire dependency tree.

Setting the CPU scaling driver to use the performance CPU scaling governor is done via /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, as mentioned, but the actual command needed is:

echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Actually, since your service will already be running as root, you don’t need the sudo.

Example:

doug@s19:/media/lexar-ssd/critical$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
doug@s19:/media/lexar-ssd/critical$ echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
doug@s19:/media/lexar-ssd/critical$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
doug@s19:/media/lexar-ssd/critical$

You should experiment with all of these settings for your particular application, as some might not do what you want. For example, the other day, I tried all these on a demanding test that I run sometimes and it made things worse. I didn’t isolate which exact setting or settings.

By the way, after reboots you can check the status of your service. Example (for my test computer):

doug@s19:/media/lexar-ssd/critical$ systemctl status doug-post-boot-s19
○ doug-post-boot-s19.service - Doug post boot script for s19
     Loaded: loaded (/etc/systemd/system/doug-post-boot-s19.service; enabled; preset: enabled)
     Active: inactive (dead) since Tue 2025-12-30 07:54:42 PST; 2 days ago
   Duration: 17ms
    Process: 872 ExecStart=/home/doug/post-boot/doug-post-boot-s19.sh (code=exited, status=0/SUCCESS)
   Main PID: 872 (code=exited, status=0/SUCCESS)
        CPU: 9ms

Dec 30 07:54:42 s19 systemd[1]: Started doug-post-boot-s19.service - Doug post boot script for s19.
Dec 30 07:54:42 s19 root[878]: doug-post-boot-s19.sh - begin...
Dec 30 07:54:42 s19 root[885]: doug-set-tcc-offset.sh - begin...
Dec 30 07:54:42 s19 root[887]: doug-set-tcc-offset.sh - found TCC OFFSET device at /sys/devices/virtual/thermal/cooling_device22. exiting, done...
Dec 30 07:54:42 s19 root[889]: doug-post-boot-s19.sh - exiting, done...
Dec 30 07:54:42 s19 systemd[1]: doug-post-boot-s19.service: Deactivated successfully.
doug@s19:/media/lexar-ssd/critical$

What all is recommended in a “test” setup, you know… after trying in a Virtual setup but before setting the changes to the main system?

I can not answer your question. It would be a function of what you’re trying to do. It might just be that you need to set the changes in the main system.

Yep, I believe I’m catching that same impression as my volume levels seem to be less than quality output. And hardware and software functionality choices.

I may need to change my whole install setup.