Commit b473fca8 authored by Jin Hai's avatar Jin Hai Committed by GitHub
Browse files

Merge pull request #150 from scsven/dev

Improve large query optimizer pass

Former-commit-id: 32eebbead2b5142b2590e1e1e69a12044eb21259
parents cb8b8566 3639af60
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ Please mark all change in change log and use the ticket from JIRA.
- \#118 - Using shared_ptr instead of weak_ptr to avoid performance loss
- \#122 - Add unique id for Job
- \#130 - Set task state MOVED after resource copy it completed
- \#149 - Improve large query optimizer pass

## Task

+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ Status
ExecutionEngineImpl::CopyToGpu(uint64_t device_id, bool hybrid) {
    if (hybrid) {
        const std::string key = location_ + ".quantizer";
        std::vector<uint64_t> gpus = scheduler::get_gpu_pool();
        std::vector<uint64_t> gpus{device_id};

        const int64_t NOT_FOUND = -1;
        int64_t device_id = NOT_FOUND;
+12 −10
Original line number Diff line number Diff line
@@ -55,16 +55,18 @@ LargeSQ8HPass::Run(const TaskPtr& task) {
    }

    std::vector<uint64_t> gpus = scheduler::get_gpu_pool();
    std::vector<int64_t> all_free_mem;
    for (auto& gpu : gpus) {
        auto cache = cache::GpuCacheMgr::GetInstance(gpu);
        auto free_mem = cache->CacheCapacity() - cache->CacheUsage();
        all_free_mem.push_back(free_mem);
    }

    auto max_e = std::max_element(all_free_mem.begin(), all_free_mem.end());
    auto best_index = std::distance(all_free_mem.begin(), max_e);
    auto best_device_id = gpus[best_index];
    //    std::vector<int64_t> all_free_mem;
    //    for (auto& gpu : gpus) {
    //        auto cache = cache::GpuCacheMgr::GetInstance(gpu);
    //        auto free_mem = cache->CacheCapacity() - cache->CacheUsage();
    //        all_free_mem.push_back(free_mem);
    //    }
    //
    //    auto max_e = std::max_element(all_free_mem.begin(), all_free_mem.end());
    //    auto best_index = std::distance(all_free_mem.begin(), max_e);
    //    auto best_device_id = gpus[best_index];
    auto best_device_id = count_ % gpus.size();
    count_++;

    ResourcePtr res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, best_device_id);
    if (not res_ptr) {
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ class LargeSQ8HPass : public Pass {

 private:
    int32_t threshold_ = std::numeric_limits<int32_t>::max();
    int64_t count_ = 0;
};

using LargeSQ8HPassPtr = std::shared_ptr<LargeSQ8HPass>;