Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add pika benchmark tools #2663

Merged
merged 19 commits into from
May 29, 2024

Conversation

luky116
Copy link
Collaborator

@luky116 luky116 commented May 21, 2024

添加 pika benchark 工具,旨在提升压测效率,并输出可视化的统计图表。目前支持了以下的压测 case:
1、常用命令的百分位延时统计图:

cmd_latency

2、常用命令的 OPS 统计图

cmd_ops

3、不同读写场景下的百分位延时统计图

rw_latency

4、不同读写场景下的 OPS 统计图

rw_ops

@github-actions github-actions bot added Invalid PR Title ✏️ Feature New feature or request 📒 Documentation Improvements or additions to documentation labels May 21, 2024
@luky116 luky116 changed the title add pika benchmark test: add pika benchmark May 21, 2024
@github-actions github-actions bot added the 🧹 Updates This will not be worked on label May 21, 2024
```

3. After the stress test is completed, parse and format the stress test data. First execute go build to compile and convert the program:
```go
Copy link
Contributor

@baerwang baerwang May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shell

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

```

Next, execute the program to format the stress test data. If the output folder does not exist, it needs to be created manually in advance:
```go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

./parser -in_dir=$(pwd)/bench_data -out_dir=$(pwd)/parsed_data
```
4. Use a python script to generate a statistical chart image from the data:
```go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

本工具提供了常用指标的压测命令,并支持将压测结果一键生成可视化的 svg 格式的统计图,提升压测效率。使用步骤如下:
1、首先,压测工具使用了 Redis 官方的 memtier_benchmark,所以要选把这个工具安装好,安装流程参考官方文档:[https://github.com/RedisLabs/memtier_benchmark](https://github.com/RedisLabs/memtier_benchmark)。
2、接下来启动一个 Pika 进程,然后执行压测脚本进行压测:
```go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

sh pika_benchmark.sh -host 127.0.0.1 -port 9221
```
目前可支持以下测试参数:
```go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

1. First of all, the stress testing tool uses Redis’ official memtier_benchmark, so you must choose to install this tool. For the installation process, please refer to the official documentation: [https://github.com/RedisLabs/memtier_benchmark](https://github.com /RedisLabs/memtier_benchmark).
2. Next, start a Pika process, and then execute the stress test script to perform the stress test:

```go
Copy link
Contributor

@baerwang baerwang May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

sh pika_benchmark.sh -host 127.0.0.1 -port 9221
```
Currently the following test parameters are supported:
```go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

}

func writeLantencyFile(path string, data ParsedLatencyData) {
fileName := path + "/" + data.Title
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filepath.Join(path,data.Title)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filepath.Join(path,data.Title)

done

}

func writeOpsFile(path string, data ParsedOpsData) {
fileName := path + "/" + data.Title
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

done

}
defer file.Close()

var (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var (
	hasAllStatsLine                   bool
	hasRequestLatencyDistributionLine bool
	hasDividingLineBegin              bool
	res                               = newBenchResult(name, usePrefix)
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var (
	hasAllStatsLine                   bool
	hasRequestLatencyDistributionLine bool
	hasDividingLineBegin              bool
	res                               = newBenchResult(name, usePrefix)
)

done

cmd_zadd=$pwd/bench_data/cmd_zadd.txt
cmd_range=$pwd/bench_data/cmd_zrange.txt

memtier_benchmark --server=$server --port=$port --clients=10 --requests=$requests --data-size=32 --threads=20 --ratio=0:10 --select-db=0 > $rw_0r10w
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是没用传参数的值?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是没用传参数的值?

done

@luky116 luky116 changed the title test: add pika benchmark test: add pika benchmark tools May 21, 2024
@luky116 luky116 removed the ✏️ Feature New feature or request label May 23, 2024
@luky116 luky116 added test benchmark and removed 🧹 Updates This will not be worked on 📒 Documentation Improvements or additions to documentation labels May 23, 2024
@AlexStocks AlexStocks merged commit 0e903fb into OpenAtomFoundation:unstable May 29, 2024
20 checks passed
chejinge pushed a commit that referenced this pull request Aug 1, 2024
* add pika benchmark

---------

Co-authored-by: liuyuecai <[email protected]>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* add pika benchmark

---------

Co-authored-by: liuyuecai <[email protected]>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* add pika benchmark

---------

Co-authored-by: liuyuecai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants