Files
firezone/rust
Thomas Eizinger d00c3b58cd refactor(connlib): only enable wire logs in debug builds (#10002)
As profiling shows, even if the log target isn't enabled, simply
checking whether or not it is enabled is a significant performance hit.
By guarding these behind `debug_assertions`, I was able to almost
achieve 3.75 Gbits/s locally (when rebased onto #9998). Obviously, this
doesn't quite translate into real-world improvements but it is
nonetheless a welcome improvement.

```
Connecting to host 172.20.0.110, port 5201
[  5] local 100.93.174.92 port 34678 connected to 172.20.0.110 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   401 MBytes  3.37 Gbits/sec   14    644 KBytes       
[  5]   1.00-2.00   sec   448 MBytes  3.76 Gbits/sec    3    976 KBytes       
[  5]   2.00-3.00   sec   453 MBytes  3.80 Gbits/sec   43    979 KBytes       
[  5]   3.00-4.00   sec   449 MBytes  3.77 Gbits/sec   21    911 KBytes       
[  5]   4.00-5.00   sec   452 MBytes  3.79 Gbits/sec    4   1.15 MBytes       
[  5]   5.00-6.00   sec   451 MBytes  3.78 Gbits/sec   81   1.01 MBytes       
[  5]   6.00-7.00   sec   445 MBytes  3.73 Gbits/sec   39    705 KBytes       
[  5]   7.00-8.00   sec   436 MBytes  3.66 Gbits/sec    3   1016 KBytes       
[  5]   8.00-9.00   sec   460 MBytes  3.85 Gbits/sec    1    956 KBytes       
[  5]   9.00-10.00  sec   453 MBytes  3.80 Gbits/sec    0   1.19 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  4.34 GBytes  3.73 Gbits/sec  209             sender
[  5]   0.00-10.00  sec  4.34 GBytes  3.73 Gbits/sec                  receiver
```

I didn't want to remove the `wire` logs entirely because they are quite
useful for debugging. However, they are also exactly this: A debugging
tool. In a production build, we are very unlikely to turn these on which
makes `debug_assertions` a good tool for keeping these around without
interfering with performance.
2025-07-25 12:24:25 +00:00
..
2025-07-22 13:24:58 +00:00
2023-05-10 07:58:32 -07:00

Rust development guide

Firezone uses Rust for all data plane components. This directory contains the Linux and Windows clients, and low-level networking implementations related to STUN/TURN.

We target the last stable release of Rust using rust-toolchain.toml. If you are using rustup, that is automatically handled for you. Otherwise, ensure you have the latest stable version of Rust installed.

Reading Client logs

The Client logs are written as JSONL for machine-readability.

To make them more human-friendly, pipe them through jq like this:

cd path/to/logs  # e.g. `$HOME/.cache/dev.firezone.client/data/logs` on Linux
cat *.log | jq -r '"\(.time) \(.severity) \(.message)"'

Resulting in, e.g.

2024-04-01T18:25:47.237661392Z INFO started log
2024-04-01T18:25:47.238193266Z INFO GIT_VERSION = 1.0.0-pre.11-35-gcc0d43531
2024-04-01T18:25:48.295243016Z INFO No token / actor_name on disk, starting in signed-out state
2024-04-01T18:25:48.295360641Z INFO null

Benchmarking on Linux

The recommended way for benchmarking any of the Rust components is Linux' perf utility. For example, to attach to a running application, do:

  1. Ensure the binary you are profiling is compiled with the release profile.
  2. sudo perf record -g --freq 10000 --pid $(pgrep <your-binary>).
  3. Run the speed test or whatever load-inducing task you want to measure.
  4. sudo perf script > profile.perf
  5. Open profiler.firefox.com and load profile.perf

Instead of attaching to a process with --pid, you can also specify the path to executable directly. That is useful if you want to capture perf data for a test or a micro-benchmark.