p2pstore 0.1.7.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. p2pstore-0.1.7.dev1/LICENSE +201 -0
  2. p2pstore-0.1.7.dev1/MANIFEST.in +10 -0
  3. p2pstore-0.1.7.dev1/PKG-INFO +313 -0
  4. p2pstore-0.1.7.dev1/README.md +279 -0
  5. p2pstore-0.1.7.dev1/pyproject.toml +61 -0
  6. p2pstore-0.1.7.dev1/setup.cfg +4 -0
  7. p2pstore-0.1.7.dev1/src/p2pstore/__init__.py +17 -0
  8. p2pstore-0.1.7.dev1/src/p2pstore/client.py +851 -0
  9. p2pstore-0.1.7.dev1/src/p2pstore/core/__init__.py +20 -0
  10. p2pstore-0.1.7.dev1/src/p2pstore/core/buffer_registry.py +43 -0
  11. p2pstore-0.1.7.dev1/src/p2pstore/core/metadata_client.py +148 -0
  12. p2pstore-0.1.7.dev1/src/p2pstore/core/metadata_server.py +47 -0
  13. p2pstore-0.1.7.dev1/src/p2pstore/core/object_types.py +17 -0
  14. p2pstore-0.1.7.dev1/src/p2pstore/core/transfer_request.py +43 -0
  15. p2pstore-0.1.7.dev1/src/p2pstore/core/transport.py +40 -0
  16. p2pstore-0.1.7.dev1/src/p2pstore/metadata/__init__.py +48 -0
  17. p2pstore-0.1.7.dev1/src/p2pstore/metadata/etcd_client.py +767 -0
  18. p2pstore-0.1.7.dev1/src/p2pstore/transport/__init__.py +20 -0
  19. p2pstore-0.1.7.dev1/src/p2pstore/transport/engine_adapter.py +61 -0
  20. p2pstore-0.1.7.dev1/src/p2pstore/transport/rdma_transport.py +282 -0
  21. p2pstore-0.1.7.dev1/src/p2pstore/transport/tcp_transport.py +171 -0
  22. p2pstore-0.1.7.dev1/src/p2pstore/transport/transfer_engine.py +100 -0
  23. p2pstore-0.1.7.dev1/src/p2pstore/utils/__init__.py +40 -0
  24. p2pstore-0.1.7.dev1/src/p2pstore/utils/common.py +70 -0
  25. p2pstore-0.1.7.dev1/src/p2pstore/utils/config.py +87 -0
  26. p2pstore-0.1.7.dev1/src/p2pstore/utils/logger.py +304 -0
  27. p2pstore-0.1.7.dev1/src/p2pstore/utils/serialization.py +103 -0
  28. p2pstore-0.1.7.dev1/src/p2pstore/utils/topology.py +414 -0
  29. p2pstore-0.1.7.dev1/src/p2pstore.egg-info/PKG-INFO +313 -0
  30. p2pstore-0.1.7.dev1/src/p2pstore.egg-info/SOURCES.txt +32 -0
  31. p2pstore-0.1.7.dev1/src/p2pstore.egg-info/dependency_links.txt +1 -0
  32. p2pstore-0.1.7.dev1/src/p2pstore.egg-info/requires.txt +17 -0
  33. p2pstore-0.1.7.dev1/src/p2pstore.egg-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Paddle
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include src/p2pstore *.py
5
+ recursive-include src/p2pstore *.pyi
6
+ global-exclude __pycache__
7
+ global-exclude *.py[cod]
8
+ prune src/p2pstore/benchmark
9
+ prune src/p2pstore/examples
10
+ prune tests
@@ -0,0 +1,313 @@
1
+ Metadata-Version: 2.4
2
+ Name: p2pstore
3
+ Version: 0.1.7.dev1
4
+ Summary: P2P Store - 基于 RDMA 的高性能分布式数据传输系统
5
+ Author: Paddle
6
+ License-Expression: Apache-2.0
7
+ Keywords: p2p,rdma,distributed,tensor,transfer
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: System :: Distributed Computing
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: numpy>=1.20.0
20
+ Requires-Dist: safetensors>=0.3.0
21
+ Requires-Dist: mooncake-transfer-engine==0.3.7
22
+ Requires-Dist: protobuf==3.20.3
23
+ Requires-Dist: etcd3==0.12.0
24
+ Provides-Extra: paddle
25
+ Requires-Dist: paddlepaddle>=2.5.0; extra == "paddle"
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.20.0; extra == "dev"
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: ruff; extra == "dev"
31
+ Provides-Extra: benchmark
32
+ Requires-Dist: paddlepaddle-gpu>=2.5.0; extra == "benchmark"
33
+ Dynamic: license-file
34
+
35
+ # P2P Store - 分布式 P2P 数据存储系统
36
+
37
+ ## 项目概述
38
+
39
+ P2P Store 是一个基于 RDMA 的高性能分布式数据传输系统,支持 Tensor、文件、字节数据的点对点传输。
40
+
41
+ ### 核心概念
42
+
43
+ - **P2PClient**: 客户端,用于 put/get/list/delete 数据
44
+ - **P2PServer**: 服务端,元数据服务器 (MetadataServer)
45
+ - **P2PConfig**: 统一配置类,Server 和 Client 共用
46
+ - **Transport**: 传输层,负责实际的数据传输,支持 RDMA 和 TCP 协议
47
+
48
+ ## 安装指南
49
+
50
+ ### 安装步骤
51
+
52
+ 1. 依赖 RDMA 库
53
+
54
+ ```bash
55
+ apt install -y rdma-core libibverbs1 libmlx5-1 libibverbs-dev
56
+ ```
57
+
58
+ 2. 安装 mooncake-transfer-engine
59
+
60
+ ```bash
61
+ pip install mooncake-transfer-engine==0.3.7
62
+
63
+ # 其他环境已有的依赖
64
+ # numpy>=1.20.0
65
+ # pyzmq>=22.0.0
66
+ # safetensors
67
+ # paddlepaddle-gpu
68
+ ```
69
+
70
+ ## 快速开始
71
+
72
+ ### 1. 启动 Metaserver
73
+
74
+ ```bash
75
+ # 直接运行 (使用默认配置: zmq://127.0.0.1:5765,127.0.0.1:5766)
76
+ python examples/start_metaserver.py
77
+ ```
78
+
79
+ ### 2. 启动 Put 节点
80
+
81
+ ```bash
82
+ # 直接运行 (默认: 5 个 1MB 的 test_data_{i} key)
83
+ python examples/test_put.py
84
+ ```
85
+
86
+ ### 3. 启动 Get 节点
87
+
88
+ 在其他节点启动示例脚本获取数据:
89
+
90
+ ```bash
91
+ python examples/benchmark_get.py
92
+ ```
93
+
94
+ ## 示例脚本
95
+
96
+ `examples/` 目录提供了多个示例脚本,**所有脚本都支持直接运行(使用默认参数)**:
97
+
98
+ | 脚本 | 作用 | 默认配置 |
99
+ | ---------------------- | -------------------- | --------------------------------------- |
100
+ | `start_metaserver.py` | 启动 Metadata Server | `zmq://{POD_0_IP}:5765,{POD_0_IP}:5766` |
101
+ | `test_put.py` | 写入测试数据 | 5 个 1MB 数据, key 前缀 `test_data` |
102
+ | `test_delete.py` | 删除数据 | 删除 `test_data` 前缀的 key |
103
+ | `test_delete_batch.py` | 批量删除数据 | 删除 `test_data` 前缀的 key |
104
+ | `test_list_files.py` | 列出所有已注册数据 | - |
105
+ | `test_clear.py` | 清空所有数据 | - |
106
+ | `benchmark_put.py` | PUT 性能测试 | 10MB × 10 个 key (`bench_test_key_{i}`) |
107
+ | `benchmark_get.py` | GET 性能测试 | 拉取 10 个 `bench_test_key_{i}`, 1 轮 |
108
+
109
+ ### 使用示例
110
+
111
+ #### 直接运行(使用默认参数)
112
+
113
+ ```bash
114
+ # 1. 启动 Metaserver (默认监听 127.0.0.1:5765,5766)
115
+ python examples/start_metaserver.py
116
+
117
+ # 2. 写入测试数据 (默认: 5 个 1MB, key 前缀 test_data)
118
+ python examples/test_put.py
119
+
120
+ # 3. 查看已注册数据
121
+ python examples/test_list_files.py
122
+
123
+ # 4. 删除数据 (默认删除 test_data 前缀的 key)
124
+ python examples/test_delete.py
125
+
126
+ # 5. 批量删除 (默认删除 test_data 前缀的 key)
127
+ python examples/test_delete_batch.py
128
+
129
+ # 6. 清空所有数据
130
+ python examples/test_clear.py
131
+ ```
132
+
133
+ #### 自定义参数
134
+
135
+ ```bash
136
+ # 写入 10 个 50MB 数据,key 前缀为 my_data
137
+ python examples/test_put.py --size_mb 50 --count 10 --key-prefix my_data
138
+
139
+ # 删除指定前缀的 key
140
+ python examples/test_delete_batch.py --key-prefix my_data
141
+
142
+ # 删除指定的多个 key
143
+ python examples/test_delete_batch.py --keys key1,key2,key3
144
+
145
+ # 指定 Metaserver 地址
146
+ python examples/test_put.py --metadata-server zmq://10.0.0.1:5765,10.0.0.1:5766
147
+ ```
148
+
149
+ ## 配置说明
150
+
151
+ P2P Store 使用 `P2PConfig` 类进行配置管理,Server 和 Client 共用同一配置类:
152
+
153
+ | 配置项 | 描述 | 默认值 |
154
+ | --------------- | --------------------------------------------------------- | -------------------- |
155
+ | metadata_server | Metaserver 地址,格式: `zmq://ip:sync_port,ip:coord_port` | 必填 |
156
+ | local_host | 本地地址 (ip) | 从 `POD_IP` 环境变量 |
157
+ | protocol | 传输协议 (rdma/tcp) | `"rdma"` |
158
+ | device | RDMA 设备列表 | 自动探测 |
159
+ | max_retries | 最大重试次数 | `10` |
160
+ | retry_interval | 重试间隔 (秒) | `3` |
161
+
162
+ ### 配置示例
163
+
164
+ ```python
165
+ from p2pstore import P2PConfig
166
+
167
+ # ZMQ 模式
168
+ config = P2PConfig(
169
+ metadata_server="zmq://10.0.0.1:5765,10.0.0.1:5766",
170
+ protocol="rdma",
171
+ device="mlx5_2,mlx5_3,mlx5_4,mlx5_5"
172
+ )
173
+ ```
174
+
175
+ ## Client API
176
+
177
+ ### 初始化 Client
178
+
179
+ ```python
180
+ from p2pstore import P2PClient, P2PConfig
181
+
182
+ # 创建配置
183
+ config = P2PConfig(
184
+ metadata_server="zmq://10.0.0.1:5765,10.0.0.1:5766",
185
+ protocol="rdma",
186
+ device="mlx5_2,mlx5_3,mlx5_4,mlx5_5"
187
+ )
188
+
189
+ # 初始化客户端
190
+ client = P2PClient(config)
191
+ ```
192
+
193
+ ### 注册数据 (put)
194
+
195
+ ```python
196
+ import paddle
197
+ import numpy as np
198
+
199
+ # 创建示例数据
200
+ tensor = paddle.to_tensor(np.random.randn(128, 128), dtype="float32")
201
+
202
+ # 注册数据,指定 key (如果 key 已存在,会先删除旧数据再写入)
203
+ await client.put("my_tensor", tensor)
204
+ ```
205
+
206
+ ### 获取数据 (get)
207
+
208
+ ```python
209
+ # 获取数据
210
+ tensor = await client.get("my_tensor")
211
+
212
+ # 保存到文件
213
+ await client.get("my_tensor", output_path="/path/to/save.bin")
214
+ ```
215
+
216
+ ### 删除数据 (delete)
217
+
218
+ ```python
219
+ # 删除指定 key 的数据 (可删除任意节点注册的数据)
220
+ await client.delete("my_tensor")
221
+
222
+ # 批量删除
223
+ results = await client.delete_batch(["key1", "key2", "key3"])
224
+ ```
225
+
226
+ ### 清除所有数据 (clear)
227
+
228
+ ```python
229
+ # 清除所有已注册的数据
230
+ result = await client.clear()
231
+ # result: {"success": bool, "cleared": int, "failed": list[str]}
232
+ ```
233
+
234
+ ### 列出数据 (list)
235
+
236
+ ```python
237
+ # 列出所有已注册的数据
238
+ files = client.list()
239
+ print(f"已注册的数据: {list(files.keys())}")
240
+ ```
241
+
242
+ ### 检查数据是否存在 (exists)
243
+
244
+ ```python
245
+ # 检查指定 key 是否存在
246
+ exists = await client.exists("my_tensor")
247
+ ```
248
+
249
+ ## 环境变量
250
+
251
+ | 变量名 | 作用 | 默认值 |
252
+ | ---------- | ---------------------------- | ----------- |
253
+ | `POD_0_IP` | Metaserver 所在节点 IP | `127.0.0.1` |
254
+ | `POD_IP` | 本地节点 IP (用于 RDMA 绑定) | `127.0.0.1` |
255
+
256
+ 所有脚本默认从 `POD_0_IP` 环境变量拼装 Metaserver 地址(格式:`zmq://{POD_0_IP}:5765,{POD_0_IP}:5766`)。
257
+
258
+ ## Benchmark 脚本
259
+
260
+ `benchmark/` 目录提供了多种性能基准测试,方便验证 RDMA 传输链路。**所有脚本的参数都有默认值,可直接运行**。
261
+
262
+ ### 脚本列表
263
+
264
+ | 脚本 | 作用 | 关键指标 |
265
+ | ----------------------------- | --------------------------------------------------------- | ------------------------------------ |
266
+ | `benchmark_put.py` | 单客户端顺序 PUT,生成指定数量的 `bench_test_key_{i}` | 吞吐量、Avg/P50/P95/P99 Latency |
267
+ | `benchmark_get.py` | 单客户端顺序 GET,拉取 PUT 端生成的 `bench_test_key_{i}` | 吞吐量、Avg/P50/P99 Latency |
268
+ | `benchmark_put_size_sweep.py` | 按不同数据大小生成 Key,格式 `{prefix}_{size}mb_{index}` | 各尺寸吞吐、Avg/P95/P99、失败次数 |
269
+ | `benchmark_get_size_sweep.py` | 适配 PUT sweep,按目标尺寸列表逐一测试 GET | 各尺寸吞吐、Avg/P95/P99、失败次数 |
270
+ | `benchmark_get_concurrent.py` | 启动 N 个独立 Client 并发拉取同一批 Key,评估链路饱和吞吐 | 总吞吐、QPS、Avg/P50/P95/P99 Latency |
271
+
272
+ ### 使用示例
273
+
274
+ #### 基础 PUT/GET 测试
275
+
276
+ ```bash
277
+ # PUT 端:写入 16 个 10MB 的 Key (默认 key 为 bench_test_key_{i})
278
+ python benchmark/benchmark_put.py --size_mb 10 --count 16
279
+
280
+ # GET 端:拉取 PUT 端写入的数据,循环拉取 3 轮 (count 需与 PUT 端一致)
281
+ python benchmark/benchmark_get.py --count 16 --rounds 3
282
+ ```
283
+
284
+ #### 多尺寸 Size Sweep 测试
285
+
286
+ ```bash
287
+ # PUT 端:使用默认值 (10MB × 8 个 key)
288
+ python benchmark/benchmark_put_size_sweep.py
289
+
290
+ # PUT 端:按 1MB/10MB/50MB 三个尺寸生成数据
291
+ python benchmark/benchmark_put_size_sweep.py \
292
+ --size_mb 1,10,50 --keys-per-size 8 --key-prefix bench_size_sweep
293
+
294
+ # GET 端:拉取对应尺寸的数据,循环 3 轮
295
+ python benchmark/benchmark_get_size_sweep.py \
296
+ --size_mb 1,10,50 --keys-per-size 8 --rounds 3 --key-prefix bench_size_sweep
297
+ ```
298
+
299
+ #### 并发 GET 测试
300
+
301
+ ```bash
302
+ # 先启动 PUT 端生成数据 (默认值: 10MB × 8 key, prefix=bench_size_sweep)
303
+ python benchmark/benchmark_put_size_sweep.py
304
+ # 或自定义 PUT 参数
305
+ python benchmark/benchmark_put_size_sweep.py --size_mb 10 --keys-per-size 8 --key-prefix bench_size_sweep
306
+
307
+ # 启动并发 GET (默认值: 4 并发, 10MB × 8 key, 5 轮, prefix=bench_size_sweep)
308
+ python benchmark/benchmark_get_concurrent.py
309
+
310
+ # 自定义参数: 8 个客户端并发 GET,循环 5 轮
311
+ python benchmark/benchmark_get_concurrent.py \
312
+ --size_mb 10 --keys-per-size 8 --concurrency 8 --rounds 5
313
+ ```