Skip to content
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

Record knowhere index build time #148

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/knowhere/prometheus_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ DECLARE_PROMETHEUS_COUNTER(knowhere_build_count);
DECLARE_PROMETHEUS_COUNTER(knowhere_search_count);
DECLARE_PROMETHEUS_COUNTER(knowhere_ann_iterator_count);
DECLARE_PROMETHEUS_COUNTER(knowhere_range_search_count);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_build_latency);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_search_topk);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_search_latency);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_ann_iterator_init_latency);
Expand Down
9 changes: 8 additions & 1 deletion src/common/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ Index<T>::Build(const DataSet& dataset, const Json& json) {
RETURN_IF_ERROR(cfg->CheckAndAdjustForBuild());

#ifdef NOT_COMPILE_FOR_SWIG
TimeRecorder rc("Build index", 2);
auto res = this->node->Build(dataset, *cfg);
auto span = rc.ElapseFromBegin("done");
span *= 0.000001; // convert to s
knowhere_build_latency.Observe(span);
knowhere_build_count.Increment();
#else
auto res = this->node->Build(dataset, *cfg);
#endif
return this->node->Build(dataset, *cfg);
return res;
}

template <typename T>
Expand Down
1 change: 1 addition & 0 deletions src/common/prometheus_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ DEFINE_PROMETHEUS_COUNTER(knowhere_build_count, "knowhere index build count")
DEFINE_PROMETHEUS_COUNTER(knowhere_search_count, "knowhere search count")
DEFINE_PROMETHEUS_COUNTER(knowhere_ann_iterator_count, "knowhere ann iterator count")
DEFINE_PROMETHEUS_COUNTER(knowhere_range_search_count, "knowhere range search count")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_build_latency, "index build latency in knowhere (s)")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_search_topk, "knowhere search topk")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_search_latency, "search latency in knowhere (ms)")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_ann_iterator_init_latency, "ann iterator init latency in knowhere (ms)")
Expand Down
Loading