In the previous post I managed to get wireguard compiled into the kernel. This raises the question: If and if so by how much is the kernel implementation faster than the wg-go implementation, what are the relative overheads compared to a raw connection.
To this end I created a benchmark script to test the connection over the USB Ethernet to eliminate wifi bottlenecks.
The full output from the run is shown at the end of this post.
Initially I tested the installed wireguard-go wireguard-go v0.0.20220316 against the installed kernel version from the previous post: I have since updated to v 7.0 : 6.7.0-rc4-msm8916-wireguard-g6cc2342c6a72.7.0.0-msm8916-v70-wg-gea3a5c52f8f6-dirty.

Benchmark Summary
| Item | Value |
|---|---|
| Device | openstick (192.168.200.1) |
| Device kernel | 7.0.0-msm8916-v70-wg-gea3a5c52f8f6-dirty |
| Device wireguard-go | wireguard-go v0.0.20220316 |
| Host kernel | 7.1.5-76070105-generic |
| Host backend | kernel |
| USB link | enx469d595d8f1f: 192.168.200.103 ↔ 192.168.200.1 |
| Tunnel networks | 10.8.0.0/24, fd08::/64 |
| Tunnel MTU | 1420 |
| Device backends | none, kernel, wireguard-go |
| IP families | IPv4, IPv6 |
| Repetitions | 3 |
| SHA-256 verify | no |
Bulk TCP
Largest transfer size (64M), all data types combined.
| Backend | Family | Dir | Mbit/s | % of raw USB | dev cpu% | dev s/GB |
|---|---|---|---|---|---|---|
none | IPv4 | down | 106.44 | 100.0% | 14.8 | 44.7 |
none | IPv4 | up | 105.86 | 100.0% | 28.5 | 84.8 |
none | IPv6 | down | 104.63 | 100.0% | 16.8 | 51.4 |
none | IPv6 | up | 103.82 | 100.0% | 27.2 | 83.1 |
kernel | IPv4 | down | 97.21 | 91.3% | 29.0 | 94.2 |
kernel | IPv4 | up | 100.29 | 94.7% | 42.1 | 127.1 |
kernel | IPv6 | down | 96.32 | 92.1% | 28.3 | 91.9 |
kernel | IPv6 | up | 99.01 | 95.4% | 41.4 | 126.2 |
wireguard-go | IPv4 | down | 96.04 | 90.2% | 62.5 | 191.3 |
wireguard-go | IPv4 | up | 100.02 | 94.5% | 71.8 | 213.1 |
wireguard-go | IPv6 | down | 94.37 | 90.2% | 62.2 | 193.3 |
wireguard-go | IPv6 | up | 98.84 | 95.2% | 71.5 | 213.4 |
This summary table shows that the kernel implementation is significantly faster and more efficient than the old wireguard-go. with significantly lower CPU usage. A repeat with the latest go implementation will follow. While the speed lost through the kernel implementation in this test is just shy of 6.6%, the loss from the go implementation is 7.8%, a noticeable change but not that extreme the CPU usage is nearly double going from 35% to 67% (over a baseline of 22% cpu usage without a tunnel). On a resource constrained system like this little model that makes a huge difference if you are trying to also run other processes at the same time. (this was an early run, some tests have changed slightly)
The encryption overhead is especially noticeable for small UDP packets. And once the IPv6 packets start to get fragmented where the IPv4 packets do not the reassembly adds significant overheads. the above table was made using IPv4 transport only. An updated version of the benchmark is running right now that compares a full IPv6 stack.
When transferring over UDP from the host to the stick the packet loss was incredibly high often over 50%. I suspect this is just the device being overloaded with data. This was most noticeable on large UDP packets. The loss was much lower in the other direction.

I also noticed some weird spiking during testing that some runs would run at a completely different rate to others (this was during UDP testing), but at two distinct levels. I am not sure if this has something to do with the loss percentage.
Below are some graphs from the latest benchmark run.

As we can see there is a noticeable difference between up and down traffic.





The full results are attached below if you are interested:
This includes the script I used to plot the graphs above as an HTML file you can load the results into