ESrally单机向量检索性能测试全流程

发布于:2024-05-10 ⋅ 阅读:(25) ⋅ 点赞:(0)

ESrally单机向量检索性能测试全流程

测试方案的尝试

准备测试 ES 的向量检索性能,Vespa 方案由于下载依赖库存在网络问题无法执行成功,终止;开源工具 ann-benchamrk 是一个用于评估近似最近邻(ANN)搜索库的性能测试工具,这个本是最佳选择,但是也由于需要 pip 安装几十个依赖和 docker 构建十分麻烦,且详细的教程介绍太少,最后还是选择 esrally 进行性能测试,这个也是 ES 官方博客所使用的。

测试环境

uname -r
# 5.4.6-1.el7.elrepo.x86_64 内核版本
lscpu
# Intel(R) Xeon(R) Gold 6130T CPU @ 2.10GHz 处理器型号
# Architecture:          x86_64 架构
cat /etc/redhat-release
# CentOS Linux release 7.4.1708 (Core) 操作系统版本
python3 --version 
# Python 3.10.11

在线安装 esrally

pip3 install esrally

Httpx 版本冲突

由于之前安装了其他 ollama-python 0.1.2 导致一些依赖版本冲突:

ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ollama-python 0.1.2 requires httpx<0.27.0,>=0.26.0, but you have httpx 0.27.0 which is incompatible.
ollama-python 0.1.2 requires responses<0.25.0,>=0.24.1, but you have responses 0.18.0 which is incompatible.

处理办法:pip 3 uninstall ollama-python

安装完查看一下 esrally 版本(不能直接使用 esrally):

cd /root/python3/Python-3.10/bin
# ./esrally --version
esrally 2.10.0

./esrally --help

返回内容如下(有省略):

usage: esrally [-h] [--version] {
   race,list,delete,info,create-track,compare,build,download,install,start,stop,add} ...

    ____        ____
   / __ \____ _/ / /_  __
  / /_/ / __ `/ / / / / /
 / _, _/ /_/ / / / /_/ /
/_/ |_|\__,_/_/_/\__, /
                /____/

 You Know, for Benchmarking Elasticsearch.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

subcommands:
  {
   race,list,delete,info,create-track,compare,build,download,install,start,stop,add}

Dense vector track 介绍

rally-tracks/dense_vector at master · elastic/rally-tracks (github.com)

本赛道(track)用于对密集向量场的索引和搜索进行基准测试。

该数据集包含 1,000 万个矢量,维度为 96。该数据集基于 Yandex DEEP 1 B 图像数据集,可在此处下载:https://big-ann-benchmarks.com/。
数据集由名为 learn.350M.fbin 的 "样本数据 "文件的前 1000 万个向量创建。

使用下面这个命令生成 JSON 格式数据集:

python3 _tools/parse.py data/learn.350M.fbin > documents.json

文档示例

{
   
  "vector": [0.21529805660247803, -0.06119159981608391, 0.08770883828401566, 0.08731604367494583, -0.03312725946307182, -0.06861377507448196, 0.011172166094183922, 0.08099681884050369, 0.06873716413974762, -0.10662394016981125, -0.06803347170352936, -0.22509372234344482, 0.04775683954358101, -0.11963146924972534, -0.13713325560092926, 0.040520284324884415, 0.03633395954966545, -0.06001321226358414, 0.05640476569533348, -0.1323852241039276, 0.09493865817785263, 0.08581436425447464,