Skip to content

Commit

Permalink
Add hardware usage to grpc API (#5333)
Browse files Browse the repository at this point in the history
* Add hardware usage to grpc API

* generate grpc docs
  • Loading branch information
JojiiOfficial authored Nov 5, 2024
1 parent 978c4bd commit e35ec15
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 43 deletions.
30 changes: 30 additions & 0 deletions docs/grpc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
- [GetResponse](#qdrant-GetResponse)
- [GroupId](#qdrant-GroupId)
- [GroupsResult](#qdrant-GroupsResult)
- [HardwareUsage](#qdrant-HardwareUsage)
- [HasIdCondition](#qdrant-HasIdCondition)
- [HasVectorCondition](#qdrant-HasVectorCondition)
- [Image](#qdrant-Image)
Expand Down Expand Up @@ -2218,6 +2219,7 @@ The JSON representation for `Value` is a JSON value.
| ----- | ---- | ----- | ----------- |
| result | [CountResult](#qdrant-CountResult) | | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -2397,6 +2399,7 @@ The JSON representation for `Value` is a JSON value.
| ----- | ---- | ----- | ----------- |
| result | [BatchResult](#qdrant-BatchResult) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -2457,6 +2460,7 @@ The JSON representation for `Value` is a JSON value.
| ----- | ---- | ----- | ----------- |
| result | [ScoredPoint](#qdrant-ScoredPoint) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -2756,6 +2760,21 @@ Additionally, the first and last points of each GeoLineString must be the same.



<a name="qdrant-HardwareUsage"></a>

### HardwareUsage



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| cpu | [uint64](#uint64) | | |






<a name="qdrant-HasIdCondition"></a>

### HasIdCondition
Expand Down Expand Up @@ -3504,6 +3523,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [BatchResult](#qdrant-BatchResult) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand All @@ -3520,6 +3540,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [GroupsResult](#qdrant-GroupsResult) | | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -3596,6 +3617,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [ScoredPoint](#qdrant-ScoredPoint) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -3664,6 +3686,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [BatchResult](#qdrant-BatchResult) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand All @@ -3680,6 +3703,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [GroupsResult](#qdrant-GroupsResult) | | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -3779,6 +3803,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [ScoredPoint](#qdrant-ScoredPoint) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -3956,6 +3981,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [BatchResult](#qdrant-BatchResult) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand All @@ -3972,6 +3998,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [GroupsResult](#qdrant-GroupsResult) | | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -4006,6 +4033,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [SearchMatrixOffsets](#qdrant-SearchMatrixOffsets) | | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -4054,6 +4082,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [SearchMatrixPairs](#qdrant-SearchMatrixPairs) | | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down Expand Up @@ -4168,6 +4197,7 @@ For example, if `oversampling` is 2.4 and `limit` is 100, then 240 vectors will
| ----- | ---- | ----- | ----------- |
| result | [ScoredPoint](#qdrant-ScoredPoint) | repeated | |
| time | [double](#double) | | Time spent to process |
| usage | [HardwareUsage](#qdrant-HardwareUsage) | optional | |



Expand Down
11 changes: 10 additions & 1 deletion lib/api/src/grpc/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::str::FromStr as _;
use std::time::Instant;

use chrono::{NaiveDateTime, Timelike};
use common::counter::hardware_accumulator::HwMeasurementAcc;
use itertools::Itertools;
use segment::common::operation_error::OperationError;
use segment::data_types::index::{
Expand All @@ -21,7 +22,7 @@ use super::qdrant::{
raw_query, start_from, BinaryQuantization, BoolIndexParams, CompressionRatio,
DatetimeIndexParams, DatetimeRange, Direction, FacetHit, FacetHitInternal, FacetValue,
FacetValueInternal, FieldType, FloatIndexParams, GeoIndexParams, GeoLineString, GroupId,
HasVectorCondition, KeywordIndexParams, LookupLocation, MultiVectorComparator,
HardwareUsage, HasVectorCondition, KeywordIndexParams, LookupLocation, MultiVectorComparator,
MultiVectorConfig, OrderBy, OrderValue, Range, RawVector, RecommendStrategy, RetrievedPoint,
SearchMatrixPair, SearchPointGroups, SearchPoints, ShardKeySelector, SparseIndices, StartFrom,
UuidIndexParams, VectorsOutput, WithLookup,
Expand Down Expand Up @@ -2129,3 +2130,11 @@ impl From<rest::SearchMatrixPair> for SearchMatrixPair {
}
}
}

impl From<HwMeasurementAcc> for HardwareUsage {
fn from(value: HwMeasurementAcc) -> Self {
Self {
cpu: value.get_cpu() as u64,
}
}
}
22 changes: 22 additions & 0 deletions lib/api/src/grpc/proto/points.proto
Original file line number Diff line number Diff line change
Expand Up @@ -817,21 +817,25 @@ message GroupsResult {
message SearchResponse {
repeated ScoredPoint result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message QueryResponse {
repeated ScoredPoint result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message QueryBatchResponse {
repeated BatchResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message QueryGroupsResponse {
GroupsResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message BatchResult {
Expand All @@ -841,16 +845,19 @@ message BatchResult {
message SearchBatchResponse {
repeated BatchResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message SearchGroupsResponse {
GroupsResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message CountResponse {
CountResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message ScrollResponse {
Expand Down Expand Up @@ -880,26 +887,31 @@ message GetResponse {
message RecommendResponse {
repeated ScoredPoint result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message RecommendBatchResponse {
repeated BatchResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message DiscoverResponse {
repeated ScoredPoint result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message DiscoverBatchResponse {
repeated BatchResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message RecommendGroupsResponse {
GroupsResult result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message UpdateBatchResponse {
Expand All @@ -915,11 +927,13 @@ message FacetResponse {
message SearchMatrixPairsResponse {
SearchMatrixPairs result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

message SearchMatrixOffsetsResponse {
SearchMatrixOffsets result = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 3;
}

// ---------------------------------------------
Expand Down Expand Up @@ -1077,3 +1091,11 @@ message GeoPoint {
double lon = 1;
double lat = 2;
}

// ---------------------------------------------
// ------------ Hardware measurements ----------
// ---------------------------------------------

message HardwareUsage {
uint64 cpu = 1;
}
1 change: 1 addition & 0 deletions lib/api/src/grpc/proto/points_internal_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ message QueryResultInternal {
message QueryBatchResponseInternal {
repeated QueryResultInternal results = 1;
double time = 2; // Time spent to process
optional HardwareUsage usage = 5;
}

message FacetCountsInternal {
Expand Down
Loading

0 comments on commit e35ec15

Please sign in to comment.