Doris BE存储层Benchmark工具
用途
1. 可以用来测试BE存储层的一些部分(例如segment、page)的性能。根据输入数据构造出指定对象,利用google benchmark进行性能测试。
编译
- 确保环境已经能顺利编译Doris本体,可以参考编译与部署
(opens new window)。 - 运行目录下的
run-be-ut.sh - 编译出的可执行文件位于
./be/ut_build_ASAN/test/tools/benchmark_tool
使用
使用随机生成的数据集进行Segment读取测试
会先利用数据集写入一个segment文件,然后对scan整个segment的耗时进行统计。
./benchmark_tool —operation=SegmentScan —column_type=int,varchar —rows_number=10000 —iterations=0
这里的column_type可以设置表结构,segment层的表结构类型目前支持int、char、varchar、string,char类型的长度为8,varchar和string类型长度限制都为最大值。默认值为int,varchar。
数据集按以下规则生成。
int: 在[1,1000000]内随机。
字符串类型的数据字符集为大小写英文字母,长度根据类型不同。
char: 长度在[1,8]内随机。 varchar: 长度在[1,128]内随机。 string: 长度在[1,100000]内随机。
rows_number表示数据的行数,默认值为10000。
iterations表示迭代次数,benchmark会重复进行测试,然后计算平均耗时。如果iterations为0则表示由benchmark自动选择迭代次数。默认值为10。
使用随机生成的数据集进行Segment写入测试
对将数据集添加进segment并写入磁盘的流程进行耗时统计。
./benchmark_tool —operation=SegmentWrite
使用从文件导入的数据集进行Segment读取测试
./benchmark_tool —operation=SegmentScanByFile —input_file=./sample.dat
这里的input_file为导入的数据集文件。 数据集文件第一行为表结构定义,之后每行分别对应一行数据,每个数据用,隔开。
举例:
1. int,char,varchar
2. 123,hello,world
3. 321,good,bye
类型支持同样为int、char、varchar、string,注意char类型数据长度不能超过8。
使用从文件导入的数据集进行Segment写入测试
./benchmark_tool —operation=SegmentWriteByFile —input_file=./sample.dat
使用随机生成的数据集进行page字典编码测试
./benchmark_tool —operation=BinaryDictPageEncode —rows_number=10000 —iterations=0
会随机生成长度在[1,8]之间的varchar,并对编码进行耗时统计。
使用随机生成的数据集进行page字典解码测试
./benchmark_tool —operation=BinaryDictPageDecode
会随机生成长度在[1,8]之间的varchar并编码,并对解码进行耗时统计。
Custom测试
这里支持用户使用自己编写的函数进行性能测试,具体可以实现在/be/test/tools/benchmark_tool.cpp。 例如实现有:
1. void custom_run_plus() {
2. int p = 100000;
3. int q = 0;
4. while (p--) {
5. q++;
6. if (UNLIKELY(q == 1024)) q = 0;
7. }
8. }
9. void custom_run_mod() {
10. int p = 100000;
11. int q = 0;
12. while (p--) {
13. q++;
14. if (q %= 1024) q = 0;
15. }
16. }
则可以通过注册CustomBenchmark来加入测试。
1. benchmarks.emplace_back(
2. new doris::CustomBenchmark("custom_run_plus", 0,
3. custom_init, custom_run_plus));
4. benchmarks.emplace_back(
5. new doris::CustomBenchmark("custom_run_mod", 0,
6. custom_init, custom_run_mod));
这里的init为每轮测试的初始化步骤(不会计入耗时),如果用户有需要初始化的对象则可以通过CustomBenchmark的派生类来实现。 运行后有如下结果:
1. 2021-08-30T10:29:35+08:00
2. Running ./benchmark_tool
3. Run on (96 X 3100.75 MHz CPU s)
4. CPU Caches:
5. L1 Data 32 KiB (x48)
6. L1 Instruction 32 KiB (x48)
7. L2 Unified 1024 KiB (x48)
8. L3 Unified 33792 KiB (x2)
9. Load Average: 0.55, 0.53, 0.39
10. ----------------------------------------------------------
11. Benchmark Time CPU Iterations
12. ----------------------------------------------------------
13. custom_run_plus 0.812 ms 0.812 ms 861
14. custom_run_mod 1.30 ms 1.30 ms 539
