fix diskann searchCache param compatibility (#27557)

Signed-off-by: xianliang <xianliang.li@zilliz.com>
pull/27649/head
foxspy 2023-10-11 16:57:34 +08:00 committed by GitHub
parent 0ca9c513f9
commit 2b46bd1f08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 10 deletions

View File

@ -49,7 +49,6 @@ index_engine = knowhere
export GIT_BRANCH=master
AZURE_OPTION := ""
ifeq (${ENABLE_AZURE}, false)
AZURE_OPTION := -Z
endif

View File

@ -208,17 +208,17 @@ func SetDiskIndexBuildParams(indexParams map[string]string, fieldDataSize int64)
}
searchCacheBudgetGBRatioStr, ok := indexParams[SearchCacheBudgetRatioKey]
if !ok {
return fmt.Errorf("index param searchCacheBudgetGBRatio not exist")
}
// set generate cache size when cache ratio param set
if ok {
SearchCacheBudgetGBRatio, err := strconv.ParseFloat(searchCacheBudgetGBRatioStr, 64)
if err != nil {
return err
}
indexParams[SearchCacheBudgetKey] = fmt.Sprintf("%f", float32(fieldDataSize)*float32(SearchCacheBudgetGBRatio)/(1<<30))
}
indexParams[PQCodeBudgetKey] = fmt.Sprintf("%f", float32(fieldDataSize)*float32(pqCodeBudgetGBRatio)/(1<<30))
indexParams[NumBuildThreadKey] = strconv.Itoa(int(float32(hardware.GetCPUNum()) * float32(buildNumThreadsRatio)))
indexParams[BuildDramBudgetKey] = fmt.Sprintf("%f", float32(hardware.GetFreeMemoryCount())/(1<<30))
indexParams[SearchCacheBudgetKey] = fmt.Sprintf("%f", float32(fieldDataSize)*float32(SearchCacheBudgetGBRatio)/(1<<30))
return nil
}

View File

@ -133,18 +133,26 @@ func TestDiskIndexParams(t *testing.T) {
err := SetDiskIndexBuildParams(indexParams, 100)
assert.NoError(t, err)
_, ok := indexParams[SearchCacheBudgetKey]
assert.True(t, ok)
indexParams[SearchCacheBudgetRatioKey] = "aabb"
err = SetDiskIndexBuildParams(indexParams, 100)
assert.Error(t, err)
_, ok := indexParams[PQCodeBudgetKey]
delete(indexParams, SearchCacheBudgetRatioKey)
delete(indexParams, SearchCacheBudgetKey)
err = SetDiskIndexBuildParams(indexParams, 100)
assert.NoError(t, err)
_, ok = indexParams[PQCodeBudgetKey]
assert.True(t, ok)
_, ok = indexParams[BuildDramBudgetKey]
assert.True(t, ok)
_, ok = indexParams[NumBuildThreadKey]
assert.True(t, ok)
_, ok = indexParams[SearchCacheBudgetKey]
assert.True(t, ok)
assert.False(t, ok)
})
t.Run("set disk index load params without auto index param", func(t *testing.T) {