[SOLVED] Huge latency with PREEMPT_RT

  • arvidb
  • arvidb's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2020 19:26 - 23 Jun 2020 10:16 #169554 by arvidb
I have a newly installed system following the Debian 10.4 Buster Linuxcnc quick and easy install guide.
arvidb@debian:~$ uname -a
Linux debian 4.19.0-9-rt-amd64 #1 SMP PREEMPT RT Debian 4.19.118-2 (2020-04-29) x86_64 GNU/Linux

latency-histogram looks like this:

arvidb@debian:~$ latency-histogram --nobase --servo 250000 --show

I believe most of the outliers are about 2 ms, so it seems I get about 5-10 of these delays each second. If I reset the values I immediately get a max of thereabouts again.

Now I have used this computer to run linuxcnc back in 2014 or thereabouts and I know I managed to get very good latency figures then, with 250 µs base thread.

Any idea where to begin to look? I don't have any of the rt* files under /dev mentioned in the Wiki Troubleshooting section - are these needed for RT_PREEMPT as well as for RTAPI?
arvidb@debian:~$ ls -l /dev/rt*
lrwxrwxrwx 1 root root      4 May 31 21:04 /dev/rtc -> rtc0
crw------- 1 root root 252, 0 May 31 21:04 /dev/rtc0
arvidb@debian:~$ ls -l /dev/RTAI_SHM
ls: cannot access '/dev/RTAI_SHM': No such file or directory

Is the rtapi_app supposed to run with realtime scheduling? It seems it doesn't:
arvidb    7522  5.7  0.3  62616 22760 pts/0    Rl+  21:20   0:00 /usr/bin/tclsh /usr/bin/latency-histogram --nobase --servo 250000 --sh
root      7535  4.3  0.7  48580 48540 ?        SLsl 21:20   0:00 /usr/bin/rtapi_app load threads name1=t_servo period1=250000
arvidb@debian:~$ chrt -p 7535
pid 7535's current scheduling policy: SCHED_OTHER
pid 7535's current scheduling priority: 0

Anything else I should check?
Attachments:
Last edit: 23 Jun 2020 10:16 by arvidb. Reason: Mark as solved

Please Log in or Create an account to join the conversation.

More
31 May 2020 19:46 #169560 by PCW
Replied by PCW on topic Huge latency with PREEMPT_RT
2 ms is huge, Do you have all power management disabled in the BIOS?

Here's an older kernel on a similar system:

freeby.mesanet.com/e8500-4.4.1-rt5.png

but 4.19 should be similar
The following user(s) said Thank You: arvidb

Please Log in or Create an account to join the conversation.

  • arvidb
  • arvidb's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2020 20:39 #169568 by arvidb
Replied by arvidb on topic Huge latency with PREEMPT_RT
Thanks, disabling BIOS power management made a huge difference. I turned off "CPU EIST Function", "Virtualization Technology", and C2 and C1E idle states in BIOS, and got 46 µs max latency while watching YouTube videos:


isolcpus=1 makes the histogram sharper but doesn't seem to affect the outliers.
Attachments:

Please Log in or Create an account to join the conversation.

  • arvidb
  • arvidb's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2020 20:58 - 31 May 2020 20:59 #169572 by arvidb
Replied by arvidb on topic Huge latency with PREEMPT_RT
Some further testing shows that the culprit was the EIST function: Enhanced Intel SpeedStep . With that turned off, but C4, C2 and C1E enabled and a few glxgears running, latency stays below 20 µs. Using Firefox to watch YouTube however still brings some spikes up to about 500-700 µs (but *much* rarer than the continuous 2 ms spikes I got with EIST enabled):
Attachments:
Last edit: 31 May 2020 20:59 by arvidb.

Please Log in or Create an account to join the conversation.

More
31 May 2020 21:57 #169577 by PCW
Replied by PCW on topic Huge latency with PREEMPT_RT
Yes, I think Speed-step basically stalls the processor while it waits for the voltage
and clock speed to change so its a no-no for real-time

Please Log in or Create an account to join the conversation.

  • BeagleBrainz
  • BeagleBrainz's Avatar
  • Visitor
  • Visitor
01 Jun 2020 01:30 #169603 by BeagleBrainz
Replied by BeagleBrainz on topic Huge latency with PREEMPT_RT
If you are going to isolate a core, you are best off isolating 2 cores and they should be on the same die.

Please Log in or Create an account to join the conversation.

  • arvidb
  • arvidb's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
02 Jun 2020 13:43 - 02 Jun 2020 13:53 #169803 by arvidb
Replied by arvidb on topic Huge latency with PREEMPT_RT
BeagleBrainz: Isolating two cores on a dual-core machine without hyperthreading doesn't really make sense to me...?

It seems the remaining outliers happen when I switch focus to the Firefox window (regardless of contents; it's not really YouTube related as I first thought). Not every time, just once in awhile. Turning off the xfce compositor helped a bit by approximately halving the latency of the outliers - but it didn't reduce the number of them. Maybe the occasional 300-350 µs delay is okay for a 1 ms servo thread (no base thread)? Or I might just have to leave Firefox alone while running an NC program...

Maybe I should try some other window environment? Anyone else running xfce successfully? This machine's got an Radeon HD 3870 graphics card, running the radeon driver.

Edit: I should add that this will be a mixed EtherCAT (Omron G5 for X, Y, and spindle) and Mesa (Z - Yaskawa SGDA, and IO) system.
Last edit: 02 Jun 2020 13:53 by arvidb.

Please Log in or Create an account to join the conversation.

More
02 Jun 2020 14:36 #169808 by PCW
Replied by PCW on topic Huge latency with PREEMPT_RT
It might be video board related.
Does the MB have built-in Intel video?
If so I would give that a try

Please Log in or Create an account to join the conversation.

  • BeagleBrainz
  • BeagleBrainz's Avatar
  • Visitor
  • Visitor
02 Jun 2020 19:17 #169859 by BeagleBrainz
Replied by BeagleBrainz on topic Huge latency with PREEMPT_RT
Sorry mate thought it was a quad core. If you have hyper threading enabled disable it.
Also try without any third party video drivers.
XFCE can help with latency.
Do a standard install of Mint 19.x with XFCE then use the kernel and packages from my repo, everything from there has been compiled on Mint so you won’t have any issues with dependencies.
Just use the standard X Windows drivers for your video card.
Try a PS/2 mouse and keyboard if you can, I have personally seen reductions in latency by using non USB keyboard and mouse, I use PS/2 myself rather than USB. USB wireless will mess up latency, actually I do all my latency tests without any wireless. If it is needed only enable it when not running linuxcnc.
If you’re still not getting the required results a new machine might be the only answer. Tommy usually has the answers to that one.

Please Log in or Create an account to join the conversation.

  • arvidb
  • arvidb's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
04 Jun 2020 16:57 #170103 by arvidb
Replied by arvidb on topic Huge latency with PREEMPT_RT
PCW: No built-in graphics unfortunately. I do have another graphics card (that uses the amdgpu instead of the radeon driver) that I could use temporarily for testing though, if it turns out to be necessary.

BeagleBrainz: Thanks for trying to help.
* As I said, and as you can see from Intel's E8400 page , this is a 2-core CPU without hyperthreading.
* As I wrote, I'm using the radeon driver already (i.e. the default, in-kernel driver). No 3rd party drivers installed.
* As you can see from my previous message, I'm already running xfce.

* I'm actually already using a PS/2 keyboard on this computer, but I have no PS/2 mouse to try unfortunately. Also nothing wireless.

Do you have any specific reasons to believe another distribution (Mint) would help, despite running the same kernel, drivers and window manager on the same hardware? Redoing the install is a large undertaking since I'm using EtherCAT - I have to build everything from source. (It's great that you're eager to help, but it mostly feels like you're sending me on wild-goose chases by not taking time to understand the circumstances...)

Please Log in or Create an account to join the conversation.

Time to create page: 0.120 seconds
Powered by Kunena Forum