remove unnecessary lock (#1801)

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
Cai Yudong 2020-03-30 14:13:02 +08:00 committed by GitHub
parent 8a731dea39
commit dbbf91db28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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();
}
}

View File

@ -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();
}