Performance Tuning
Note
This page is still under construction. More information coming soon!
There are two aspects to performance tuning; the operating system performance and the application performance. It’s best to start by focusing on the OS performance, then move to the application performance.
Kernel: Tuning the Linux Network Stack
As of today, most linux distributions still ship with the assumption that they will be multi-user systems, meaning resource limits are set for a normal human doing day-to-day desktop work. By default the Linux network stack is not setup for high speed large file transfer across WAN links. If we want to be able to transmit and receiver data at high speeds, we urge you to tune some network stack parameters to increase the TCP buffer size. This will reduce the overall network latency of your system.
This can be done by creating a file under /etc/sysctl.d/pervices.conf with the following contents:
# For more information, see sysctl.conf(5) and sysctl.d(5).
# Updates for Gnu Radio
net.core.rmem_max = 50000000
net.core.wmem_max = 1000000
kernel.shmmax = 2147483648
Following the above changes, you need to run the following command to reload the file:
$ sudo sysctl --system
Note
Although we don’t recommend it, you can edit these values on the fly with sudo sysctl -w {name of parameter}
Once the parameters are set, you can verify the changes with sudo sysctl {name of parameter}
. For example
$ sudo sysctl net.core.wmem_max
net.core.wmem_max = 1000000
Feel free to experiment with some of the other tweaks listed here. At Per Vices, we have optimized our entire internal network for high speed large file transfer across WAN links. To read more about how you can do the same, check out our application note on the topic.
Filesystem: Use RAM disks
If you are attempting to stream a file to disk, we strongly suggest streaming to RAM first, where you can subsequently carry out any initial pre-processing, prior to moving it to permanent storage.
You can use the free command to determine how much free memory you have, and then allocate some of that as a disk storage, as follows;
$ sudo free -m #report in MB
total used free shared buff/cache available
Mem: 7854 3388 1086 1211 3380 2957
Swap: 9727 1 9726
The available column indicates how much available memory we can allocate. For initial testing, you can likely safely allocate 65%, however this may depend on your applications memory usage.
Note
This command provides an instantaneous view of your memory usage; if your capture application requires additional memory, ensure you factor that into your calculations. Better yet, try and run this command while streaming your file to disk, so that you have an idea of what the run time memory requirements of your application may be.
To create the actual ramdisk, use the mount command with a tmpfs type and the size argument;
$ sudo mkdir /tmp/ramdisk
$ sudo mount -t tmpfs -o size=1922m tmpfs /tmp/ramdisk/
$ sudo chown -R `whoami`:`whoami` /tmp/ramdisk/
Note
Make sure you umount the drive after use!
Application: Prioritize the application
On Linux machines, you may experience dataloss when running at high rates because your capture program is not running all the time. You can run your application at a higher priority with a negative nice level, using the nice command. For example, to adjust the priority of the uhd_find_devices command you would run;
$ sudo nice --adjustment=-15 uhd_find_devices