vearch / vearch

Distributed vector search for AI-native applications

Home Page:https://vearch.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

范围索引使用虚拟内存

hanqiushi opened this issue · comments

commented

您好,我这边发现如果对一些字段创建索引时,会额外申请大量的虚拟内存,这部分是必须的么,可以调整申请虚拟内存的大小么

如下图,VIRT 达到几十G
image

建表参数
"properties": {
"feature": {
"dimension": 512,
"type": "vector"
},
"image_url": {
"index": true,
"type": "string"
},
"face": {
"index": true,
"type": "string"
},
"group": {
"type": "string",
"array": true,
"index": true
},
"type": {
"type": "string",
"index": true
}
}
其中四项添加了index=true参数,现象上看就多分配了32G虚拟内存
如果表中向量数量少(不到100w),是否可以通过调整参数把这个虚拟内存降低,多谢

commented

字段索引保存在文件中,使用mmap进行访问,虚拟内存的占用取决于字段存储的数据,如果存储的内容例如time这种重复率低的内容,字段索引占用的虚拟内存就会比较大,如果存储的是性别,占用就会比较小,建议根据实际需求建立索引

commented

字段索引保存在文件中,使用mmap进行访问,虚拟内存的占用取决于字段存储的数据,如果存储的内容例如time这种重复率低的内容,字段索引占用的虚拟内存就会比较大,如果存储的是性别,占用就会比较小,建议根据实际需求建立索引

我这边看到的现象是,只要执行建表语句,虚拟内存就马上占用上。
分析了一下代码,感觉应该是 gamma 中 的 field_range_index.cc 中 这部分参数影响的

int MultiFieldsRangeIndex::AddField(int field, enum DataType field_type) {
BTreeParameters bt_param;
bt_param.mainleafxtra = 0;
bt_param.maxleaves = 1000000;
bt_param.poolsize = 500;
bt_param.leafxtra = 0;
bt_param.mainpool = 500;
bt_param.mainbits = 16;
bt_param.bits = 16;
bt_param.kDelim = "\001";

其中的 mainbits 和 bits 是 16,在 threadskv10h.c 中 执行 mmap时会申请4G虚拟内存
mgr->pages[0] = mmap (0, (uid)mgr->page_size << SEG_bits, flag, MAP_SHARED, mgr->idx, 0);

这里面的 mainbits 和 bits 值能改小么

commented

可以改小,但是需要测试下

commented

可以改小,但是需要测试下

好的,多谢