Skip to content

Improving statsByShard performance when the number of shards is very large#130857

Merged
masseyke merged 44 commits intoelastic:mainfrom
masseyke:fix/statsByShard-performance
Nov 7, 2025
Merged

Improving statsByShard performance when the number of shards is very large#130857
masseyke merged 44 commits intoelastic:mainfrom
masseyke:fix/statsByShard-performance

Conversation

@masseyke
Copy link
Copy Markdown
Member

@masseyke masseyke commented Jul 8, 2025

This fixes IndicesService.statsByShard() so that it no longer has O(N^2) performance (where N is the number of shards in the cache). It does this by pre-computing the total number of objects in the cache and the total number of shards represented in the cache, so that these don't have to be calculated for each shard.

Closes #97222

@masseyke masseyke added >bug :Core/Infra/Stats Statistics tracking and retrieval APIs v9.2.0 labels Jul 8, 2025
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@masseyke
Copy link
Copy Markdown
Member Author

This is related to #97222

@masseyke masseyke changed the title First attempt at improving statsByShard performance Improving statsByShard performance when the number of shards is very large Sep 26, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 7, 2025
…large (elastic#130857)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
elasticsearchmachine pushed a commit that referenced this pull request Nov 7, 2025
…large (#130857) (#137749)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 7, 2025
…large (elastic#130857)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
(cherry picked from commit 22c15bc)
@masseyke
Copy link
Copy Markdown
Member Author

masseyke commented Nov 7, 2025

💚 All backports created successfully

Status Branch Result
9.1
8.19

Questions ?

Please refer to the Backport tool documentation

masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 7, 2025
…large (elastic#130857)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
(cherry picked from commit 22c15bc)

# Conflicts:
#	server/src/test/java/org/elasticsearch/indices/IndicesQueryCacheTests.java
elasticsearchmachine pushed a commit that referenced this pull request Nov 7, 2025
…large (#130857) (#137766)

(cherry picked from commit 22c15bc)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
elasticsearchmachine pushed a commit that referenced this pull request Nov 7, 2025
…large (#130857) (#137768)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
(cherry picked from commit 22c15bc)

# Conflicts:
#	server/src/test/java/org/elasticsearch/indices/IndicesQueryCacheTests.java
Kubik42 pushed a commit to Kubik42/elasticsearch that referenced this pull request Nov 10, 2025
…large (elastic#130857)

Co-authored-by: Joe Gallo <joe.gallo@elastic.co>
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 12, 2025
masseyke added a commit that referenced this pull request Nov 12, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 12, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 12, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 12, 2025
elasticsearchmachine pushed a commit that referenced this pull request Nov 12, 2025
elasticsearchmachine pushed a commit that referenced this pull request Nov 12, 2025
masseyke added a commit that referenced this pull request Nov 12, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 12, 2025
…is very large (elastic#130857)" (elastic#137973)

This reverts commit 22c15bc.

(cherry picked from commit e138f5f)

# Conflicts:
#	server/src/test/java/org/elasticsearch/indices/IndicesQueryCacheTests.java
masseyke added a commit that referenced this pull request Nov 13, 2025
…is very large (#130857)" (#137973) (#137993)

This reverts commit 22c15bc.

(cherry picked from commit e138f5f)
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 14, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending >bug :Core/Infra/Stats Statistics tracking and retrieval APIs Team:Data Management (obsolete) DO NOT USE. This team no longer exists. v8.19.8 v9.1.8 v9.2.2 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Computing IndicesQueryCache stats is O(N²) in shard count

4 participants