I need good latency for software stepping. I am using a parallel port and a
HobbyCNC PRO Stepper
board.
I needed to update my LinuxCNC computer as it was still using Debian 9 on a really old computer. I had ok latency on that old computer.
But during the move to Debian 12 I decided to use a somewhat newer PC as well, the "new" one having an AMD A-8 processor.
During initial tests, Debian 12 worked well on this old AMD-A8 machine, but the latency was horrid.
I found this article as well:
dantalion.nl/2024/09/29/linuxcnc-latency...arameter-tuning.html
and after tuning mine I now have excellent latency for my needs. (Big thanks to "dantalion" if they ever see this post, I could not find any way to contact them to thank them in their blog.)
Before tuning: 200,000+ microsecond base threads
After tuning :6,000 and below.
I ended up only setting 1 of the 4 processors for the real time tasks, vs 1/2 of them. As when I was watching the cores using HTOP while running latency tests, one core appeared to be doing nothing. And the non-realtime cores were getting hit pretty hard by other tasks when making the system work. So I figured I would just let one core handle the real-time, and let the other three cores take care of other stuff. Not sure if this will cause me a problem at some point, but so far it all seems to be working well, when actually running LinuxCNC and performing some real world initial tests.
Below is what I ended up doing, I am posting steps and my settings below for others that may be new to Linux and struggling with how/where to make the edits. I have not found anything that walks through all the steps. If you are using this, just be sure you read the above mentioned article and change the lines that impact the cores.
I don't fully understand all of the settings, but applying all of them noted in the blog post seemed to work for me.
What I did was:Edit Boot Parameters:
- open the terminal
- edit the grub file using nano: sudo nano /etc/default/grub
- edit one line in grub (put a # in front of the existing GRUB_CMDLINE_LINUX_DEFAULT="quiet" line to comment it out, then make a new line below it.) My new line is: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash skew_tick=1 nosmt=force kthread_cpus=0-1 irqaffinity=0-1 rcu_nocb_poll rcu_nocbs=2-3 nohz=on nohz_full=2-3 isolcpus=2-3 intel_pstate=disable amd_pstate=disable idle=poll cpufreq.off=1 cpuidle.off=1 intel_idle.max_cstate=1 amd_idle.max_cstate=1 nowatchdog nosoftlockup"
- save the file and close out of nano
- update grub: sudo update-grubEdit sysctl parameters:Make a new file for the custom config and add contents to it: sudo nano /etc/sysctl.d/99-custom.conf
- added the following lines:
kernel.timer_migration=0
kernel.sched_rt_runtime_us=-1
- save file and close out of nano
- I think rebooted computer.
Also I experimented with another machine that had an AMD A10 core, but that would result in 2 of the cores showing as inactive in htop, I think it has something to do with this chip being really 2 chips with dual cores, vs the AMD A8 is a single chip with 4 cores. I'm sure there is a way to address that, but since the A8 chipped worked out, I never pursued anymore.