<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/</id><updated>2022-11-07T21:32:23.106000Z</updated><subtitle>Recent posts to Good improvement in linux Real Time.</subtitle><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4bf0/33ae/938d" rel="alternate"/><published>2022-11-07T21:32:23.106000Z</published><updated>2022-11-07T21:32:23.106000Z</updated><author><name>paho</name><uri>https://forge.codesys.com/u/paho/</uri></author><id>https://forge.codesys.com3b19cb846a62b432d0b23814e98de6a5c5db7033</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Currently on Debian 11, but somehow i've managed to get it working with the steps you suggested.&lt;br/&gt;
On a i5-11th Gen. iEi DRPC industrial PC it's working for a few weeks without any problems.&lt;br/&gt;
The cores 2+3 are isolated from the rest and there is no conflict on the CODESYS runtime with the NodeJS/MongoDB server, also on heavy load.&lt;/p&gt;
&lt;p&gt;This thread should be official included to the CODESYS FAQ, because of the rare infos about the Linux runtime.&lt;/p&gt;
&lt;p&gt;Thanks to everyone here, especially &lt;a class="user-mention" href="/u/mondinmr/"&gt;@mondinmr&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4bf0/1519" rel="alternate"/><published>2022-10-25T08:59:48.588000Z</published><updated>2022-10-25T08:59:48.588000Z</updated><author><name>mondinmr</name><uri>https://forge.codesys.com/u/mondinmr/</uri></author><id>https://forge.codesys.com0a4d5be0a3cf1105a90cf1e4f8d7a84a33175717</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Here a i5 5th gen.&lt;br/&gt;
On same PC there are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Runtime with ethercat master&lt;/li&gt;
&lt;li&gt;Qt/C++ Settings manager, Gateway, logger and recorder/player to provide and store program recordings.&lt;/li&gt;
&lt;li&gt;Qt/C++ HMI on LxQt Desktop.&lt;/li&gt;
&lt;li&gt;X2GO remote desktop connected via VPN.&lt;/li&gt;
&lt;li&gt;OpenVPN Server.&lt;/li&gt;
&lt;li&gt;MySQL server for programs management and messages management.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can see, after about 2 hours max jitter is 45µs, but it remain many time under 10µs, there are spikes of 15-20µs in about 10-15 minutes and 30-45µs in about 30 minutes. &lt;/p&gt;
&lt;p&gt;We have many machines working in this configuration out in last 3 years.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4bf0/33ae" rel="alternate"/><published>2022-10-20T09:21:00.759000Z</published><updated>2022-10-20T09:21:00.759000Z</updated><author><name>mondinmr</name><uri>https://forge.codesys.com/u/mondinmr/</uri></author><id>https://forge.codesys.comd7ef4d1f5227a89a75d2223ee761186114134c2e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Also in Debian 10? In many machines using kernel 4.19.xRT Is working good. On medium load we have some spike after many hours but it's remaining &amp;lt;50-100us depending on machine.&lt;br/&gt;
Results obtained with LXQT, a heavy Qt/C++ application doing HMI and IoT works and a openVPN service running on other cores. &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4bf0" rel="alternate"/><published>2022-10-14T07:09:14.375000Z</published><updated>2022-10-14T07:09:14.375000Z</updated><author><name>paho</name><uri>https://forge.codesys.com/u/paho/</uri></author><id>https://forge.codesys.comdb3a44ed57de514d3f73291672cb41e16f02871f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;i did everything that &lt;strong&gt;mondinmr&lt;/strong&gt; wrote in his tutorial above. If i'm starting the codesyscontrol and let my program run, there is a max. jitter with ~15us.&lt;br/&gt;
If i let the program run for lets say a few hours over night, there is a max. jitter with 300us. Is this because you cannot remove all IRQs from the two isolated cores and something is blocking the cycle?&lt;/p&gt;
&lt;p&gt;I switched yesterday from Debian 10 to Debian 11 with RT patch (with all the tweaks from above) and except from that i think the IEC-Tasks and everything else works perfect.&lt;br/&gt;
Also the Intel I225-LM is working great with my TCP/IP Modbus controller with Debian 11 out of the box.&lt;/p&gt;
&lt;p&gt;Greetings,&lt;br/&gt;
paho&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4fad/8cd8/96b8" rel="alternate"/><published>2022-08-18T15:05:42.020000Z</published><updated>2022-08-18T15:05:42.020000Z</updated><author><name>paho</name><uri>https://forge.codesys.com/u/paho/</uri></author><id>https://forge.codesys.com6036677765767c95b7869f12e8af935b5e10ac39</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Great, with that tutorial i've made it. Working like charm.&lt;/p&gt;
&lt;p&gt;Another question, because there is a current project where the client asked me if we can put the CODESYS Runtime on a virtual system (because they've a big server farm with thousands of virtual systems) with soft real time (cycle times of 0,5-1ms)? Did anyone encountered something like this before?&lt;/p&gt;
&lt;p&gt;Thanks a lot!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#effa" rel="alternate"/><published>2022-08-16T07:16:22.497000Z</published><updated>2022-08-16T07:16:22.497000Z</updated><author><name>Ingo</name><uri>https://forge.codesys.com/u/ingo/</uri></author><id>https://forge.codesys.comd1b26866f7ea2050f78375be81afe44e9abd7f7f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi &lt;a class="user-mention" href="/u/mondinmr/"&gt;@mondinmr&lt;/a&gt;,&lt;br/&gt;
thanks again for this nice summary about realtime optimizations!&lt;br/&gt;
And also thanks for the outlook regarding the Rasperry Pi 4.&lt;/p&gt;
&lt;p&gt;Looking forward to hear from that.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hint:&lt;/strong&gt; If you post the Raspberry Pi results in CODESYS Talk, maybe use a different topic for RPI. Then it will be easier found.&lt;/p&gt;
&lt;p&gt;Don't know if you found this already, but from CODESYS there is an FAQ, giving some optimization hints: &lt;a href="https://faq.codesys.com/pages/viewpage.action?pageId=122748972" rel="nofollow"&gt;https://faq.codesys.com/pages/viewpage.action?pageId=122748972&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And soon, there will be a new chapter in the online help.&lt;/p&gt;
&lt;p&gt;Keep up the great work!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br/&gt;
Ingo&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4fad/8cd8" rel="alternate"/><published>2022-08-12T07:58:37.007000Z</published><updated>2022-08-12T07:58:37.007000Z</updated><author><name>mondinmr</name><uri>https://forge.codesys.com/u/mondinmr/</uri></author><id>https://forge.codesys.com25b49ad4e969113f5d90dab51963541a5091ce7a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi! In latest versions of Codesys Control for linux everything is improved very well!&lt;/p&gt;
&lt;p&gt;Only a few steps are required to obtain very low jitter on many CPUs.&lt;/p&gt;
&lt;p&gt;0 - Use RT Preempt kernel (Debian has a precompiled RT kernel)&lt;/p&gt;
&lt;p&gt;1 - DISABLE HYPERTHREADING FROM BIOS!!!&lt;/p&gt;
&lt;p&gt;2 -  In INTEL CPUS change in /etc/default/grub this line:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;GRUB_CMDLINE_LINUX_DEFAULT="isolcpus=2,3 processor.max_cstate=1 intel_idle.max_cstate=0 acpi_irq_nobalance noirqbalance quiet"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;isolcpus&lt;/strong&gt; detach cores 2 and 3 from Linux KERNEL.&lt;br/&gt;
High cores work better for me.&lt;br/&gt;
&lt;strong&gt;processor.max_cstate&lt;/strong&gt; and &lt;strong&gt;intel_idle.max_cstate&lt;/strong&gt; tune power management.&lt;br/&gt;
&lt;strong&gt;acpi_irq_nobalance noirqbalance&lt;/strong&gt; avoid IRQs balancing. This has a big impact on jitter.&lt;/p&gt;
&lt;p&gt;3 - Use folowing script to push all IRQs possible on low cores use mask 1 or 3 to use cores 0 and 1 and leave alone 2 and 3:&lt;/p&gt;
&lt;table class="codehilitetable"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$#&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Syntax: &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt; cpu_hex_mask"&lt;/span&gt;
                &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Mask is 1-F where 1 is CPU0"&lt;/span&gt;
                &lt;span class="nb"&gt;echo&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; i in /proc/irq/*&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -d &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
                &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; &amp;gt; &lt;span class="nv"&gt;$i&lt;/span&gt;/smp_affinity &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
                &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; &amp;gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
        &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;4 - Modify /etc/initrd/codesyscontrol do_status:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;    do_status&lt;/span&gt;
&lt;span class="err"&gt;    if [ $? -eq 0 ]; then&lt;/span&gt;
&lt;span class="err"&gt;        rm $PIDFILE&lt;/span&gt;
&lt;span class="err"&gt;        echo "Error: Failed to start codesyscontrol"&lt;/span&gt;
&lt;span class="err"&gt;        exit 1&lt;/span&gt;
&lt;span class="err"&gt;    else&lt;/span&gt;
&lt;span class="err"&gt;        PID=$(cat $PIDFILE)&lt;/span&gt;
&lt;span class="err"&gt;        echo performance &amp;gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor&lt;/span&gt;
&lt;span class="err"&gt;        echo performance &amp;gt; /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor&lt;/span&gt;
&lt;span class="err"&gt;        echo performance &amp;gt; /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor&lt;/span&gt;
&lt;span class="err"&gt;        echo performance &amp;gt; /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor&lt;/span&gt;
&lt;span class="err"&gt;        taskset -p 4 $PID &amp;gt;&amp;gt;/root/codelog.txt&lt;/span&gt;
&lt;span class="err"&gt;        echo 0 &amp;gt; /proc/sys/kernel/numa_balancing&lt;/span&gt;
&lt;span class="err"&gt;        echo never &amp;gt; /sys/kernel/mm/transparent_hugepage/enabled&lt;/span&gt;
&lt;span class="err"&gt;        echo 0 &amp;gt; /sys/kernel/mm/ksm/run&lt;/span&gt;
&lt;span class="err"&gt;        echo "codesyscontrol started"&lt;/span&gt;
&lt;span class="err"&gt;    fi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This move codesysbin to core 2, fix CPU frequency to maximum (This is very important for jitter) and make some irq tuning.&lt;/p&gt;
&lt;p&gt;5 - In codesys go in TaskGroup and select CORE 3 for all tasks. Now you have GNU/Linux OS on cores 0 and 1, only CODESYS runtime on core 2 and only IEC tasks on core 3.&lt;/p&gt;
&lt;p&gt;&lt;img src="./attachment/attachment.png" width="50%"/&gt;&lt;/p&gt;
&lt;p&gt;In 4.2 and 4.4.1 runtimes max jitter shoud be from 13µs to 40µs depending on luky of your hardware configuration.&lt;/p&gt;
&lt;p&gt;We have many production machines out in different hw configurations (J1900, i5 5th gen, i5 6th gen) and jitter max never go over 40µs. In luky hardware remain under 13µs.&lt;/p&gt;
&lt;p&gt;There many wonderful things about linux runtime:&lt;/p&gt;
&lt;p&gt;1 - Is working in User Space, this make all stack exceptions bring debugger to yellow row indicating its.&lt;br/&gt;
In Windows RTE that is working in kernel space many time severe exceptions crash all device bringing Windows to reboot or to a blue screen of death. I such cases is very hard find error causes.&lt;br/&gt;
Kernel space is painful for safety of IoT.&lt;/p&gt;
&lt;p&gt;2 - All INTEL and Realtek chips working on a PCIe line work in ethercat very well also in 250µs cyclic with standard linux kernel modules (drivers)!&lt;/p&gt;
&lt;p&gt;3 - You can develop external components in C.&lt;/p&gt;
&lt;p&gt;4 - GNU/Linux is hundreds time much safe and stable in production machines, you don't fall in painful Windows 10/11 update system that is became a nightmare in industrial automation!&lt;/p&gt;
&lt;p&gt;As side note, we are also testing ARM 64 runtime in Raspberry 4, with a our distro built in yocto.&lt;br/&gt;
Raspberry 4 has ethernet connector on PCIe line in contrast to USB of old Raspberries until 3.&lt;br/&gt;
It's impressive! We tested an application for many hours, using a Ethercat SLAVE board SPI, a C++ application for slave, CODESYS as master on native ethernet connector connected master to slave on itself rpi and obtained a max jitter of 19µs in a 300µs cyclic.&lt;br/&gt;
In only master configuration I controlled a Lenze Servo Inverter down to 250µs cyclic. &lt;/p&gt;
&lt;p&gt;The only difference in RPI 4 is kernel command line of step 2, all other steps remain unaltered.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#4fad" rel="alternate"/><published>2022-08-03T18:58:11.956000Z</published><updated>2022-08-03T18:58:11.956000Z</updated><author><name>paho</name><uri>https://forge.codesys.com/u/paho/</uri></author><id>https://forge.codesys.comef5ddd205de60dadc5a9b835ce3aa45721e73ff7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Good to hear that, because i'm using the Linux SL on my i5 IPC too. Having Debian 4.19 with RT Preempt Kernel. The max. Jitter is 272us.&lt;br/&gt;
Are there additionally adjustments to do in the OS? My application is now fixed at CPU1 and i want to know if using the multicore brings really an improvement...&lt;/p&gt;
&lt;p&gt;For my application, i'm not that unhappy with the jitter, but i'm using MODBUS TCP/IP bus couplers from WAGO and if i'm going to send data in short intervals (like every 50ms) then i can see some delays (not lost packets or erros) - i can see that on a LED that i'm going to switch on and of every 50ms. From time to time it seems that there is a delay of one 0/1 cycle, like a pause of 50ms.&lt;br/&gt;
The coupler is connected with a seperate ethernet interface and static configuration, point-to-point connection with a patchcable.&lt;/p&gt;
&lt;p&gt;I think this can also be some network driver issue... maybe someone has a suggestion for my problem.&lt;/p&gt;
&lt;p&gt;Thank you,&lt;br/&gt;
paho&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#90fb" rel="alternate"/><published>2022-03-04T14:51:52.408000Z</published><updated>2022-03-04T14:51:52.408000Z</updated><author><name>mondinmr</name><uri>https://forge.codesys.com/u/mondinmr/</uri></author><id>https://forge.codesys.com8f4d525fabb1391e40444978953dfc177a51b79a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Raspberry PI4, debian 64bit, Kernel RT stock from debian repo.&lt;br/&gt;
Runtime SL ARM64.&lt;br/&gt;
A little tuning in kernel parameters and CPU pinning.&lt;br/&gt;
Jitter &amp;lt;= 52µs with ethercat on native adapter.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Good improvement in linux Real Time.</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/dd3a2052c9/?limit=25#1f0b" rel="alternate"/><published>2022-01-06T09:50:01.271000Z</published><updated>2022-01-06T09:50:01.271000Z</updated><author><name>mikuroung</name><uri>https://forge.codesys.com/u/mikuroung/</uri></author><id>https://forge.codesys.coma4235b65f33edaa7a76db4a3a8be57a1701c9303</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;thank a lot for your answer.&lt;br/&gt;
This is very helpful for me&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>