Skip to content

Commit a898095

Browse files
authored
add --num-shards option for milvus performance test case (zilliztech#526)
* add --num-shards option for milvus performance test case * fix lint warning
1 parent 7a1dc5e commit a898095

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

vectordb_bench/backend/clients/milvus/cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ class MilvusTypedDict(TypedDict):
2929
str | None,
3030
click.option("--password", type=str, help="Db password", required=False),
3131
]
32+
num_shards: Annotated[
33+
int,
34+
click.option(
35+
"--num-shards",
36+
type=int,
37+
help="Number of shards",
38+
required=False,
39+
default=1,
40+
show_default=True,
41+
),
42+
]
3243

3344

3445
class MilvusAutoIndexTypedDict(CommonTypedDict, MilvusTypedDict): ...
@@ -46,6 +57,7 @@ def MilvusAutoIndex(**parameters: Unpack[MilvusAutoIndexTypedDict]):
4657
uri=SecretStr(parameters["uri"]),
4758
user=parameters["user_name"],
4859
password=SecretStr(parameters["password"]),
60+
num_shards=int(parameters["num_shards"]),
4961
),
5062
db_case_config=AutoIndexConfig(),
5163
**parameters,
@@ -64,6 +76,7 @@ def MilvusFlat(**parameters: Unpack[MilvusAutoIndexTypedDict]):
6476
uri=SecretStr(parameters["uri"]),
6577
user=parameters["user_name"],
6678
password=SecretStr(parameters["password"]),
79+
num_shards=int(parameters["num_shards"]),
6780
),
6881
db_case_config=FLATConfig(),
6982
**parameters,
@@ -110,6 +123,7 @@ def MilvusIVFFlat(**parameters: Unpack[MilvusIVFFlatTypedDict]):
110123
uri=SecretStr(parameters["uri"]),
111124
user=parameters["user_name"],
112125
password=SecretStr(parameters["password"]),
126+
num_shards=int(parameters["num_shards"]),
113127
),
114128
db_case_config=IVFFlatConfig(
115129
nlist=parameters["nlist"],
@@ -131,6 +145,7 @@ def MilvusIVFSQ8(**parameters: Unpack[MilvusIVFFlatTypedDict]):
131145
uri=SecretStr(parameters["uri"]),
132146
user=parameters["user_name"],
133147
password=SecretStr(parameters["password"]),
148+
num_shards=int(parameters["num_shards"]),
134149
),
135150
db_case_config=IVFSQ8Config(
136151
nlist=parameters["nlist"],
@@ -156,6 +171,7 @@ def MilvusDISKANN(**parameters: Unpack[MilvusDISKANNTypedDict]):
156171
uri=SecretStr(parameters["uri"]),
157172
user=parameters["user_name"],
158173
password=SecretStr(parameters["password"]),
174+
num_shards=int(parameters["num_shards"]),
159175
),
160176
db_case_config=DISKANNConfig(
161177
search_list=parameters["search_list"],
@@ -184,6 +200,7 @@ def MilvusGPUIVFFlat(**parameters: Unpack[MilvusGPUIVFTypedDict]):
184200
uri=SecretStr(parameters["uri"]),
185201
user=parameters["user_name"],
186202
password=SecretStr(parameters["password"]),
203+
num_shards=int(parameters["num_shards"]),
187204
),
188205
db_case_config=GPUIVFFlatConfig(
189206
nlist=parameters["nlist"],
@@ -218,6 +235,7 @@ def MilvusGPUBruteForce(**parameters: Unpack[MilvusGPUBruteForceTypedDict]):
218235
uri=SecretStr(parameters["uri"]),
219236
user=parameters["user_name"],
220237
password=SecretStr(parameters["password"]),
238+
num_shards=int(parameters["num_shards"]),
221239
),
222240
db_case_config=GPUBruteForceConfig(
223241
metric_type=parameters["metric_type"],
@@ -249,6 +267,7 @@ def MilvusGPUIVFPQ(**parameters: Unpack[MilvusGPUIVFPQTypedDict]):
249267
uri=SecretStr(parameters["uri"]),
250268
user=parameters["user_name"],
251269
password=SecretStr(parameters["password"]),
270+
num_shards=int(parameters["num_shards"]),
252271
),
253272
db_case_config=GPUIVFPQConfig(
254273
nlist=parameters["nlist"],
@@ -288,6 +307,7 @@ def MilvusGPUCAGRA(**parameters: Unpack[MilvusGPUCAGRATypedDict]):
288307
uri=SecretStr(parameters["uri"]),
289308
user=parameters["user_name"],
290309
password=SecretStr(parameters["password"]),
310+
num_shards=int(parameters["num_shards"]),
291311
),
292312
db_case_config=GPUCAGRAConfig(
293313
intermediate_graph_degree=parameters["intermediate_graph_degree"],

vectordb_bench/backend/clients/milvus/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class MilvusConfig(DBConfig):
77
uri: SecretStr = "http://localhost:19530"
88
user: str | None = None
99
password: SecretStr | None = None
10+
num_shards: int = 1
1011

1112
def to_dict(self) -> dict:
1213
return {

vectordb_bench/backend/clients/milvus/milvus.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ def __init__(
4040

4141
from pymilvus import connections
4242

43-
connections.connect(**self.db_config, timeout=30)
43+
connections.connect(
44+
uri=self.db_config.get("uri"),
45+
user=self.db_config.get("user"),
46+
password=self.db_config.get("password"),
47+
timeout=30,
48+
)
4449
if drop_old and utility.has_collection(self.collection_name):
4550
log.info(f"{self.name} client drop_old collection: {self.collection_name}")
4651
utility.drop_collection(self.collection_name)
@@ -59,6 +64,7 @@ def __init__(
5964
name=self.collection_name,
6065
schema=CollectionSchema(fields),
6166
consistency_level="Session",
67+
num_shards=self.db_config.get("num_shards"),
6268
)
6369

6470
log.info(f"{self.name} create index: index_params: {self.case_config.index_param()}")

0 commit comments

Comments
 (0)