Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
21da5e67
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
21da5e67
编写于
9月 27, 2019
作者:
Y
yudong.cai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-574 rename some configurations
Former-commit-id: 4fabcc8a1dda1ca8998362c9466dd4d58f45d68a
上级
cb70c1c0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
143 addition
and
141 deletion
+143
-141
cpp/conf/server_config.template
cpp/conf/server_config.template
+7
-5
cpp/src/cache/CpuCacheMgr.cpp
cpp/src/cache/CpuCacheMgr.cpp
+8
-8
cpp/src/cache/GpuCacheMgr.cpp
cpp/src/cache/GpuCacheMgr.cpp
+4
-4
cpp/src/server/Config.cpp
cpp/src/server/Config.cpp
+91
-91
cpp/src/server/Config.h
cpp/src/server/Config.h
+30
-30
cpp/src/server/DBWrapper.cpp
cpp/src/server/DBWrapper.cpp
+3
-3
未找到文件。
cpp/conf/server_config.template
浏览文件 @
21da5e67
...
...
@@ -11,25 +11,27 @@ db_config:
secondary_path: # path used to store data only, split by semicolon
backend_url: sqlite://:@:/ # URI format: dialect://username:password@host:port/database
# Keep 'dialect://:@:/', and replace other texts with real values
.
# Keep 'dialect://:@:/', and replace other texts with real values
# Replace 'dialect' with 'mysql' or 'sqlite'
insert_buffer_size: 4 # GB, maximum insert buffer size allowed
# sum of insert_buffer_size and cpu_cache_capacity cannot exceed total memory
build_index_gpu: 0 # gpu id used for building index
metric_config:
enable_monitor: false # enable monitoring or not
collector: prometheus # prometheus
prometheus_config:
port: 8080 # port prometheus use
d
to fetch metrics
port: 8080 # port prometheus use
s
to fetch metrics
cache_config:
cpu_
mem_capacity: 16
# GB, CPU memory used for cache
cpu_
mem_threshold: 0.85
# percentage of data that will be kept when cache cleanup is triggered
cpu_
cache_capacity: 16
# GB, CPU memory used for cache
cpu_
cache_threshold: 0.85
# percentage of data that will be kept when cache cleanup is triggered
cache_insert_data: false # whether to load inserted data into cache
engine_config:
blas_threshold: 20
use_blas_threshold: 20 # if nq < use_blas_threshold, use SSE, faster with fluctuated response times
# if nq >= use_blas_threshold, use OpenBlas, slower with stable response times
resource_config:
resource_pool:
...
...
cpp/src/cache/CpuCacheMgr.cpp
浏览文件 @
21da5e67
...
...
@@ -34,23 +34,23 @@ CpuCacheMgr::CpuCacheMgr() {
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
Status
s
;
int32_t
cpu_
mem
_cap
;
s
=
config
.
GetCacheConfigCpu
MemCapacity
(
cpu_mem
_cap
);
int32_t
cpu_
cache
_cap
;
s
=
config
.
GetCacheConfigCpu
CacheCapacity
(
cpu_cache
_cap
);
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
}
int64_t
cap
=
cpu_
mem
_cap
*
unit
;
int64_t
cap
=
cpu_
cache
_cap
*
unit
;
cache_
=
std
::
make_shared
<
Cache
<
DataObjPtr
>>
(
cap
,
1UL
<<
32
);
float
cpu_
mem
_threshold
;
s
=
config
.
GetCacheConfigCpu
MemThreshold
(
cpu_mem
_threshold
);
float
cpu_
cache
_threshold
;
s
=
config
.
GetCacheConfigCpu
CacheThreshold
(
cpu_cache
_threshold
);
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
}
if
(
cpu_
mem_threshold
>
0.0
&&
cpu_mem
_threshold
<=
1.0
)
{
cache_
->
set_freemem_percent
(
cpu_
mem
_threshold
);
if
(
cpu_
cache_threshold
>
0.0
&&
cpu_cache
_threshold
<=
1.0
)
{
cache_
->
set_freemem_percent
(
cpu_
cache
_threshold
);
}
else
{
SERVER_LOG_ERROR
<<
"Invalid cpu_
mem_threshold: "
<<
cpu_mem
_threshold
SERVER_LOG_ERROR
<<
"Invalid cpu_
cache_threshold: "
<<
cpu_cache
_threshold
<<
", by default set to "
<<
cache_
->
freemem_percent
();
}
}
...
...
cpp/src/cache/GpuCacheMgr.cpp
浏览文件 @
21da5e67
...
...
@@ -38,16 +38,16 @@ GpuCacheMgr::GpuCacheMgr() {
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
Status
s
;
int32_t
gpu_
mem
_cap
;
s
=
config
.
GetCacheConfigGpu
MemCapacity
(
gpu_mem
_cap
);
int32_t
gpu_
cache
_cap
;
s
=
config
.
GetCacheConfigGpu
CacheCapacity
(
gpu_cache
_cap
);
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
}
int32_t
cap
=
gpu_
mem
_cap
*
G_BYTE
;
int32_t
cap
=
gpu_
cache
_cap
*
G_BYTE
;
cache_
=
std
::
make_shared
<
Cache
<
DataObjPtr
>>
(
cap
,
1UL
<<
32
);
float
gpu_mem_threshold
;
s
=
config
.
GetCacheConfigGpu
Mem
Threshold
(
gpu_mem_threshold
);
s
=
config
.
GetCacheConfigGpu
Cache
Threshold
(
gpu_mem_threshold
);
if
(
!
s
.
ok
())
{
SERVER_LOG_ERROR
<<
s
.
message
();
}
...
...
cpp/src/server/Config.cpp
浏览文件 @
21da5e67
...
...
@@ -135,20 +135,20 @@ Config::ValidateConfig() {
if
(
!
s
.
ok
())
return
s
;
/* cache config */
int32_t
cache_cpu_
mem
_capacity
;
s
=
GetCacheConfigCpu
MemCapacity
(
cache_cpu_mem
_capacity
);
int32_t
cache_cpu_
cache
_capacity
;
s
=
GetCacheConfigCpu
CacheCapacity
(
cache_cpu_cache
_capacity
);
if
(
!
s
.
ok
())
return
s
;
float
cache_cpu_
mem
_threshold
;
s
=
GetCacheConfigCpu
MemThreshold
(
cache_cpu_mem
_threshold
);
float
cache_cpu_
cache
_threshold
;
s
=
GetCacheConfigCpu
CacheThreshold
(
cache_cpu_cache
_threshold
);
if
(
!
s
.
ok
())
return
s
;
int32_t
cache_gpu_
mem
_capacity
;
s
=
GetCacheConfigGpu
MemCapacity
(
cache_gpu_mem
_capacity
);
int32_t
cache_gpu_
cache
_capacity
;
s
=
GetCacheConfigGpu
CacheCapacity
(
cache_gpu_cache
_capacity
);
if
(
!
s
.
ok
())
return
s
;
float
cache_gpu_
mem
_threshold
;
s
=
GetCacheConfigGpu
MemThreshold
(
cache_gpu_mem
_threshold
);
float
cache_gpu_
cache
_threshold
;
s
=
GetCacheConfigGpu
CacheThreshold
(
cache_gpu_cache
_threshold
);
if
(
!
s
.
ok
())
return
s
;
bool
cache_insert_data
;
...
...
@@ -156,8 +156,8 @@ Config::ValidateConfig() {
if
(
!
s
.
ok
())
return
s
;
/* engine config */
int32_t
engine_blas_threshold
;
s
=
GetEngineConfig
BlasThreshold
(
engin
e_blas_threshold
);
int32_t
engine_
use_
blas_threshold
;
s
=
GetEngineConfig
UseBlasThreshold
(
engine_us
e_blas_threshold
);
if
(
!
s
.
ok
())
return
s
;
int32_t
engine_omp_thread_num
;
...
...
@@ -226,23 +226,23 @@ Config::ResetDefaultConfig() {
if
(
!
s
.
ok
())
return
s
;
/* cache config */
s
=
SetCacheConfigCpu
MemCapacity
(
CONFIG_CACHE_CPU_MEM
_CAPACITY_DEFAULT
);
s
=
SetCacheConfigCpu
CacheCapacity
(
CONFIG_CACHE_CPU_CACHE
_CAPACITY_DEFAULT
);
if
(
!
s
.
ok
())
return
s
;
s
=
SetCacheConfigCpu
MemThreshold
(
CONFIG_CACHE_CPU_MEM
_THRESHOLD_DEFAULT
);
s
=
SetCacheConfigCpu
CacheThreshold
(
CONFIG_CACHE_CPU_CACHE
_THRESHOLD_DEFAULT
);
if
(
!
s
.
ok
())
return
s
;
s
=
SetCacheConfigGpu
MemCapacity
(
CONFIG_CACHE_GPU_MEM
_CAPACITY_DEFAULT
);
s
=
SetCacheConfigGpu
CacheCapacity
(
CONFIG_CACHE_GPU_CACHE
_CAPACITY_DEFAULT
);
if
(
!
s
.
ok
())
return
s
;
s
=
SetCacheConfigGpu
MemThreshold
(
CONFIG_CACHE_GPU_MEM
_THRESHOLD_DEFAULT
);
s
=
SetCacheConfigGpu
CacheThreshold
(
CONFIG_CACHE_GPU_CACHE
_THRESHOLD_DEFAULT
);
if
(
!
s
.
ok
())
return
s
;
s
=
SetCacheConfigCacheInsertData
(
CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT
);
if
(
!
s
.
ok
())
return
s
;
/* engine config */
s
=
SetEngineConfig
BlasThreshold
(
CONFIG_ENGIN
E_BLAS_THRESHOLD_DEFAULT
);
s
=
SetEngineConfig
UseBlasThreshold
(
CONFIG_ENGINE_US
E_BLAS_THRESHOLD_DEFAULT
);
if
(
!
s
.
ok
())
return
s
;
s
=
SetEngineConfigOmpThreadNum
(
CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT
);
...
...
@@ -417,17 +417,17 @@ Config::CheckMetricConfigPrometheusPort(const std::string &value) {
}
Status
Config
::
CheckCacheConfigCpu
Mem
Capacity
(
const
std
::
string
&
value
)
{
Config
::
CheckCacheConfigCpu
Cache
Capacity
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config cpu_
mem
_capacity: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config cpu_
cache
_capacity: "
+
value
);
}
else
{
uint64_t
cpu_cache_capacity
=
std
::
stoi
(
value
)
*
GB
;
uint64_t
total_mem
=
0
,
free_mem
=
0
;
CommonUtil
::
GetSystemMemInfo
(
total_mem
,
free_mem
);
if
(
cpu_cache_capacity
>=
total_mem
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Cache config cpu_
mem
_capacity exceed system memory: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Cache config cpu_
cache
_capacity exceed system memory: "
+
value
);
}
else
if
(
cpu_cache_capacity
>
(
double
)
total_mem
*
0.9
)
{
std
::
cerr
<<
"Warning: cpu_
mem
_capacity value is too big"
<<
std
::
endl
;
std
::
cerr
<<
"Warning: cpu_
cache
_capacity value is too big"
<<
std
::
endl
;
}
int32_t
buffer_value
;
...
...
@@ -435,29 +435,29 @@ Config::CheckCacheConfigCpuMemCapacity(const std::string &value) {
if
(
!
s
.
ok
())
return
s
;
int64_t
insert_buffer_size
=
buffer_value
*
GB
;
if
(
insert_buffer_size
+
cpu_cache_capacity
>=
total_mem
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Sum of cpu_
mem
_capacity and buffer_size exceed system memory"
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Sum of cpu_
cache
_capacity and buffer_size exceed system memory"
);
}
}
return
Status
::
OK
();
}
Status
Config
::
CheckCacheConfigCpu
Mem
Threshold
(
const
std
::
string
&
value
)
{
Config
::
CheckCacheConfigCpu
Cache
Threshold
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsFloat
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config cpu_
mem
_threshold: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config cpu_
cache
_threshold: "
+
value
);
}
else
{
float
cpu_
mem
_threshold
=
std
::
stof
(
value
);
if
(
cpu_
mem_threshold
<=
0.0
||
cpu_mem
_threshold
>=
1.0
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config cpu_
mem
_threshold: "
+
value
);
float
cpu_
cache
_threshold
=
std
::
stof
(
value
);
if
(
cpu_
cache_threshold
<=
0.0
||
cpu_cache
_threshold
>=
1.0
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config cpu_
cache
_threshold: "
+
value
);
}
}
return
Status
::
OK
();
}
Status
Config
::
CheckCacheConfigGpu
Mem
Capacity
(
const
std
::
string
&
value
)
{
Config
::
CheckCacheConfigGpu
Cache
Capacity
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
std
::
cerr
<<
"ERROR: gpu_cache_capacity "
<<
value
<<
" is not a number"
<<
std
::
endl
;
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config gpu_cache_capacity: "
+
value
)
;
}
else
{
uint64_t
gpu_cache_capacity
=
std
::
stoi
(
value
)
*
GB
;
int
gpu_index
;
...
...
@@ -469,22 +469,22 @@ Config::CheckCacheConfigGpuMemCapacity(const std::string &value) {
"Fail to get GPU memory for GPU device: "
+
std
::
to_string
(
gpu_index
));
}
else
if
(
gpu_cache_capacity
>=
gpu_memory
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Cache config gpu_
mem
_capacity exceed GPU memory: "
+
std
::
to_string
(
gpu_memory
));
"Cache config gpu_
cache
_capacity exceed GPU memory: "
+
std
::
to_string
(
gpu_memory
));
}
else
if
(
gpu_cache_capacity
>
(
double
)
gpu_memory
*
0.9
)
{
std
::
cerr
<<
"Warning: gpu_
mem
_capacity value is too big"
<<
std
::
endl
;
std
::
cerr
<<
"Warning: gpu_
cache
_capacity value is too big"
<<
std
::
endl
;
}
}
return
Status
::
OK
();
}
Status
Config
::
CheckCacheConfigGpu
Mem
Threshold
(
const
std
::
string
&
value
)
{
Config
::
CheckCacheConfigGpu
Cache
Threshold
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsFloat
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config gpu_
mem
_threshold: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config gpu_
cache
_threshold: "
+
value
);
}
else
{
float
gpu_
mem
_threshold
=
std
::
stof
(
value
);
if
(
gpu_
mem_threshold
<=
0.0
||
gpu_mem
_threshold
>=
1.0
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config gpu_
mem
_threshold: "
+
value
);
float
gpu_
cache
_threshold
=
std
::
stof
(
value
);
if
(
gpu_
cache_threshold
<=
0.0
||
gpu_cache
_threshold
>=
1.0
)
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid cache config gpu_
cache
_threshold: "
+
value
);
}
}
return
Status
::
OK
();
...
...
@@ -499,9 +499,9 @@ Config::CheckCacheConfigCacheInsertData(const std::string &value) {
}
Status
Config
::
CheckEngineConfigBlasThreshold
(
const
std
::
string
&
value
)
{
Config
::
CheckEngineConfig
Use
BlasThreshold
(
const
std
::
string
&
value
)
{
if
(
!
ValidationUtil
::
ValidateStringIsNumber
(
value
).
ok
())
{
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid engine config
blas
threshold: "
+
value
);
return
Status
(
SERVER_INVALID_ARGUMENT
,
"Invalid engine config
use_blas_
threshold: "
+
value
);
}
return
Status
::
OK
();
}
...
...
@@ -729,45 +729,45 @@ Config::GetMetricConfigStrPrometheusPort() {
////////////////////////////////////////////////////////////////////////////////
/* cache config */
std
::
string
Config
::
GetCacheConfigStrCpu
Mem
Capacity
()
{
Config
::
GetCacheConfigStrCpu
Cache
Capacity
()
{
std
::
string
value
;
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
MEM
_CAPACITY
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_CPU_
MEM
_CAPACITY
,
CONFIG_CACHE_CPU_
MEM
_CAPACITY_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
MEM
_CAPACITY
,
value
);
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
CACHE
_CAPACITY
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_CPU_
CACHE
_CAPACITY
,
CONFIG_CACHE_CPU_
CACHE
_CAPACITY_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
CACHE
_CAPACITY
,
value
);
}
return
value
;
}
std
::
string
Config
::
GetCacheConfigStrCpu
Mem
Threshold
()
{
Config
::
GetCacheConfigStrCpu
Cache
Threshold
()
{
std
::
string
value
;
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
MEM
_THRESHOLD
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_CPU_
MEM
_THRESHOLD
,
CONFIG_CACHE_CPU_
MEM
_THRESHOLD_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
MEM
_THRESHOLD
,
value
);
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD
,
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD
,
value
);
}
return
value
;
}
std
::
string
Config
::
GetCacheConfigStrGpu
Mem
Capacity
()
{
Config
::
GetCacheConfigStrGpu
Cache
Capacity
()
{
std
::
string
value
;
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
MEM
_CAPACITY
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_GPU_
MEM
_CAPACITY
,
CONFIG_CACHE_GPU_
MEM
_CAPACITY_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
MEM
_CAPACITY
,
value
);
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
CACHE
_CAPACITY
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_GPU_
CACHE
_CAPACITY
,
CONFIG_CACHE_GPU_
CACHE
_CAPACITY_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
CACHE
_CAPACITY
,
value
);
}
return
value
;
}
std
::
string
Config
::
GetCacheConfigStrGpu
Mem
Threshold
()
{
Config
::
GetCacheConfigStrGpu
Cache
Threshold
()
{
std
::
string
value
;
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
MEM
_THRESHOLD
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_GPU_
MEM
_THRESHOLD
,
CONFIG_CACHE_GPU_
MEM
_THRESHOLD_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
MEM
_THRESHOLD
,
value
);
if
(
!
GetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_CACHE
).
GetValue
(
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD
,
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD_DEFAULT
);
SetConfigValueInMem
(
CONFIG_CACHE
,
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD
,
value
);
}
return
value
;
}
...
...
@@ -786,12 +786,12 @@ Config::GetCacheConfigStrCacheInsertData() {
////////////////////////////////////////////////////////////////////////////////
/* engine config */
std
::
string
Config
::
GetEngineConfigStrBlasThreshold
()
{
Config
::
GetEngineConfigStr
Use
BlasThreshold
()
{
std
::
string
value
;
if
(
!
GetConfigValueInMem
(
CONFIG_ENGINE
,
CONFIG_ENGINE_BLAS_THRESHOLD
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_ENGINE
).
GetValue
(
CONFIG_ENGINE_BLAS_THRESHOLD
,
CONFIG_ENGINE_BLAS_THRESHOLD_DEFAULT
);
SetConfigValueInMem
(
CONFIG_ENGINE
,
CONFIG_ENGINE_BLAS_THRESHOLD
,
value
);
if
(
!
GetConfigValueInMem
(
CONFIG_ENGINE
,
CONFIG_ENGINE_
USE_
BLAS_THRESHOLD
,
value
).
ok
())
{
value
=
GetConfigNode
(
CONFIG_ENGINE
).
GetValue
(
CONFIG_ENGINE_
USE_
BLAS_THRESHOLD
,
CONFIG_ENGINE_
USE_
BLAS_THRESHOLD_DEFAULT
);
SetConfigValueInMem
(
CONFIG_ENGINE
,
CONFIG_ENGINE_
USE_
BLAS_THRESHOLD
,
value
);
}
return
value
;
}
...
...
@@ -922,36 +922,36 @@ Config::GetMetricConfigPrometheusPort(std::string &value) {
}
Status
Config
::
GetCacheConfigCpu
Mem
Capacity
(
int32_t
&
value
)
{
std
::
string
str
=
GetCacheConfigStrCpu
Mem
Capacity
();
Status
s
=
CheckCacheConfigCpu
Mem
Capacity
(
str
);
Config
::
GetCacheConfigCpu
Cache
Capacity
(
int32_t
&
value
)
{
std
::
string
str
=
GetCacheConfigStrCpu
Cache
Capacity
();
Status
s
=
CheckCacheConfigCpu
Cache
Capacity
(
str
);
if
(
!
s
.
ok
())
return
s
;
value
=
std
::
stoi
(
str
);
return
Status
::
OK
();
}
Status
Config
::
GetCacheConfigCpu
Mem
Threshold
(
float
&
value
)
{
std
::
string
str
=
GetCacheConfigStrCpu
Mem
Threshold
();
Status
s
=
CheckCacheConfigCpu
Mem
Threshold
(
str
);
Config
::
GetCacheConfigCpu
Cache
Threshold
(
float
&
value
)
{
std
::
string
str
=
GetCacheConfigStrCpu
Cache
Threshold
();
Status
s
=
CheckCacheConfigCpu
Cache
Threshold
(
str
);
if
(
!
s
.
ok
())
return
s
;
value
=
std
::
stof
(
str
);
return
Status
::
OK
();
}
Status
Config
::
GetCacheConfigGpu
Mem
Capacity
(
int32_t
&
value
)
{
std
::
string
str
=
GetCacheConfigStrGpu
Mem
Capacity
();
Status
s
=
CheckCacheConfigGpu
Mem
Capacity
(
str
);
Config
::
GetCacheConfigGpu
Cache
Capacity
(
int32_t
&
value
)
{
std
::
string
str
=
GetCacheConfigStrGpu
Cache
Capacity
();
Status
s
=
CheckCacheConfigGpu
Cache
Capacity
(
str
);
if
(
!
s
.
ok
())
return
s
;
value
=
std
::
stoi
(
str
);
return
Status
::
OK
();
}
Status
Config
::
GetCacheConfigGpu
Mem
Threshold
(
float
&
value
)
{
std
::
string
str
=
GetCacheConfigStrGpu
Mem
Threshold
();
Status
s
=
CheckCacheConfigGpu
Mem
Threshold
(
str
);
Config
::
GetCacheConfigGpu
Cache
Threshold
(
float
&
value
)
{
std
::
string
str
=
GetCacheConfigStrGpu
Cache
Threshold
();
Status
s
=
CheckCacheConfigGpu
Cache
Threshold
(
str
);
if
(
!
s
.
ok
())
return
s
;
value
=
std
::
stof
(
str
);
return
Status
::
OK
();
...
...
@@ -968,9 +968,9 @@ Config::GetCacheConfigCacheInsertData(bool &value) {
}
Status
Config
::
GetEngineConfigBlasThreshold
(
int32_t
&
value
)
{
std
::
string
str
=
GetEngineConfigStrBlasThreshold
();
Status
s
=
CheckEngineConfigBlasThreshold
(
str
);
Config
::
GetEngineConfig
Use
BlasThreshold
(
int32_t
&
value
)
{
std
::
string
str
=
GetEngineConfigStr
Use
BlasThreshold
();
Status
s
=
CheckEngineConfig
Use
BlasThreshold
(
str
);
if
(
!
s
.
ok
())
return
s
;
value
=
std
::
stoi
(
str
);
return
Status
::
OK
();
...
...
@@ -1116,34 +1116,34 @@ Config::SetMetricConfigPrometheusPort(const std::string &value) {
/* cache config */
Status
Config
::
SetCacheConfigCpu
Mem
Capacity
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCpu
Mem
Capacity
(
value
);
Config
::
SetCacheConfigCpu
Cache
Capacity
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCpu
Cache
Capacity
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CPU_
MEM
_CAPACITY
,
value
);
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CPU_
CACHE
_CAPACITY
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigCpu
Mem
Threshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCpu
Mem
Threshold
(
value
);
Config
::
SetCacheConfigCpu
Cache
Threshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigCpu
Cache
Threshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CPU_
MEM
_THRESHOLD
,
value
);
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigGpu
Mem
Capacity
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigGpu
Mem
Capacity
(
value
);
Config
::
SetCacheConfigGpu
Cache
Capacity
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigGpu
Cache
Capacity
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_GPU_
MEM
_CAPACITY
,
value
);
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_GPU_
CACHE
_CAPACITY
,
value
);
return
Status
::
OK
();
}
Status
Config
::
SetCacheConfigGpu
Mem
Threshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigGpu
Mem
Threshold
(
value
);
Config
::
SetCacheConfigGpu
Cache
Threshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckCacheConfigGpu
Cache
Threshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_GPU_
MEM
_THRESHOLD
,
value
);
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD
,
value
);
return
Status
::
OK
();
}
...
...
@@ -1157,10 +1157,10 @@ Config::SetCacheConfigCacheInsertData(const std::string &value) {
/* engine config */
Status
Config
::
SetEngineConfigBlasThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckEngineConfigBlasThreshold
(
value
);
Config
::
SetEngineConfig
Use
BlasThreshold
(
const
std
::
string
&
value
)
{
Status
s
=
CheckEngineConfig
Use
BlasThreshold
(
value
);
if
(
!
s
.
ok
())
return
s
;
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_ENGINE_BLAS_THRESHOLD
,
value
);
SetConfigValueInMem
(
CONFIG_DB
,
CONFIG_ENGINE_
USE_
BLAS_THRESHOLD
,
value
);
return
Status
::
OK
();
}
...
...
cpp/src/server/Config.h
浏览文件 @
21da5e67
...
...
@@ -60,14 +60,14 @@ static const char *CONFIG_DB_BUILD_INDEX_GPU_DEFAULT = "0";
/* cache config */
static
const
char
*
CONFIG_CACHE
=
"cache_config"
;
static
const
char
*
CONFIG_CACHE_CPU_
MEM_CAPACITY
=
"cpu_mem
_capacity"
;
static
const
char
*
CONFIG_CACHE_CPU_
MEM
_CAPACITY_DEFAULT
=
"16"
;
static
const
char
*
CONFIG_CACHE_GPU_
MEM_CAPACITY
=
"gpu_mem
_capacity"
;
static
const
char
*
CONFIG_CACHE_GPU_
MEM
_CAPACITY_DEFAULT
=
"0"
;
static
const
char
*
CONFIG_CACHE_CPU_
MEM
_THRESHOLD
=
"cpu_mem_threshold"
;
static
const
char
*
CONFIG_CACHE_CPU_
MEM
_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_GPU_
MEM
_THRESHOLD
=
"gpu_mem_threshold"
;
static
const
char
*
CONFIG_CACHE_GPU_
MEM
_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_CPU_
CACHE_CAPACITY
=
"cpu_cache
_capacity"
;
static
const
char
*
CONFIG_CACHE_CPU_
CACHE
_CAPACITY_DEFAULT
=
"16"
;
static
const
char
*
CONFIG_CACHE_GPU_
CACHE_CAPACITY
=
"gpu_cache
_capacity"
;
static
const
char
*
CONFIG_CACHE_GPU_
CACHE
_CAPACITY_DEFAULT
=
"0"
;
static
const
char
*
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD
=
"cpu_mem_threshold"
;
static
const
char
*
CONFIG_CACHE_CPU_
CACHE
_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD
=
"gpu_mem_threshold"
;
static
const
char
*
CONFIG_CACHE_GPU_
CACHE
_THRESHOLD_DEFAULT
=
"0.85"
;
static
const
char
*
CONFIG_CACHE_CACHE_INSERT_DATA
=
"cache_insert_data"
;
static
const
char
*
CONFIG_CACHE_CACHE_INSERT_DATA_DEFAULT
=
"false"
;
...
...
@@ -83,8 +83,8 @@ static const char *CONFIG_METRIC_PROMETHEUS_PORT_DEFAULT = "8080";
/* engine config */
static
const
char
*
CONFIG_ENGINE
=
"engine_config"
;
static
const
char
*
CONFIG_ENGINE_
BLAS_THRESHOLD
=
"
blas_threshold"
;
static
const
char
*
CONFIG_ENGINE_BLAS_THRESHOLD_DEFAULT
=
"20"
;
static
const
char
*
CONFIG_ENGINE_
USE_BLAS_THRESHOLD
=
"use_
blas_threshold"
;
static
const
char
*
CONFIG_ENGINE_
USE_
BLAS_THRESHOLD_DEFAULT
=
"20"
;
static
const
char
*
CONFIG_ENGINE_OMP_THREAD_NUM
=
"omp_thread_num"
;
static
const
char
*
CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT
=
"0"
;
...
...
@@ -137,14 +137,14 @@ class Config {
Status
CheckMetricConfigPrometheusPort
(
const
std
::
string
&
value
);
/* cache config */
Status
CheckCacheConfigCpu
Mem
Capacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCpu
Mem
Threshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpu
Mem
Capacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpu
Mem
Threshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCpu
Cache
Capacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCpu
Cache
Threshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpu
Cache
Capacity
(
const
std
::
string
&
value
);
Status
CheckCacheConfigGpu
Cache
Threshold
(
const
std
::
string
&
value
);
Status
CheckCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
/* engine config */
Status
CheckEngineConfigBlasThreshold
(
const
std
::
string
&
value
);
Status
CheckEngineConfig
Use
BlasThreshold
(
const
std
::
string
&
value
);
Status
CheckEngineConfigOmpThreadNum
(
const
std
::
string
&
value
);
/* resource config */
...
...
@@ -173,14 +173,14 @@ class Config {
std
::
string
GetMetricConfigStrPrometheusPort
();
/* cache config */
std
::
string
GetCacheConfigStrCpu
Mem
Capacity
();
std
::
string
GetCacheConfigStrCpu
Mem
Threshold
();
std
::
string
GetCacheConfigStrGpu
Mem
Capacity
();
std
::
string
GetCacheConfigStrGpu
Mem
Threshold
();
std
::
string
GetCacheConfigStrCpu
Cache
Capacity
();
std
::
string
GetCacheConfigStrCpu
Cache
Threshold
();
std
::
string
GetCacheConfigStrGpu
Cache
Capacity
();
std
::
string
GetCacheConfigStrGpu
Cache
Threshold
();
std
::
string
GetCacheConfigStrCacheInsertData
();
/* engine config */
std
::
string
GetEngineConfigStrBlasThreshold
();
std
::
string
GetEngineConfigStr
Use
BlasThreshold
();
std
::
string
GetEngineConfigStrOmpThreadNum
();
/* resource config */
...
...
@@ -208,14 +208,14 @@ class Config {
Status
GetMetricConfigPrometheusPort
(
std
::
string
&
value
);
/* cache config */
Status
GetCacheConfigCpu
Mem
Capacity
(
int32_t
&
value
);
Status
GetCacheConfigCpu
Mem
Threshold
(
float
&
value
);
Status
GetCacheConfigGpu
Mem
Capacity
(
int32_t
&
value
);
Status
GetCacheConfigGpu
Mem
Threshold
(
float
&
value
);
Status
GetCacheConfigCpu
Cache
Capacity
(
int32_t
&
value
);
Status
GetCacheConfigCpu
Cache
Threshold
(
float
&
value
);
Status
GetCacheConfigGpu
Cache
Capacity
(
int32_t
&
value
);
Status
GetCacheConfigGpu
Cache
Threshold
(
float
&
value
);
Status
GetCacheConfigCacheInsertData
(
bool
&
value
);
/* engine config */
Status
GetEngineConfigBlasThreshold
(
int32_t
&
value
);
Status
GetEngineConfig
Use
BlasThreshold
(
int32_t
&
value
);
Status
GetEngineConfigOmpThreadNum
(
int32_t
&
value
);
/* resource config */
...
...
@@ -244,14 +244,14 @@ class Config {
Status
SetMetricConfigPrometheusPort
(
const
std
::
string
&
value
);
/* cache config */
Status
SetCacheConfigCpu
Mem
Capacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigCpu
Mem
Threshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpu
Mem
Capacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpu
Mem
Threshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigCpu
Cache
Capacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigCpu
Cache
Threshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpu
Cache
Capacity
(
const
std
::
string
&
value
);
Status
SetCacheConfigGpu
Cache
Threshold
(
const
std
::
string
&
value
);
Status
SetCacheConfigCacheInsertData
(
const
std
::
string
&
value
);
/* engine config */
Status
SetEngineConfigBlasThreshold
(
const
std
::
string
&
value
);
Status
SetEngineConfig
Use
BlasThreshold
(
const
std
::
string
&
value
);
Status
SetEngineConfigOmpThreadNum
(
const
std
::
string
&
value
);
/* resource config */
...
...
cpp/src/server/DBWrapper.cpp
浏览文件 @
21da5e67
...
...
@@ -92,10 +92,10 @@ Status DBWrapper::StartService() {
}
//init faiss global variable
int32_t
blas_threshold
;
s
=
config
.
GetEngineConfig
BlasThreshold
(
blas_threshold
);
int32_t
use_
blas_threshold
;
s
=
config
.
GetEngineConfig
UseBlasThreshold
(
use_
blas_threshold
);
if
(
!
s
.
ok
())
return
s
;
faiss
::
distance_compute_blas_threshold
=
blas_threshold
;
faiss
::
distance_compute_blas_threshold
=
use_
blas_threshold
;
//set archive config
engine
::
ArchiveConf
::
CriteriaT
criterial
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录