Skip to content

Add graph creation stats to the KNNStats API#1141

Merged
martin-gaievski merged 14 commits intoopensearch-project:mainfrom
ryanbogan:graph_creation_stats
Oct 3, 2023
Merged

Add graph creation stats to the KNNStats API#1141
martin-gaievski merged 14 commits intoopensearch-project:mainfrom
ryanbogan:graph_creation_stats

Conversation

@ryanbogan
Copy link
Copy Markdown
Member

@ryanbogan ryanbogan commented Sep 18, 2023

Description

Adds graph creation stats to the KNNStats API

Old:

{
  "_nodes": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "cluster_name": "903360760764:navneet-test-domain",
  "circuit_breaker_triggered": false,
  "model_index_status": null,
  "nodes": {
    "H4Bf02YSRr2UBc_kjuEduw": {
      "graph_memory_usage_percentage": 0.00015215651,
      "graph_query_requests": 0,
      "graph_memory_usage": 3,
      "cache_capacity_reached": false,
      "load_success_count": 3,
      "training_memory_usage": 0,
      "indices_in_cache": {
        "products-shirts": {
          "graph_memory_usage_percentage": 0.00015215651,
          "graph_memory_usage": 3,
          "graph_count": 3
        }
      },
      "script_query_errors": 0,
      "hit_count": 0,
      "knn_query_requests": 0,
      "total_load_time": 9907321,
      "miss_count": 3,
      "knn_query_with_filter_requests": 0,
      "training_memory_usage_percentage": 0,
      "lucene_initialized": false,
      "graph_index_requests": 3,
      "faiss_initialized": true,
      "load_exception_count": 0,
      "training_errors": 0,
      "eviction_count": 0,
      "nmslib_initialized": false,
      "script_compilations": 0,
      "script_query_requests": 0,
      "graph_query_errors": 0,
      "indexing_from_model_degraded": false,
      "graph_index_errors": 0,
      "training_requests": 0,
      "script_compilation_errors": 0
    }
  }
}

New stats being added:

"graph_stats": {
    "merge": {
        "current": 0,
        "current_docs": 0,
        "current_size_in_bytes": 0,
        "total": 0,
        "total_time_in_millis": 0,
        "total_docs": 0
    },
    "refresh": {
        "total": 0,
        "total_time_in_millis": 0
    }
}

Issues Resolved

#999

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed as per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 18, 2023

Codecov Report

Merging #1141 (49f6d46) into main (5dd9780) will increase coverage by 0.14%.
The diff coverage is 92.38%.

@@             Coverage Diff              @@
##               main    #1141      +/-   ##
============================================
+ Coverage     84.96%   85.10%   +0.14%     
- Complexity     1192     1211      +19     
============================================
  Files           159      160       +1     
  Lines          4842     4942     +100     
  Branches        440      448       +8     
============================================
+ Hits           4114     4206      +92     
- Misses          530      537       +7     
- Partials        198      199       +1     
Files Coverage Δ
...index/codec/KNN80Codec/KNN80DocValuesConsumer.java 91.03% <100.00%> (+2.33%) ⬆️
...n/index/codec/util/KNNVectorSerializerFactory.java 96.29% <ø> (ø)
...org/opensearch/knn/plugin/stats/KNNGraphValue.java 100.00% <100.00%> (ø)
...java/org/opensearch/knn/plugin/stats/KNNStats.java 100.00% <100.00%> (ø)
...ava/org/opensearch/knn/plugin/stats/StatNames.java 100.00% <100.00%> (ø)
.../opensearch/knn/index/codec/util/KNNCodecUtil.java 77.50% <66.66%> (-16.95%) ⬇️

Copy link
Copy Markdown
Collaborator

@navneet1v navneet1v left a comment

Choose a reason for hiding this comment

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

Can you add the new stats response in the PR description both old and new

Comment thread src/main/java/org/opensearch/knn/plugin/stats/StatNames.java
@navneet1v
Copy link
Copy Markdown
Collaborator

Please link the GH issue in the description.

@ryanbogan
Copy link
Copy Markdown
Member Author

Please link the GH issue in the description.

There wasn't one for this change.

@navneet1v
Copy link
Copy Markdown
Collaborator

Please link the GH issue in the description.

There wasn't one for this change.

this was the issue: #999

Comment thread src/main/java/org/opensearch/knn/plugin/stats/KNNGraphValue.java Outdated
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Comment thread src/main/java/org/opensearch/knn/index/codec/util/KNNCodecUtil.java
@navneet1v
Copy link
Copy Markdown
Collaborator

@ryanbogan the task also includes adding the logs for these stats, I am not seeing it in the PR. can we add the relevant logs for merge and refresh?

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Copy link
Copy Markdown
Collaborator

@navneet1v navneet1v left a comment

Choose a reason for hiding this comment

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

Overall code looks good to me. Please resolve all the comments and conversation.

@ryanbogan ryanbogan requested a review from navneet1v September 28, 2023 16:49
@navneet1v
Copy link
Copy Markdown
Collaborator

@ryanbogan there are conflicts in the Changelog.md please fix that. Merge is blocked.

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
@ryanbogan
Copy link
Copy Markdown
Member Author

@navneet1v should be fixed now

@navneet1v
Copy link
Copy Markdown
Collaborator

@navneet1v should be fixed now

@ryanbogan approved

@ryanbogan
Copy link
Copy Markdown
Member Author

Performance testing results

With change:
"results": {
"test_took": 253624.85724590067,
"delete_index_took_total": 282.29088229982153,
"create_index_took_total": 430.6469659999493,
"ingest_took_total": 65798.45976050038,
"refresh_index_store_kb_total": 1380712.7157226563,
"refresh_index_took_total": 10007.285990400305,
"warmup_operation_took_total": 487.07364670026436,
"query_took_total": 176619.1,
"query_took_p50": 17.7,
"query_took_p90": 19.7,
"query_took_p99": 21.3,
"query_took_p99.9": 38.4,
"query_took_p100": 46.8,
"query_client_time_total": 203427.4,
"query_client_time_p50": 20.2,
"query_client_time_p90": 22.1,
"query_client_time_p99": 24.0,
"query_client_time_p99.9": 51.0,
"query_client_time_p100": 304.0,
"query_memory_kb_total": 652816.0,
"query_recall@K_total": 0.9997133,
"query_recall@1_total": 1.0
}

Without change:
"results": {
"test_took": 251924.78345970024,
"delete_index_took_total": 306.656430199655,
"create_index_took_total": 448.1916740998713,
"ingest_took_total": 65752.38597490061,
"refresh_index_store_kb_total": 1418928.1783203124,
"refresh_index_took_total": 9903.949380500126,
"query_took_total": 175513.6,
"query_took_p50": 17.5,
"query_took_p90": 19.4,
"query_took_p99": 21.0,
"query_took_p99.9": 38.1,
"query_took_p100": 135.7,
"query_client_time_total": 202541.7,
"query_client_time_p50": 20.1,
"query_client_time_p90": 22.1,
"query_client_time_p99": 23.9,
"query_client_time_p99.9": 62.3,
"query_client_time_p100": 307.2,
"query_memory_kb_total": 652814.7,
"query_recall@K_total": 0.9997167000000001,
"query_recall@1_total": 1.0
}

@martin-gaievski martin-gaievski merged commit 9e3e046 into opensearch-project:main Oct 3, 2023
@opensearch-trigger-bot
Copy link
Copy Markdown
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1141-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9e3e04660e0bb8a3a1a9bb6d69928dd86d202eb2
# Push it to GitHub
git push --set-upstream origin backport/backport-1141-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1141-to-2.x.

@ryanbogan ryanbogan deleted the graph_creation_stats branch October 4, 2023 15:31
jingqimao77-spec pushed a commit to jingqimao77-spec/k-NN that referenced this pull request Mar 15, 2026
* Add graph stats to KNN Stats API

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants