Collaborations

LinuxCNC · Latency

LinuxCNC latency in depth: eight real tests on my milling machine's computer

In episode 2 of LinuxCNC from scratch I told you just enough to know whether your computer is good enough. This is the advanced workshop: the eight boots I ran on my EMCO F1's PC, all the numbers, which parameter improves what, and which one surprised me for the worse.

Published on 28 November 2026. Revised on 29 November 2026.

In the video I told you that, to drive a machine, the computer doesn't have to be fast: it has to be punctual. LinuxCNC gives it a fixed tick and, on each tick, decides what the motors do. Latency is how late that tick arrives when the computer gets distracted by something else: the mouse, the network, the disk, the screen.

What didn't fit in the video are the numbers. I wanted to know, with data and not from what you read on forums, what you gain with each Linux boot tweak. So I left the milling machine's computer measuring for a whole night: eight different configurations, each with its own reboot and about eleven minutes of testing with the computer flat out. Here's everything, so you can repeat it on yours.

The patient

It's the computer that drives my EMCO F1: a small second-hand office Dell, like the ones I recommend in the video.

ComputerDell OptiPlex 7070 Micro
ProcessorIntel Core i5-9500T, 6 cores (no hyperthreading)
Network cardIntel I219-LM, dedicated to the Mesa
Control cardMesa 7i76E at 10.10.10.10, with a direct cable
SystemDebian 12 with LinuxCNC 2.9.10
Realtime kernel6.12.113 PREEMPT_RT (tests A to G) and 6.1.0-52 PREEMPT_RT (test H)
Terminal on the milling machine's Dell with the lspci command showing an Intel I219-LM network card
The first check from the video, on the F1's Dell: Intel network card.

How I measured it, so you can repeat it

The tool is the same as in the video: Latency Histogram, which comes with LinuxCNC (Applications menu, under CNC, or latency-histogram in a terminal). I left it at its default values: a fast tick every 25 microseconds, the one a parallel port would use, and a calm one every 1000, the one the Mesa uses. LinuxCNC must be closed while it measures.

If you're only going to use a Mesa, you can measure just the slow tick with latency-histogram --nobase, which is what your machine will use. I measured both at once so I could compare with the parallel port, and that's somewhat more demanding for the computer.

A latency test with the computer idle is useless: big delays show up when the computer is busy. The official documentation is clear about it: you have to make it sweat while it measures and leave it running for several minutes, because peaks are rare. I pushed it like this, all at once:

  • CPU, memory and disk flat out with stress-ng: six computing tasks, two input/output, one memory and one disk.
  • 3D graphics with glxgears, the classic spinning gears.
  • The Mesa network, with a ping every millisecond for one minute: 60 000 packets.

If you want to repeat it exactly, these are the commands, each in its own terminal (install the first one with sudo apt install stress-ng):

stress-ng --cpu 6 --io 2 --vm 1 --hdd 1 --timeout 20m
glxgears
sudo chrt 99 ping -i .001 -c 60000 10.10.10.10

Change the 6 in --cpu to the number of cores your processor has. So I wouldn't have to stay up all night, I set up an automatic boot: the computer rebooted with the next configuration, ran the test, saved the screenshot and the numbers, and started again. The eight tests ran in the early hours of November 24, from ten past midnight to quarter past two, and when it finished the computer put the boot options back as they were.

How to read the window

Latency Histogram window for test A: base thread with a maximum of 72.2 microseconds and servo thread with a maximum of 51.1
Test A, the computer exactly as it was after installing. On the left, the parallel port's tick; on the right, the Mesa's.

Each side is a different tick. The bars count how many times the tick arrived with each delay: the one in the middle, zero, is the ticks that arrived on time. The vertical scale is logarithmic (each line is ten times the one below), so the little bars at the sides, even if they look tall, are only a few times.

But forget about the bars, as I told you in the video. What matters are three boxes:

  • max: the worst delay of the whole test. This is the number that decides whether the computer is good enough.
  • sdev: how much the ticks wobble overall. The lower, the more regular.
  • off-chart, the box at the bottom right: how many ticks fell off the chart. If it shows in red, there were bigger delays than the window shows.

What's a good number? For the parallel port, the LinuxCNC documentation says that below about 15 or 20 microseconds the results are very good, that between 30 and 50 you can still work but the maximum speed is disappointing, and that at 100 or more that computer is no good for driving motors through a parallel port. For the Mesa the documentation gives no figure, because its tick is a thousand microseconds. My criterion, the one from the video: below 100, green; between 100 and 200, amber, and you'll need to keep an eye on the network.

The eight tests

I started with the computer as it was and added boot parameters one at a time, to see what each one does. Here's the summary:

Bar chart with the worst delay of the eight tests: on the base thread all red, between 35.2 and 153.1 microseconds; on the servo thread all green, between 43.1 and 73.7
With the Mesa, green in all eight. With a parallel port, none gets below 20.
TestWhat I changed in the boot optionsBase maxBase sdevServo max
ANothing: exactly as it is after installing72.2 (20 off)1,251,1
B+ isolcpus=4.543,91,058,4
C+ irqaffinity=0.3153.1 (1 off)1,048,2
D+ intel_idle.max_cstate=0 processor.max_cstate=141,11,043,1
E+ idle=poll38,60,950,9
FFull tuning: E plus thirteen more parameters38,60,654,2
GF, but with nohz_full and rcu_nocbs on the isolated cores68.4 (4 off)1,173,7
HF, with kernel 6.1 instead of 6.1235,20,351,5

All values are in microseconds. "Off" are the ticks that fell off the chart. The full tuning in F adds these parameters to E: intel_pstate=disable nohz_full=1 rcu_nocbs=1 rcu_nocb_poll threadirqs i915.enable_dc=0 i915.enable_psr=0 i915.enable_fbc=0 i915.enable_guc=0 usbcore.autosuspend=-1 nmi_watchdog=0 intel_iommu=off pcie_aspm=off. It's the kind of list that goes around the forums, and I tried it as is to see whether it really helps.

The eight Latency Histogram windows from tests A to H, side by side
The eight real screenshots, exactly as the computer saved them at the end of each test.

What they taught me

A warning first: it's a single eleven-minute test per configuration, on the same night. It tells you what happened on my computer, it isn't a law. The big differences are clear; those of a few microseconds could change if repeated. That's why you should always measure on yours.

1. With the Mesa, green in every test, whatever I touched

The worst delay of the Mesa's tick was between 43 and 74 microseconds in all eight tests. Out of every thousand, seventy-odd at most. None of the tweaks changed it in any way that matters: the computer as installed already had plenty of headroom. That's the best news for anyone starting out: with a Mesa, an ordinary office computer works without touching anything. All you have to check is that it passes the check-up.

2. For the parallel port, the magic word is isolcpus

With a single word in the boot options, isolcpus=4.5, the worst delay of the fast tick dropped from 72.2 to 43.9 microseconds, and the 20 ticks that fell off the chart went to zero. What it does is reserve two processor cores (here 4 and 5, the last two) so the system doesn't put its own tasks on them. LinuxCNC uses those reserved cores for its ticks, and there they work without anybody bothering them.

3. A single peak ruins a whole test

In test C, sending the interrupts to cores 0 and 3 with irqaffinity=0.3 (careful: the comma picks just those two; for 0 to 3 it would be 0-3), the maximum jumped to 153.1. Look at the box at the bottom: a single tick out of the millions in eleven minutes. If the test had lasted half a minute, that peak wouldn't have shown up, and you'd have been left with a nice, false number. That's why in the video I tell you ten minutes and a coffee. And that's why, if you get an odd number, repeat the test before changing anything.

4. Turning off the processor's naps helps, but it comes at a cost

Limiting the processor's sleep states (D) brought the fast tick down to 41.1, and forcing it never to sleep with idle=poll (E) left it at 38.6. Careful with idle=poll: the cores keep spinning at full speed even when they have nothing to do, so the computer uses more power and gets hotter. In a PC as small as this one, tucked into a cabinet, it's not free.

5. Full tuning makes the tick more regular, not more punctual

With the whole list of parameters (F), the worst delay stayed the same as in E, 38.6. What did change is how regular the tick is: the deviation dropped from 0.9 to 0.6, and on the chart the bell is much narrower. For a parallel port, that means smoother motion. To stop failing, it's not enough.

6. Copying forum lists without measuring can backfire

This is the one that surprised me most. In F, two of the parameters, nohz_full and rcu_nocbs, pointed at core 1, which isn't one of the reserved ones. Theory says they should go on the isolated cores, so in G I put them on 4 and 5. Result: worse across the board. The fast tick went up to 68.4 with four ticks off the chart, and the Mesa's reached 73.7, the worst of the eight tests. The official documentation already warns that these settings depend on each machine and have to be found by testing. I agree: measure before and after every change, and if it doesn't improve, take it out.

7. The newest kernel isn't always the best

Test H is F, but booting with the 6.1 realtime kernel that comes with Debian 12, instead of the more modern 6.12. It was the best of the eight for the fast tick: 35.2 maximum and 0.3 deviation, by far the most regular tick. On this computer, the veteran kernel beats the new one. It's the same thing I told you in the video about computers: newer isn't always better.

Latency Histogram window for test H: base thread with a maximum of 35.2 microseconds and a deviation of 0.3
Test H: the narrowest bell of them all. Even so, 35.2 doesn't reach the parallel port's green.

The conclusion

Same computer, same night: with the Mesa, green first time and in every test; with a parallel port, the best result after tuning everything was 35.2 microseconds, above that 20. It would do for a machine that doesn't need many pulses per second, but with less margin. Tuning helps, a lot, but it doesn't turn an office computer into a machine with a perfect tick. That's why in this series we go with Mesa.

How to set these parameters

Boot parameters are written in the GRUB configuration file, the menu that appears at power-on. Open a terminal and edit it:

sudo nano /etc/default/grub

Find the GRUB_CMDLINE_LINUX_DEFAULT line and add what you want to test inside the quotes, separated by spaces. For example, for test B:

GRUB_CMDLINE_LINUX_DEFAULT="quiet isolcpus=4.5"

Save (Ctrl+O and Ctrl+X in nano), apply the change and reboot:

sudo update-grub
sudo reboot

When it's back up, check that the computer booted with what you added using cat /proc/cmdline. If something gets worse, undo the change in the same file and run sudo update-grub again.

Two details to get it right:

  • Which cores to isolate. Check how many you have with nproc. They are counted from zero, so on a 4-core processor the last two are isolcpus=2.3, and on a 6-core one, 4.5. If your processor has hyperthreading and you don't turn it off in the BIOS, each physical core is two logical ones and you should isolate both siblings; lscpu -e shows which ones belong together.
  • One change at a time. If you add five parameters at once and something gets worse, you won't know which one it was. You've just seen it in test G.

My recipe

  • With a Mesa: the BIOS as I showed you in the video (C-states, power saving, turbo and hyperthreading off), the Intel network card used only for the Mesa, and the ten-minute check-up. If it comes out green, don't touch the boot options. If you want plenty of headroom, isolcpus on the last two cores and measure again.
  • With a parallel port: the same, plus isolcpus, which is what makes the biggest difference. From there, one parameter at a time, measuring, and keep only what improves things. If you can't get below about 20 microseconds, all is not lost: with 30 or 40 you can still work, but the step rate drops. Work out how many pulses per second your machine needs at its top speed and see whether you have enough.
  • Always: repeat the test every time you update the system or the kernel. What comes out green today may not tomorrow.

The network: the other tick

With a Mesa over the network, besides the computer's latency, what matters is how long each packet takes to go and come back. While I was measuring, the ping to the Mesa didn't lose a single one of the 60 000 packets in any of the eight tests: on average they took 0.116 milliseconds, and the worst between 0.25 and 0.36. With a one-millisecond tick, there's plenty of margin.

The network card already had two settings: interrupt coalescing set to zero (rx-usecs 0, so it doesn't wait to bundle packets), which is what the Mesa driver manual recommends, and network power saving (EEE) turned off. How to really measure when each read reaches the Mesa is in The 7i76E in depth, in the DPLL section: on this same Dell, not one read in 780,000 cycles came close to the limit.

Frequently asked questions

How long does the latency test have to run?

At least ten minutes with the computer busy. Big delays are rare: in my test C, the 153-microsecond peak was a single tick in eleven minutes. In half a minute I wouldn't have caught it.

Which number do I have to look at in Latency Histogram?

The max box. With a Mesa, the one on the right, the servo thread: below 100 microseconds, green. With a parallel port, the one on the left, the base thread: ideally below about 15 or 20.

I got amber with the Mesa, between 100 and 200. Is that OK?

Fine to start with, but keep an eye on the network: when you connect the Mesa, check there are no communication errors. Before that, go over the BIOS and try isolcpus, which usually brings it down.

Do I need to touch the boot parameters if I use a Mesa?

Usually not. On my Dell, with the Mesa it came out green in all eight tests, including without touching anything. If it comes out green, leave it as it is.

Is idle=poll worth it?

In my tests it lowered the parallel port's worst delay a little, but the cores keep working flat out all the time and the computer uses more power and runs hotter. With a Mesa I wouldn't use it.

Why doesn't the Mesa's tick improve when I tune everything?

Because it was already fine. The tweaks mainly reduce small, frequent delays, which is what matters for the parallel port's fast tick. The Mesa's, once every millisecond, has plenty of margin and hardly notices.

Can I run the test in a virtual machine or on another computer?

No. Latency depends on each specific computer, its BIOS and its hardware. The test is done on the computer that will go on the machine, with the system it will use.

What now?

If your computer passed the check-up, you have the foundation. The next step is connecting the card: in Mesa 7i76E from scratch you have the step-by-step guide, and in the LinuxCNC from scratch series we go episode by episode. And tell me in the video comments which computer you have, which network card and what number you got: with that we're building a list of computers that work.

Sources

What's next comes out on YouTube

Every week: restoration progress, new parts and what goes wrong, told as it is.

Subscribe to DominicZe