I am trying to ping between two PCs running Ubuntu 20.04 connected via a Layer-2 switch.
My goal is to get "nearly" stable ping latency.
Similar to other people, I figured out that ping latency (round-trip-time) under a low CPU load gets worse than under a higher CPU load.
https://superuser.com/questions/543503/ping-vs-cpu-usage
https://superuser.com/questions/1189531/kvm-how-is-cpu-usage-related-to-ping
For instance, let say I am pinging from PC-A to PC-B. When PC-B did not run any program other than default programs in the operating system, the ping latency received on PC-A was around 0.5 - 0.6 ms. However, when I used the stress tool to increase CPU load (e.g., stress one core to 80% load), I saw that the ping latency received on PC-A was just around 0.2 - 0.3 ms.
I am sure the problem is not caused by the switch because I also tried the direct cable between PC-A and PC-B and still got the same behavior.
I am pretty sure that this behavior is caused by powersave mode, which is the default CPU indicator. But what surprises me is that when I changed CPU indicator from powersave mode to performance mode using cpufrequtils, the ping latency received on PC-A was still around 0.5 - 0.6 ms (no load on PC-B). The same behavior (the ping latency around 0.2 - 0.3 ms) happened when I increased CPU load. In addition to changing the CPU indicator, I guess I still need to do something else.