xref: /cloud-hypervisor/docs/performance_metrics.md (revision e18d32bac29943bdc1f984ca423370d3cfb536b7)
18bef32d3SBo Chen# Performance Metrics
28bef32d3SBo Chen
38bef32d3SBo ChenCloud Hypervisor provides a [performance metrics](https://github.com/cloud-hypervisor/cloud-hypervisor/tree/main/performance-metrics)
48bef32d3SBo Chenbinary for users to generate metrics data from their own
58bef32d3SBo Chenenvironment. This document describes how to generate metrics data
68bef32d3SBo Chenquickly by using Cloud Hypervisor's development script,
78bef32d3SBo Chene.g. `dev_cli.sh`. The only prerequisite is [Docker installation](https://docs.docker.com/engine/install/).
88bef32d3SBo ChenPlease note that upon its first invocation, this script will pull a
98bef32d3SBo Chenfairly large container image.
108bef32d3SBo Chen
11d7e8cd82SSongqian Li## Run the Performance Tests
12d7e8cd82SSongqian Li
138bef32d3SBo ChenTo generate metrics data for all available performance tests (including
148bef32d3SBo Chenboot time, block I/O throughput, and network throughput & latency) and
158bef32d3SBo Chenoutput the result into a json file:
168bef32d3SBo Chen
178bef32d3SBo Chen```
188bef32d3SBo Chen$ ./scripts/dev_cli.sh tests --metrics -- -- --report-file /tmp/metrics.json
198bef32d3SBo Chen```
208bef32d3SBo Chen
218bef32d3SBo ChenTo get a list of available performance tests:
228bef32d3SBo Chen
238bef32d3SBo Chen```
248bef32d3SBo Chen$ ./scripts/dev_cli.sh tests --metrics -- -- --list-tests
258bef32d3SBo Chen```
268bef32d3SBo Chen
278bef32d3SBo ChenTo generate metrics data for selected performance tests, e.g. boot time only:
288bef32d3SBo Chen
298bef32d3SBo Chen```
308bef32d3SBo Chen$ ./scripts/dev_cli.sh tests --metrics -- -- --report-file /tmp/metrics.json --test-filter boot_time
318bef32d3SBo Chen```
32d7e8cd82SSongqian Li
33d7e8cd82SSongqian LiTo set custom timeout or test iterations for all performance tests:
34*e18d32baSSongqian Li
35d7e8cd82SSongqian Li```
36d7e8cd82SSongqian Li$ ./scripts/dev_cli.sh tests --metrics -- -- --timeout 5 --iterations 10
37d7e8cd82SSongqian Li```
38d7e8cd82SSongqian Li
39d7e8cd82SSongqian Li## Performance Tests Details
40d7e8cd82SSongqian Li
41e4aa3617SBo ChenThe following table lists the supported performance tests with default
42e4aa3617SBo Chentimeout and number of iterations. The `timeout` defines the maximum
43e4aa3617SBo Chenexecution time of each test for each iteration. The `iteration` defines
44e4aa3617SBo Chenhow many times a test needs to be executed to generate the final metrics
45e4aa3617SBo Chendata.
46d7e8cd82SSongqian Li
47d7e8cd82SSongqian Li| **Type**   | **Metric**                                 | **Timeout(s)** | **Iterations** |
48d7e8cd82SSongqian Li|------------|--------------------------------------------|----------------|----------------|
49d7e8cd82SSongqian Li| Boot Time  | boot_time_ms                               | 2              | 10             |
50d7e8cd82SSongqian Li|            | boot_time_pmem_ms                          | 2              | 10             |
51d7e8cd82SSongqian Li|            | boot_time_16_vcpus_ms                      | 2              | 10             |
52d7e8cd82SSongqian Li|            | boot_time_16_vcpus_pmem_ms                 | 2              | 10             |
53d7e8cd82SSongqian Li| Virtio Net | virtio_net_latency_us                      | 10             | 5              |
54d7e8cd82SSongqian Li|            | virtio_net_throughput_single_queue_rx_gbps | 10             | 5              |
55d7e8cd82SSongqian Li|            | virtio_net_throughput_single_queue_tx_gbps | 10             | 5              |
56d7e8cd82SSongqian Li|            | virtio_net_throughput_multi_queue_rx_gbps  | 10             | 5              |
57d7e8cd82SSongqian Li|            | virtio_net_throughput_multi_queue_tx_gbps  | 10             | 5              |
58d7e8cd82SSongqian Li| Block      | block_read_MiBps                           | 10             | 5              |
59d7e8cd82SSongqian Li|            | block_write_MiBps                          | 10             | 5              |
60d7e8cd82SSongqian Li|            | block_random_read_MiBps                    | 10             | 5              |
61d7e8cd82SSongqian Li|            | block_random_write_MiBps                   | 10             | 5              |
62d7e8cd82SSongqian Li|            | block_multi_queue_read_MiBps               | 10             | 5              |
63d7e8cd82SSongqian Li|            | block_multi_queue_write_MiBps              | 10             | 5              |
64d7e8cd82SSongqian Li|            | block_multi_queue_random_read_MiBps        | 10             | 5              |
65d7e8cd82SSongqian Li|            | block_multi_queue_random_write_MiBps       | 10             | 5              |
66d7e8cd82SSongqian Li|            | block_read_IOPS                            | 10             | 5              |
67d7e8cd82SSongqian Li|            | block_write_IOPS                           | 10             | 5              |
68d7e8cd82SSongqian Li|            | block_random_read_IOPS                     | 10             | 5              |
69d7e8cd82SSongqian Li|            | block_random_write_IOPS                    | 10             | 5              |
70d7e8cd82SSongqian Li|            | block_multi_queue_read_IOPS                | 10             | 5              |
71d7e8cd82SSongqian Li|            | block_multi_queue_write_IOPS               | 10             | 5              |
72d7e8cd82SSongqian Li|            | block_multi_queue_random_read_IOPS         | 10             | 5              |
73d7e8cd82SSongqian Li|            | block_multi_queue_random_write_IOPS        | 10             | 5              |
74*e18d32baSSongqian Li| Other      | restore_latency_time_ms                    | 2              | 10             |
75d7e8cd82SSongqian Li
76d7e8cd82SSongqian Li## Output Format
77d7e8cd82SSongqian Li
78e4aa3617SBo ChenPerformance-metrics output the result into a json file if `report-file`
79e4aa3617SBo Chenparam is set. The fields included in JSON include:
80d7e8cd82SSongqian Li
81d7e8cd82SSongqian Li| Field Name         | Content                                  |
82d7e8cd82SSongqian Li|--------------------|------------------------------------------|
83d7e8cd82SSongqian Li| git_human_readable | Recent tag information of git repository |
84d7e8cd82SSongqian Li| git_revision       | Commit id of HEAD                        |
85d7e8cd82SSongqian Li| git_commit_date    | Commit date of HEAD                      |
86d7e8cd82SSongqian Li| date               | Date for executing the program           |
87d7e8cd82SSongqian Li| results            | A list of metrics                        |
88d7e8cd82SSongqian Li
89efb92d40SBo Chen## Example
90efb92d40SBo Chen
91efb92d40SBo ChenHere is an example of generating metrics data for the boot time using
92efb92d40SBo Chen`pmem`:
93efb92d40SBo Chen
94efb92d40SBo Chen```bash
95efb92d40SBo Chen$ ./scripts/dev_cli.sh tests --metrics -- -- --test-filter boot_time_pmem_ms
96efb92d40SBo Chen```
97efb92d40SBo Chen
98efb92d40SBo ChenHere is a sample output:
99d7e8cd82SSongqian Li
100d7e8cd82SSongqian Li```json
101d7e8cd82SSongqian Li{
102efb92d40SBo Chen  "git_human_readable": "v40.0",
103efb92d40SBo Chen  "git_revision": "e9b263975786abbf895469b93dfc00f21ce39a88",
104efb92d40SBo Chen  "git_commit_date": "Fri Jun 21 08:40:44 2024 +0000",
105efb92d40SBo Chen  "date": "Tue Jul 16 16:35:29 UTC 2024",
106d7e8cd82SSongqian Li  "results": [
107d7e8cd82SSongqian Li    {
108efb92d40SBo Chen      "name": "boot_time_pmem_ms",
109efb92d40SBo Chen      "mean": 105.9461,
110efb92d40SBo Chen      "std_dev": 7.140993312558129,
111efb92d40SBo Chen      "max": 120.01499999999999,
112efb92d40SBo Chen      "min": 92.37600000000002
113efb92d40SBo Chen    }
114d7e8cd82SSongqian Li  ]
115d7e8cd82SSongqian Li}
116d7e8cd82SSongqian Li```
117efb92d40SBo Chen
118efb92d40SBo ChenNote that the metrics data above is for illustration purpose only and
119efb92d40SBo Chendoes not represent the actual performance of Cloud Hypervisor on your
120efb92d40SBo Chensystem.
121