====== 13 Performance Monitoring ======
[[kb:labview:perf-mon|Click Here]] for information about performance monitoring on windows.
===== Quick Overview =====
The easiest way to get a quick overview of the resource usage on a NI Linux RT system is the Linux command line tool ''top''.
1. Use ''ssh'' to log into the system. //Windows 10 upwards have ''ssh'' included. No need for tools like ''putty'' anymore.//
$ ssh admin@
NI Linux Real-Time (run mode)
Log in with your NI-Auth credentials.
admin@'s password:
admin@cRIO-9030:~#
2. Run ''top''.
admin@cRIO-9030:~# top
{{:kb:ni-rt:linuxrt:bildschirmfoto_vom_2025-03-04_10-06-57.png?400|}}
==== Alternative ====
A more modern and clear overview about the system resources offers the ''top'' successor ''htop''. But it is not included in the NI Linux RT default installation. If the cRIO has internet access, then it can be installed by the ''opkg'' package manager.
admin@cRIO-9030:~# opkg install htop
{{:kb:ni-rt:linuxrt:bildschirmfoto_vom_2025-03-04_10-09-06.png?400|}}
===== Memory (RAM) =====
Because of the specific memory management of LLinux,it is not so obvious how much memory is in use and how much is free. A common pitfall is the use of the System Property Node ''FreePhysMem'' to get the amount of memory LabVIEW (or other programs) could use. Linux uses extensive buffering of IO-operations that can lead to a huge memory usage. In this case ''FreePhysMem'' will show a very low value (about 16 MB seems the minimum Linux holds back), but there is probably much more memory available if some process asks for it.
{{:kb:ni-rt:linuxrt:pasted:20230413-083351.png}}
To get more detailed information about the memory on a Linux machine the best way it to read the (virtual) file ''/proc/meminfo'' (e.g. with ''cat /proc/meminfo'' on the Bash). A lot of the content is really complicated operating system stuff, for more information see https://access.redhat.com/solutions/406773.
{{:kb:ni-rt:linuxrt:meminfo1.png|Typical output of the file /proc/meminfo}}
Most relevant are the fist three lines:
* ''MemTotal'': Total physical memory (same as ''TotalPhysMem'' in the System Property Node)
* ''MemFree'': Memory not used by anything. Probably this is the value ''FreePhysMem'' in the System Property Node returns. This memory gets consumed from IO-buffers with the time.
* ''MemAvailable'': Is the amount of memory that a process or whatever can allocate until the memory is "full". This is probably the best value to determine the //free memory// on a Linux machine.
Example output of ''/proc/meminfo'' after the cRIO did a lot of IO-operations and the memory is consumed by the Buffer:
{{:kb:ni-rt:linuxrt:meminfo2.png|Typical output of the file /proc/meminfo}}
//HSE Internal:// For easy accessing the Linux memory info from LabVIEW there is a VI ''Get Linux MemInfo.vi'' in the project //HAGEMONITOR-MASTER//. This VI returns all ''meminfo'' content as attributes of a variant. In the future this VI could go into a //RT-Tools//-library.
==== LabVIEW's Memory Footprint ====
A tip courtesy of fellow LabVIEW friend [[https://www.linkedin.com/in/felipepinheirosilva/|Felipe Pinheiro Silva]]: You can read out the amount of memory that the LabVIEW real time application uses.
cat /proc/$(pidof lvrt)/status | grep VmRSS
===== Real Time Trace Viewer =====
Unlike the DETT, the Real Time Trace Viewer only shows timings. //Tip: Have a second project which only contains the components of the code, which are also runnable under windows and use the DETT.//
==== Getting started ====
- place Start and Stop Trace methods in your code
- make sure firewall rules allow communication
- start Realt Time Trace Viewer
- start the RT-Application
{{:kb:ni-rt:linuxrt:pasted:20230413-082537.png}}
{{:kb:ni-rt:linuxrt:pasted:20230413-082456.png}}
{{:kb:ni-rt:linuxrt:pasted:20230413-082702.png}}
===== Additional Resources =====
* [[https://forums.ni.com/t5/LabVIEW-Champion-Discussions/Determinism-jitter-and-timed-structures-on-RT/m-p/4151733#M32515|NI Champions Forum: Determinism, jitter and timed structures on RT]]
* [[https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YHdDCAW&l=de-DE|Monitoring CPU and Memory Usage on Real-Time Embedded Targets]]