Skip to content
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 @@ -75,6 +75,7 @@ extern const std::unique_ptr<PrometheusClient> prometheusClient;
#define DECLARE_PROMETHEUS_HISTOGRAM(name_histogram) extern prometheus::Histogram& name_histogram;

DECLARE_PROMETHEUS_HISTOGRAM(knowhere_build_latency);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_load_latency);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_search_latency);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_range_search_latency);
DECLARE_PROMETHEUS_HISTOGRAM(knowhere_ann_iterator_init_latency);
Expand Down
24 changes: 22 additions & 2 deletions src/common/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,17 @@ Index<T>::Deserialize(const BinarySet& binset, const Json& json) {
if (res != Status::success) {
return res;
}
return this->node->Deserialize(binset, *cfg);

#ifdef NOT_COMPILE_FOR_SWIG

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this #ifdef needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need build swig pyknowhere for CI test, prometheus cannot pass swig build

TimeRecorder rc("Load index", 2);
res = this->node->Deserialize(binset, *cfg);
auto span = rc.ElapseFromBegin("done");
span *= 0.001; // convert to ms
knowhere_load_latency.Observe(span);
#else
res = this->node->Deserialize(binset, *cfg);
#endif
return res;
}

template <typename T>
Expand All @@ -198,7 +208,17 @@ Index<T>::DeserializeFromFile(const std::string& filename, const Json& json) {
if (res != Status::success) {
return res;
}
return this->node->DeserializeFromFile(filename, *cfg);

#ifdef NOT_COMPILE_FOR_SWIG
TimeRecorder rc("Load index from file", 2);
res = this->node->DeserializeFromFile(filename, *cfg);
auto span = rc.ElapseFromBegin("done");
span *= 0.001; // convert to ms
knowhere_load_latency.Observe(span);
#else
res = this->node->DeserializeFromFile(filename, *cfg);
#endif
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 @@ -26,6 +26,7 @@ const std::unique_ptr<PrometheusClient> prometheusClient = std::make_unique<Prom
* text format parsing error in line 50: expected float as value, got "=\"0.9\"}"
******************************************************************************/
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_build_latency, "index build latency in knowhere (s)")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_load_latency, "index load latency in knowhere (ms)")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_search_latency, "search latency in knowhere (ms)")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_range_search_latency, "range search latency in knowhere (ms)")
DEFINE_PROMETHEUS_HISTOGRAM(knowhere_ann_iterator_init_latency, "ann iterator init latency in knowhere (ms)")
Expand Down