mirror of https://github.com/milvus-io/milvus.git
* #1756 fix memory exhausted during searching Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * #1756 update const names Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/1760/head
parent
5a83ba4e49
commit
578d2633eb
|
@ -18,6 +18,7 @@ Please mark all change in change log and use the issue from GitHub
|
||||||
- \#1724 Remove unused unittests
|
- \#1724 Remove unused unittests
|
||||||
- \#1734 Opentracing for combined search request
|
- \#1734 Opentracing for combined search request
|
||||||
- \#1735 Fix search out of memory with ivf_flat
|
- \#1735 Fix search out of memory with ivf_flat
|
||||||
|
- \#1756 Fix memory exhausted during searching
|
||||||
|
|
||||||
## Feature
|
## Feature
|
||||||
- \#1603 BinaryFlat add 2 Metric: Substructure and Superstructure
|
- \#1603 BinaryFlat add 2 Metric: Substructure and Superstructure
|
||||||
|
|
|
@ -12,15 +12,16 @@
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace cache {
|
namespace cache {
|
||||||
|
|
||||||
constexpr double DEFAULT_THRESHHOLD_PERCENT = 0.7;
|
constexpr double DEFAULT_THRESHOLD_PERCENT = 0.7;
|
||||||
constexpr double WARNING_THRESHHOLD_PERCENT = 0.9;
|
constexpr double WARNING_THRESHOLD_PERCENT = 0.9;
|
||||||
|
constexpr double BIG_ITEM_THRESHOLD_PERCENT = 0.1;
|
||||||
|
|
||||||
template <typename ItemObj>
|
template <typename ItemObj>
|
||||||
Cache<ItemObj>::Cache(int64_t capacity, int64_t cache_max_count, const std::string& header)
|
Cache<ItemObj>::Cache(int64_t capacity, int64_t cache_max_count, const std::string& header)
|
||||||
: usage_(0),
|
: usage_(0),
|
||||||
capacity_(capacity),
|
capacity_(capacity),
|
||||||
header_(header),
|
header_(header),
|
||||||
freemem_percent_(DEFAULT_THRESHHOLD_PERCENT),
|
freemem_percent_(DEFAULT_THRESHOLD_PERCENT),
|
||||||
lru_(cache_max_count) {
|
lru_(cache_max_count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +82,9 @@ Cache<ItemObj>::insert(const std::string& key, const ItemObj& item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if usage exceed capacity, free some items
|
// if usage exceed capacity, free some items
|
||||||
if (usage_ > (int64_t)(capacity_ * WARNING_THRESHHOLD_PERCENT)) {
|
if (usage_ > capacity_ ||
|
||||||
|
(item_size > (int64_t)(capacity_ * BIG_ITEM_THRESHOLD_PERCENT) &&
|
||||||
|
usage_ > (int64_t)(capacity_ * WARNING_THRESHOLD_PERCENT))) {
|
||||||
SERVER_LOG_DEBUG << header_ << " Current usage " << (usage_ >> 20) << "MB is too high for capacity "
|
SERVER_LOG_DEBUG << header_ << " Current usage " << (usage_ >> 20) << "MB is too high for capacity "
|
||||||
<< (capacity_ >> 20) << "MB, start free memory";
|
<< (capacity_ >> 20) << "MB, start free memory";
|
||||||
free_memory();
|
free_memory();
|
||||||
|
|
Loading…
Reference in New Issue