|
2 | 2 |
|
3 | 3 | To test performance of KVDK, you can run our benchmark tool "bench", the tool is auto-built along with KVDK library in the build dir.
|
4 | 4 |
|
5 |
| -You can manually run individual benchmark follow the examples as shown bellow, or simply run our basic benchmark script "scripts/run_benchmark.py" to test all the basic read/write performance. |
6 |
| - |
7 |
| -To run the script, you shoulf first build kvdk, then run: |
8 |
| - |
| 5 | +Here is an example to run benchmarks on `string` type: |
| 6 | +```bash |
| 7 | +./bench -path=./kvdk_bench_dir -type=string -num_kv=8388608 -num_operations=1048576 -threads=10 -max_access_threads=64 -value_size=120 -latency=1 |
9 | 8 | ```
|
10 |
| -scripts/run_benchmark.py [data_type] [key distribution] |
11 |
| -``` |
12 |
| - |
13 |
| -data_type: Which data type to benchmark, it can be string/sorted/hash/list/blackhole/all |
14 | 9 |
|
15 |
| -key distribution: Distribution of key of the benchmark workloads, it can be random/zipf/all |
16 |
| -## Fill data to new instance |
17 |
| - |
18 |
| -To test performance, we need to first fill key-value pairs to the KVDK instance. Since KVDK did not support cross-socket access yet, we need to bind bench program to a numa node: |
19 |
| - |
20 |
| - numactl --cpunodebind=0 --membind=0 ./bench -fill=1 -value_size=120 -threads=64 -path=/mnt/pmem0/kvdk -space=274877906944 -num=838860800 -max_write_threads=64 -type=string -populate=1 |
| 10 | +To benchmark performance when KVs are stored on separted memory nodes, we can use `numactl`: |
| 11 | +```bash |
| 12 | +numactl --cpunodebind=0 --membind=0 ./bench -path=./kvdk_bench_dir -type=string -num_kv=8388608 -num_operations=1048576 -threads=10 -max_access_threads=64 -value_size=120 -latency=1 -dest_memory_nodes=1 |
| 13 | +``` |
21 | 14 |
|
22 |
| -This command will fill 83886088 uniform distributed string-type key-value pairs to the KVDK instance that located at /mnt/pmem0/kvdk. |
| 15 | +The above configurations will consume ~7 GB memory. |
23 | 16 |
|
24 | 17 | Explanation of arguments:
|
25 | 18 |
|
26 |
| - -fill: Indicates filling data to a new instance. |
27 |
| - |
28 |
| - -threads: Number of threads of benchmark. |
| 19 | + -path: KVDK initialized here |
29 | 20 |
|
30 |
| - -space: PMem space that allocate to the KVDK instance. |
| 21 | + -type: Type of key-value pairs to benchmark, it can be string/sorted/hash/list/blackhole. |
31 | 22 |
|
32 |
| - -max_access_threads: Max concurrent access threads in the KVDK instance, set it to the number of the hyper-threads for performance consideration. You can call KVDK API with any number of threads, but if your parallel threads more than max_access_threads, the performance will be degraded due to synchronization cost |
| 23 | + -num_kv: Number of KV when benchmarking fill/insert. |
33 | 24 |
|
34 |
| - -type: Type of key-value pairs to benchmark, it can be "string", "hash" or "sorted". |
| 25 | + -num_operations: Number of operations running benchmarks other than fill/insert. |
35 | 26 |
|
36 |
| - -populate: Populate pmem space while creating new KVDK instance for best write performance in runtime, see "include/kvdk/configs.hpp" for explanation. |
| 27 | + -threads: Number of threads of benchmark. `max_access_threads` will override this when benchmarking `fill`. |
37 | 28 |
|
38 |
| -## Test read/write performance |
| 29 | + -max_access_threads: Max concurrent access threads in the KVDK instance, set it to the number of the hyper-threads for performance consideration. You can call KVDK API with any number of threads, but if your parallel threads more than max_access_threads, the performance will be degraded due to synchronization cost. |
39 | 30 |
|
40 |
| -### Read performance |
| 31 | + -value_size: Value length of values in Byte. |
41 | 32 |
|
42 |
| -After fill the instance, we can test read performance with the command below: |
| 33 | + -latency: Print latencies of operations or not. |
43 | 34 |
|
44 |
| - numactl --cpunodebind=0 --membind=0 ./bench -fill=0 -time=10 -value_size=120 -threads=64 -read_ratio=1 -existing_keys_ratio=1 -path=/mnt/pmem0/kvdk -space=274877906944 -num=838860800 -max_write_threads=64 -type=string |
45 |
| - |
46 |
| -This will read key-value pairs from the KVDK instance with 48 threads in 10 seconds. |
47 |
| - |
48 |
| -Explanation of arguments: |
49 |
| - |
50 |
| - -read_ratio: Ratio of read threads among benchmark threads, for example, if set it to 0.5, then there will be 24 write threads and 24 read threads. |
51 |
| - |
52 |
| - -existing_keys_ratio: Ratio of keys among key-value pairs to read that already filled in the instance. For example, if set it to 0.5, then 50% read operations will return NotFound. |
53 |
| - |
54 |
| -Benchmark tool will print performance stats to stdout, include throughput in each second and average ops: |
55 |
| - |
56 |
| - $numactl --cpunodebind=0 --membind=0 ./bench -fill=0 -time=10 -value_size=120 -threads=64 -read_ratio=1 -existing_keys_ratio=1 -path=/mnt/pmem0/kvdk -space=274877906944 -num=838860800 -max_write_threads=64 -type=string |
57 |
| - |
58 |
| - [LOG] time 0 ms: Initializing PMem size 274877906944 in file /mnt/pmem0/kvdk/data |
59 |
| - [LOG] time 1864 ms: Map pmem space done |
60 |
| - [LOG] time 9033 ms: In restoring: iterated 840882543 records |
61 |
| - init 0 write threads |
62 |
| - init 64 read threads |
63 |
| - ------- ops in seconds ----------- |
64 |
| - time (ms), read ops, not found, write ops, total read, total write |
65 |
| - 1000 73691000 0 0 73691000 0 |
66 |
| - 2001 73613000 0 0 147304000 0 |
67 |
| - 3002 73643000 0 0 220947000 0 |
68 |
| - 4003 73656000 0 0 294603000 0 |
69 |
| - 5004 73675000 0 0 368278000 0 |
70 |
| - 6005 73667000 0 0 441945000 0 |
71 |
| - 7006 73699000 0 0 515644000 0 |
72 |
| - 8007 73647000 0 0 589291000 0 |
73 |
| - 9008 73634000 0 0 662925000 0 |
74 |
| - 10009 73677000 0 0 736602000 0 |
75 |
| - finish bench |
76 |
| - ------------ statistics ------------ |
77 |
| - read ops 73660400, write ops 0 |
78 |
| - [LOG] time 19051 ms: instance closed |
79 |
| - |
80 |
| - |
81 |
| - |
82 |
| -### Write performance |
83 |
| - |
84 |
| -Similarily, to test write performance, we can simply modify "read_ratio": |
85 |
| - |
86 |
| - numactl --cpunodebind=0 --membind=0 ./bench -fill=0 -time=10 -value_size=120 -threads=64 -read_ratio=0 -existing_keys_ratio=0 -path=/mnt/pmem0/kvdk -space=274877906944 -num=838860800 -max_write_threads=64 -type=string |
87 |
| - |
88 |
| -This command will insert new key-value pairs to the KVDK instance in 10 seconds. Likely wise, by modify "existing_keys_ratio", we can control how many write operations are updates. |
89 |
| - |
90 |
| - $numactl --cpunodebind=0 --membind=0 ./bench -fill=0 -time=10 -value_size=120 -threads=64 -read_ratio=0 -existing_keys_ratio=0 -path=/mnt/pmem0/kvdk -space=274877906944 -num=838860800 -max_write_threads=64 -type=string |
91 |
| - |
92 |
| - [LOG] time 0 ms: Initializing PMem size 274877906944 in file /mnt/pmem0/kvdk/data |
93 |
| - [LOG] time 1865 ms: Map pmem space done |
94 |
| - [LOG] time 9015 ms: In restoring: iterated 840882543 records |
95 |
| - init 64 write threads |
96 |
| - init 0 read threads |
97 |
| - ------- ops in seconds ----------- |
98 |
| - time (ms), read ops, not found, write ops, total read, total write |
99 |
| - 1000 0 0 50610000 0 50610000 |
100 |
| - 2007 0 0 50053000 0 100663000 |
101 |
| - 3016 0 0 49669000 0 150332000 |
102 |
| - 4017 0 0 49048000 0 199380000 |
103 |
| - 5018 0 0 48540000 0 247920000 |
104 |
| - 6022 0 0 48210000 0 296130000 |
105 |
| - 7023 0 0 47725000 0 343855000 |
106 |
| - 8024 0 0 47354000 0 391209000 |
107 |
| - 9027 0 0 47080000 0 438289000 |
108 |
| - 10028 0 0 46544000 0 484833000 |
109 |
| - finish bench |
110 |
| - ------------ statistics ------------ |
111 |
| - read ops 0, write ops 48483400 |
112 |
| - [LOG] time 19055 ms: instance closed |
113 |
| - |
114 |
| - |
115 |
| -### Stat latencies |
116 |
| - |
117 |
| -We can also stat latency information by add "-latency=1" to the benchmark command. |
118 |
| - |
119 |
| - $ numactl --cpunodebind=0 --membind=0 ./bench -fill=0 -time=10 -value_size=120 -threads=64 -read_ratio=0.5 -existing_keys_ratio=1 -path=/mnt/pmem0/kvdk -space=274877906944 -num=838860800 -max_write_threads=64 -type=string -latency=1 |
120 |
| - |
121 |
| - [LOG] time 0 ms: Initializing PMem size 274877906944 in file /mnt/pmem0/kvdk/data |
122 |
| - [LOG] time 1869 ms: Map pmem space done |
123 |
| - [LOG] time 14963 ms: In restoring: iterated 1323729106 records |
124 |
| - calculate latencies |
125 |
| - init 6 write threads |
126 |
| - init 58 read threads |
127 |
| - ------- ops in seconds ----------- |
128 |
| - time (ms), read ops, not found, write ops, total read, total write |
129 |
| - 1000 62763000 0 3933000 62763000 3933000 |
130 |
| - 2001 62297000 0 4303000 125060000 8236000 |
131 |
| - 3002 62190000 0 4530000 187250000 12766000 |
132 |
| - 4003 62194000 0 4530000 249444000 17296000 |
133 |
| - 5004 62206000 0 4531000 311650000 21827000 |
134 |
| - 6005 62172000 0 4527000 373822000 26354000 |
135 |
| - 7006 62194000 0 4530000 436016000 30884000 |
136 |
| - 8007 62227000 0 4535000 498243000 35419000 |
137 |
| - 9008 62196000 0 4529000 560439000 39948000 |
138 |
| - 10009 62190000 0 4527000 622629000 44475000 |
139 |
| - finish bench |
140 |
| - ------------ statistics ------------ |
141 |
| - read ops 62263100, write ops 4447500 |
142 |
| - read lantencies (us): Avg: 0.89, P50: 0.83, P99: 1.54, P99.5: 1.67, P99.9: 2.77, P99.99: 4.20 |
143 |
| - write lantencies (us): Avg: 0.09, P50: 1.22, P99: 2.64, P99.5: 3.25, P99.9: 4.22, P99.99: 5.35 |
144 |
| - [LOG] time 28382 ms: instance closed |
| 35 | + -dest_memory_nodes: The memory nodes to store KV data. |
145 | 36 |
|
146 | 37 | ## More configurations
|
147 | 38 |
|
148 |
| -For more configurations of the benchmark tool, please reference to "benchmark/bench.cpp" and "scripts/basic_benchmarks.py". |
149 |
| - |
150 |
| - |
151 |
| - |
152 |
| - |
| 39 | +For more configurations of the benchmark tool, please reference to "benchmark/bench.cpp". |
0 commit comments