-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support basic searcher #351
Conversation
src/allocator_wrapper.h
Outdated
template <typename T, typename U> | ||
bool | ||
operator==(const AllocatorWrapper<T>&, const AllocatorWrapper<U>&) noexcept { | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
src/data_cell/flatten_datacell.h
Outdated
@@ -70,6 +70,11 @@ class FlattenDataCell : public FlattenInterface { | |||
io_->Prefetch(id * code_size_); | |||
}; | |||
|
|||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.cpp
Outdated
|
||
template <typename GraphTmpl, typename VectorDataTmpl> | ||
BasicSearcher<GraphTmpl, VectorDataTmpl>::BasicSearcher(std::shared_ptr<GraphTmpl> graph, | ||
std::shared_ptr<VectorDataTmpl> vector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use interface is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.cpp
Outdated
for (uint32_t i = 0; i < neighbors.size(); i++) { | ||
#ifdef USE_SSE | ||
if (i + prefetch_neighbor_visit_num_ < neighbors.size()) { | ||
_mm_prefetch(vl->mass + neighbors[i + prefetch_neighbor_visit_num_], _MM_HINT_T0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
0d51c38
to
b267091
Compare
src/impl/basic_searcher.h
Outdated
#include <shared_mutex> | ||
|
||
#include "../utils.h" | ||
#include "ThreadPool.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused header files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/runtime_parameter.h
Outdated
#include <string> | ||
#include <thread> | ||
#include <variant> | ||
#include <vector> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
#include "fixtures.h" | ||
#include "io/memory_io.h" | ||
#include "quantization/fp32_quantizer.h" | ||
#include "safe_allocator.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher_test.cpp
Outdated
REQUIRE(result.top().second == valid_result.top().second); | ||
REQUIRE(result.top().second == ids[i]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/runtime_parameter.h
Outdated
int cur_{0}; | ||
bool is_end_{false}; | ||
}; | ||
} // namespace vsag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.h
Outdated
uint32_t prefetch_neighbor_visit_num_{1}; | ||
}; | ||
|
||
} // namespace vsag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.cpp
Outdated
} | ||
|
||
MaxHeap | ||
BasicSearcher::Search(const float* query, InnerSearchParam& inner_search_param) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const InnerSearchParam& inner_search_param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/data_cell/flatten_datacell.h
Outdated
@@ -226,7 +226,18 @@ FlattenDataCell<QuantTmpl, IOTmpl>::query(float* result_dists, | |||
const std::shared_ptr<Computer<QuantTmpl>>& computer, | |||
const InnerIdType* idx, | |||
InnerIdType id_count) { | |||
for (uint32_t i = 0; i < this->prefetch_neighbor_codes_num_ and i < id_count; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefetch_neighbor_codes_num_
is always 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be further optimized by optimizer
8af23a1
to
6450d83
Compare
6450d83
to
a8a6a01
Compare
Codecov ReportAttention: Patch coverage is @@ Coverage Diff @@
## main #351 +/- ##
==========================================
+ Coverage 90.94% 91.06% +0.12%
==========================================
Files 133 134 +1
Lines 8459 8542 +83
==========================================
+ Hits 7693 7779 +86
+ Misses 766 763 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
src/impl/basic_searcher.cpp
Outdated
|
||
void | ||
BasicSearcher::SetGraphAndVector(GraphInterfacePtr graph_data_cell, | ||
FlattenInterfacePtr vector_data_cell) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split two function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.cpp
Outdated
std::pair<float, uint64_t>& current_node_pair, | ||
Vector<InnerIdType>& to_be_visited_rid, | ||
Vector<InnerIdType>& to_be_visited_id) const { | ||
// to_be_visited_rid is used in redundant storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant not used now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comment for distinguish to_be_visited_rid and to_be_visited_id in basic_search.h
src/impl/basic_searcher.cpp
Outdated
} | ||
|
||
void | ||
BasicSearcher::SetGraphAndVector(GraphInterfacePtr graph_data_cell, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use interface name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.cpp
Outdated
uint32_t hops = 0; | ||
uint32_t dist_cmp = 0; | ||
uint32_t count_no_visited = 0; | ||
Vector<InnerIdType> to_be_visited_rid(graph_data_cell_->MaximumDegree(), allocator_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a8a6a01
to
cb903ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
9657fd4
to
b789120
Compare
src/impl/basic_searcher.h
Outdated
virtual MaxHeap | ||
Search(GraphInterfacePtr graph_data_cell, | ||
FlattenInterfacePtr vector_data_cell, | ||
hnswlib::VisitedListPtr vl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ResourceObjectPool
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.h
Outdated
|
||
virtual MaxHeap | ||
Search(GraphInterfacePtr graph_data_cell, | ||
FlattenInterfacePtr vector_data_cell, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const GraphInterfacePtr& graph_data_cell
const FlattenInterfacePtr& vector_data_cell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/impl/basic_searcher.cpp
Outdated
uint32_t | ||
BasicSearcher::visit(const GraphInterfacePtr& graph_data_cell, | ||
std::shared_ptr<vsag::VisitedList> vl, | ||
std::pair<float, uint64_t>& current_node_pair, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vsag:: no useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: zhongxiaoyao.zxy <[email protected]>
503771d
to
9d96e8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
#278