The benchmark suite contains several benchmarks that can be used to evaluate the performance of the Asterinas platform. The following benchmarks are supported:
- [Sysbench](#Sysbench)
- [Membench](#Membench)
- [Iperf](#Iperf)
### Sysbench
Sysbench is a scriptable benchmark tool that evaluates system performance. It includes five kinds of tests: CPU, memory, file I/O, mutex performance, and thread performance. Detailed usage and options can be found by using:
```shell
sysbench --help
sysbench --test=<test_name> help
```
Here we list some general commands for evaluation:
```shell
# CPU test
sysbench --test=cpu --cpu-max-prime=<N> --num-threads=<N> run
# Thread test
sysbench --test=threads --thread-yields=<N> --num-threads=<N> --max-time=<N> run
# This is a easy way to generate a file with target size in Linux.
# The following command can create a file named 512K.file with the size 512K.
dd if=/dev/zero of=512K.file bs=1K count=512
```
### Iperf
iPerf is a tool for actively measuring the maximum achievable bandwidth on IP networks. Usage and options are detailed in:
```shell
iperf3 -h
```
iperf can run in the following instructions:
```shell
export HOST_ADDR=127.0.0.1
export HOST_PORT=8888
iperf3 -s -B $HOST_ADDR -p $HOST_PORT -D # Start the server as a daemon
iperf3 -c $HOST_ADDR -p $HOST_PORT # Start the client
```
Note that [a variant of iperf3](https://github.com/stefano-garzarella/iperf-vsock) can measure the performance of `vsock`. But the implemented `vsock` has not been verified to work well in it.
## Add benchmark to benchmark CI
To add a new benchmark to the Asternias Continuous Integration (CI) system, follow these detailed steps:
### Step 1: Add the Benchmark to the `asterinas/test/benchmarks` Directory
-`alert_threshold`: Set the threshold for alerting. If the benchmark result exceeds this threshold, an alert will be triggered. Note that the threshold should usually be greater than 100%. If your results are not stable, set it to a bigger value.
-`alert_tool`: Choose the validation tool to use. The available options are `customBiggerIsBetter` and `customSmallerIsBetter`. Refer to [this](https://github.com/benchmark-action/github-action-benchmark?tab=readme-ov-file#tool-required) for more details. If using `customBiggerIsBetter`, the alert will be triggered when `prev.value / current.value` exceeds the threshold. If using `customSmallerIsBetter`, the alert will be triggered when `current.value / prev.value` exceeds the threshold.
-`search_pattern`: Define a regular expression to extract benchmark results from the output using `awk`. This regular expression is designed to match specific patterns in the output, effectively isolating the benchmark results and producing a set of fragments.
-`result_index`: Specify the index of the result in the extracted output. This field is aligned with `awk`'s action.
-`description`: Provide a brief description of the benchmark.
For example, if the benchmark output is "Syscall average latency: 1000 ns", the `search_pattern` is "Syscall average latency:", and the `result_index` is "4". `awk` will extract "1000" as the benchmark result. See the `awk` [manual](https://www.gnu.org/software/gawk/manual/gawk.html#Getting-Started) for more information.
- Ensure the benchmark runs successfully and check the results in `asterinas/result_getpid.json`.
### Additional Considerations
- **Validation:** After adding and testing the benchmark, ensure that the CI pipeline correctly integrates the new benchmark by triggering a CI build.
- **Documentation:** Update any relevant documentation to include the new benchmark, explaining its purpose and how to interpret its results.
By following these steps, you will successfully integrate a new benchmark into the Asternias CI system, enhancing its capability to evaluate platform performance.