mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-01 08:28:10 +08:00
remove unnecessary lock (#1801)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
parent
8a731dea39
commit
dbbf91db28
7
core/src/cache/CacheMgr.h
vendored
7
core/src/cache/CacheMgr.h
vendored
@ -57,12 +57,6 @@ class CacheMgr {
|
||||
void
|
||||
SetCapacity(int64_t capacity);
|
||||
|
||||
void
|
||||
Lock();
|
||||
|
||||
void
|
||||
Unlock();
|
||||
|
||||
protected:
|
||||
CacheMgr();
|
||||
|
||||
@ -70,7 +64,6 @@ class CacheMgr {
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Cache<ItemObj>> cache_;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
} // namespace cache
|
||||
|
||||
12
core/src/cache/CacheMgr.inl
vendored
12
core/src/cache/CacheMgr.inl
vendored
@ -133,17 +133,5 @@ CacheMgr<ItemObj>::SetCapacity(int64_t capacity) {
|
||||
cache_->set_capacity(capacity);
|
||||
}
|
||||
|
||||
template <typename ItemObj>
|
||||
void
|
||||
CacheMgr<ItemObj>::Lock() {
|
||||
mutex_.lock();
|
||||
}
|
||||
|
||||
template <typename ItemObj>
|
||||
void
|
||||
CacheMgr<ItemObj>::Unlock() {
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
||||
} // namespace cache
|
||||
} // namespace milvus
|
||||
|
||||
2
core/src/cache/GpuCacheMgr.cpp
vendored
2
core/src/cache/GpuCacheMgr.cpp
vendored
@ -84,9 +84,7 @@ GpuCacheMgr::GetInstance(int64_t gpu_id) {
|
||||
void
|
||||
GpuCacheMgr::OnGpuCacheCapacityChanged(int64_t capacity) {
|
||||
for (auto& iter : instance_) {
|
||||
iter.second->Lock();
|
||||
iter.second->SetCapacity(capacity * G_BYTE);
|
||||
iter.second->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -555,11 +555,9 @@ ExecutionEngineImpl::CopyToGpu(uint64_t device_id, bool hybrid) {
|
||||
*/
|
||||
ENGINE_LOG_DEBUG << "CPU to GPU" << device_id << " start";
|
||||
auto gpu_cache_mgr = cache::GpuCacheMgr::GetInstance(device_id);
|
||||
// gpu_cache_mgr->Lock();
|
||||
// gpu_cache_mgr->Reserve(index_->Size());
|
||||
index_ = knowhere::cloner::CopyCpuToGpu(index_, device_id, knowhere::Config());
|
||||
// gpu_cache_mgr->InsertItem(location_, std::static_pointer_cast<cache::DataObj>(index_));
|
||||
// gpu_cache_mgr->Unlock();
|
||||
ENGINE_LOG_DEBUG << "CPU to GPU" << device_id << " finished";
|
||||
} catch (std::exception& e) {
|
||||
ENGINE_LOG_ERROR << e.what();
|
||||
@ -577,10 +575,8 @@ ExecutionEngineImpl::CopyToIndexFileToGpu(uint64_t device_id) {
|
||||
// the ToIndexData is only a placeholder, cpu-copy-to-gpu action is performed in
|
||||
if (index_) {
|
||||
auto gpu_cache_mgr = milvus::cache::GpuCacheMgr::GetInstance(device_id);
|
||||
gpu_cache_mgr->Lock();
|
||||
gpu_num_ = device_id;
|
||||
gpu_cache_mgr->Reserve(index_->Size());
|
||||
gpu_cache_mgr->Unlock();
|
||||
}
|
||||
#endif
|
||||
return Status::OK();
|
||||
@ -964,10 +960,8 @@ ExecutionEngineImpl::GetVectorByID(const int64_t& id, uint8_t* vector, bool hybr
|
||||
Status
|
||||
ExecutionEngineImpl::Cache() {
|
||||
auto cpu_cache_mgr = milvus::cache::CpuCacheMgr::GetInstance();
|
||||
cpu_cache_mgr->Lock();
|
||||
cache::DataObjPtr obj = std::static_pointer_cast<cache::DataObj>(index_);
|
||||
cpu_cache_mgr->InsertItem(location_, obj);
|
||||
cpu_cache_mgr->Unlock();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user