@@ -156,7 +156,6 @@ class DiskANNIndexNode : public IndexNode {
156156 std::string index_prefix_;
157157 mutable std::mutex preparation_lock_;
158158 std::atomic_bool is_prepared_;
159- int32_t num_threads_;
160159 std::shared_ptr<FileManager> file_manager_;
161160 std::unique_ptr<diskann::PQFlashIndex<T>> pq_flash_index_;
162161 std::atomic_int64_t dim_;
@@ -280,7 +279,6 @@ DiskANNIndexNode<T>::Add(const DataSet& dataset, const Config& cfg) {
280279 static_cast <unsigned >(build_conf.search_list_size ),
281280 static_cast <double >(build_conf.pq_code_budget_gb ),
282281 static_cast <double >(build_conf.build_dram_budget_gb ),
283- static_cast <uint32_t >(build_conf.num_threads ),
284282 static_cast <uint32_t >(build_conf.disk_pq_dims ),
285283 false ,
286284 build_conf.accelerate_build };
@@ -355,8 +353,8 @@ DiskANNIndexNode<T>::Prepare(const Config& cfg) {
355353
356354 pq_flash_index_ = std::make_unique<diskann::PQFlashIndex<T>>(reader, diskann_metric);
357355
358- auto load_expect = TryDiskANNCall< int >(
359- [&]() -> int { return pq_flash_index_->load (prep_conf. num_threads , index_prefix_.c_str ()); });
356+ auto load_expect =
357+ TryDiskANNCall< int >( [&]() -> int { return pq_flash_index_->load (pool_-> size () , index_prefix_.c_str ()); });
360358
361359 if (!load_expect.has_value () || load_expect.value () != 0 ) {
362360 LOG_KNOWHERE_ERROR_ << " Failed to load DiskANN." ;
@@ -397,7 +395,7 @@ DiskANNIndexNode<T>::Prepare(const Config& cfg) {
397395 } else {
398396 auto gen_cache_expect = TryDiskANNCall<bool >([&]() -> bool {
399397 pq_flash_index_->generate_cache_list_from_sample_queries (warmup_query_file, 15 , 6 , num_nodes_to_cache,
400- prep_conf. num_threads , node_list);
398+ node_list);
401399 return true ;
402400 });
403401
@@ -417,10 +415,6 @@ DiskANNIndexNode<T>::Prepare(const Config& cfg) {
417415 }
418416 }
419417
420- // set thread number
421- omp_set_num_threads (prep_conf.num_threads );
422- num_threads_ = prep_conf.num_threads ;
423-
424418 // warmup
425419 if (prep_conf.warm_up ) {
426420 LOG_KNOWHERE_INFO_ << " Warming up." ;
@@ -441,15 +435,22 @@ DiskANNIndexNode<T>::Prepare(const Config& cfg) {
441435 std::vector<float > warmup_result_dists (warmup_num, 0 );
442436
443437 bool all_searches_are_good = true ;
444- #pragma omp parallel for schedule(dynamic, 1)
438+
439+ std::vector<std::future<void >> futures;
440+ futures.reserve (warmup_num);
445441 for (_s64 i = 0 ; i < (int64_t )warmup_num; ++i) {
446- auto search_expect = TryDiskANNCall<bool >([&]() -> bool {
447- pq_flash_index_->cached_beam_search (warmup + (i * warmup_aligned_dim), 1 , warmup_L,
448- warmup_result_ids_64.data () + (i * 1 ),
449- warmup_result_dists.data () + (i * 1 ), 4 );
442+ futures.push_back (pool_->push ([&, index = i]() {
443+ pq_flash_index_->cached_beam_search (warmup + (index * warmup_aligned_dim), 1 , warmup_L,
444+ warmup_result_ids_64.data () + (index * 1 ),
445+ warmup_result_dists.data () + (index * 1 ), 4 );
446+ }));
447+ }
448+ for (auto & future : futures) {
449+ auto one_search_res = TryDiskANNCall<bool >([&]() {
450+ future.get ();
450451 return true ;
451452 });
452- if (!search_expect .has_value ()) {
453+ if (!one_search_res .has_value ()) {
453454 all_searches_are_good = false ;
454455 }
455456 }
@@ -507,6 +508,7 @@ DiskANNIndexNode<T>::Search(const DataSet& dataset, const Config& cfg, const Bit
507508 auto p_id = new int64_t [k * nq];
508509 auto p_dist = new float [k * nq];
509510
511+ bool all_searches_are_good = true ;
510512 std::vector<std::future<void >> futures;
511513 futures.reserve (nq);
512514 for (int64_t row = 0 ; row < nq; ++row) {
@@ -516,7 +518,17 @@ DiskANNIndexNode<T>::Search(const DataSet& dataset, const Config& cfg, const Bit
516518 }));
517519 }
518520 for (auto & future : futures) {
519- future.get ();
521+ auto one_search_res = TryDiskANNCall<bool >([&]() {
522+ future.get ();
523+ return true ;
524+ });
525+ if (!one_search_res.has_value ()) {
526+ all_searches_are_good = false ;
527+ }
528+ }
529+
530+ if (!all_searches_are_good) {
531+ return unexpected (Status::diskann_inner_error);
520532 }
521533
522534 auto res = GenResultDataSet (nq, k, p_id, p_dist);
@@ -572,6 +584,7 @@ DiskANNIndexNode<T>::RangeSearch(const DataSet& dataset, const Config& cfg, cons
572584
573585 std::vector<std::future<void >> futures;
574586 futures.reserve (nq);
587+ bool all_searches_are_good = true ;
575588 for (int64_t row = 0 ; row < nq; ++row) {
576589 futures.push_back (pool_->push ([&, index = row]() {
577590 std::vector<int64_t > indices;
@@ -586,8 +599,18 @@ DiskANNIndexNode<T>::RangeSearch(const DataSet& dataset, const Config& cfg, cons
586599 }));
587600 }
588601 for (auto & future : futures) {
589- future.get ();
602+ auto one_search_res = TryDiskANNCall<bool >([&]() {
603+ future.get ();
604+ return true ;
605+ });
606+ if (!one_search_res.has_value ()) {
607+ all_searches_are_good = false ;
608+ }
590609 }
610+ if (!all_searches_are_good) {
611+ return unexpected (Status::diskann_inner_error);
612+ }
613+
591614 GetRangeSearchResult (result_dist_array, result_id_array, is_ip, nq, radius, search_conf.range_filter , p_dist, p_id,
592615 p_lims);
593616 return GenResultDataSet (nq, p_id, p_dist, p_lims);
@@ -603,8 +626,7 @@ DiskANNIndexNode<T>::GetIndexMeta(const Config& cfg) const {
603626 auto diskann_conf = static_cast <const DiskANNConfig&>(cfg);
604627 feder::diskann::DiskANNMeta meta (diskann_conf.data_path , diskann_conf.max_degree , diskann_conf.search_list_size ,
605628 diskann_conf.pq_code_budget_gb , diskann_conf.build_dram_budget_gb ,
606- diskann_conf.num_threads , diskann_conf.disk_pq_dims , diskann_conf.accelerate_build ,
607- Count (), entry_points);
629+ diskann_conf.disk_pq_dims , diskann_conf.accelerate_build , Count (), entry_points);
608630 std::unordered_set<int64_t > id_set (entry_points.begin (), entry_points.end ());
609631
610632 Json json_meta, json_id_set;
0 commit comments