Skip to content

Add dense vector off-heap stats to Node stats and Index stats APIs #126704

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

Merged
merged 35 commits into from
Apr 23, 2025

Conversation

ChrisHegarty
Copy link
Contributor

@ChrisHegarty ChrisHegarty commented Apr 11, 2025

This change enhances the dense_vector section of the Nodes stats and Index stats APIs so that they report the desired size of off-heap memory for all indexed vectors. The dense_vector section of the Custer stats API remains unchanged.

The retrieval mechanism and structure of the new stats is the same across the various three stats APIs, but more fine-grained information is disclosed as when moving from Cluster -> Node -> Index API.

For Node stats, we aggregate the total byte sizes for all vectors, categorised by the data type. For example:

"dense_vector" : {
  "value_count" : 5,
  "off_heap" : {
    "total_size_in_bytes" : 27,
    "total_veb_size_in_bytes" : 3,
    "total_vec_size_in_bytes" : 23,
    "total_veq_size_in_bytes" : 0,
    "total_vex_size_in_bytes" : 1
  }
}

Index stats: same as Node stats with included field break down . For example:

"dense_vector" : {
  "value_count" : 5,
  "off_heap" : {
    "total_size_in_bytes" : 27,
    "total_veb_size_in_bytes" : 3,
    "total_vec_size_in_bytes" : 23,
    "total_veq_size_in_bytes" : 0,
    "total_vex_size_in_bytes" : 1,
    "fielddata" : {
      "bar" : {
        "veb_size_in_bytes" : 3,
        "vec_size_in_bytes" : 14,
        "vex_size_in_bytes" : 1
      },
      "foo" : {
        "vec_size_in_bytes" : 9
      }
    }
  }

The implementation accesses the actual statistics through reflection. This will be completely removed when Lucene exposes this, which is expected in Lucene 10.3, see apache/lucene#14426.

@ChrisHegarty ChrisHegarty requested a review from a team as a code owner April 11, 2025 15:24
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Apr 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Hi @ChrisHegarty, I've created a changelog YAML for you.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

I only looked at the reflection bits, and have a thought.

@ChrisHegarty ChrisHegarty changed the title initial changes to support dense vectors off-heap stats Add dense vector off-heap stats to Node stats and Index stats APIs Apr 11, 2025
static {
try {
// Lucene99ScalarQuantizedVectorsReader
var cls = Class.forName("org.apache.lucene.codecs.lucene99.Lucene99ScalarQuantizedVectorsReader$FieldEntry");
Copy link
Member

Choose a reason for hiding this comment

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

I realize it would be even more complicated, but there are all the bwc indices from Lucene (Lucene95, 92, etc.). Do we want to include those? Its probable that folks have data in those old indices.

Its likely fine to do a "good enough" job here and indicate that stats are only available on newer formats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's add them, it's not difficult and will improve usability. When Lucene 10.3 arrives it will have support there too, and we can delete all this reflection code.

@ChrisHegarty
Copy link
Contributor Author

@elasticmachine update branch

@ChrisHegarty
Copy link
Contributor Author

@elasticmachine update branch

@ChrisHegarty
Copy link
Contributor Author

@elasticmachine update branch

@ChrisHegarty ChrisHegarty removed the test-full-bwc Trigger full BWC version matrix tests label Apr 16, 2025
Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

I am confused by delegate thing, maybe I am misunderstanding.

Do we want to add the other older readers later?

@ChrisHegarty
Copy link
Contributor Author

Do we want to add the other older readers later?

The reason I've not added them yet is that they're hard to test. My latest thought is to generate an old index and stuff it into a unit test. Longer term we won't need this, since the Lucene readers will already be tested in Lucene itself, but for now we'd need some minimal sanity on the reflection code.

@ChrisHegarty
Copy link
Contributor Author

@elasticmachine update branch

@elasticmachine
Copy link
Collaborator

merge conflict between base and head

@ChrisHegarty
Copy link
Contributor Author

I added support for the old codecs, see 4638377. I tested these locally, since it's not straightforward to create these old indices.

@ChrisHegarty ChrisHegarty requested a review from benwtrent April 18, 2025 09:28
Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

I am confused by default behavior and if we always want to return these stats or if per-field stats are always returned.

@ChrisHegarty ChrisHegarty merged commit 19550a8 into elastic:main Apr 23, 2025
17 checks passed
@ChrisHegarty ChrisHegarty deleted the dense_vector_stats branch April 23, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Relevance/Search Catch all for Search Relevance :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants