Skip to content

Conversation

@masseyke
Copy link
Member

This avoids performing an N^2 loop through indices when we call GET /*/_rollup/data. This can save a few seconds per call for clusters with a very large number of indices.

@masseyke masseyke added >bug :StorageEngine/Rollup Turn fine-grained time-based data into coarser-grained data v9.3.0 labels Nov 19, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@masseyke
Copy link
Member Author

Here's what it looks like calling GET /*/_rollup/data on a cluster with 16,500 indices without this fix (the response takes about 2s):
Screenshot 2025-11-19 at 9 51 46 AM

@masseyke masseyke requested a review from nielsbauman November 19, 2025 15:57
Copy link
Contributor

@nielsbauman nielsbauman left a comment

Choose a reason for hiding this comment

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

Left one optional suggestion, other than that LGTM. Thanks Keith :)

static Map<String, RollableIndexCaps> getCapsByRollupIndex(Collection<String> resolvedIndexNames, Map<String, IndexMetadata> indices) {
Map<String, List<RollupJobCaps>> allCaps = new TreeMap<>();

indices.entrySet().stream().filter(entry -> resolvedIndexNames.contains(entry.getKey())).forEach(entry -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it's worth converting this to a regular for-each loop (instead of using the Streams API)?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't seem like it would matter much for a single pass through a collection, does it?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is, this is only hot code b/c it's in an N^2 for loop -- the method itself isn't called all that often.

@masseyke masseyke merged commit 0c4e141 into elastic:main Nov 19, 2025
34 checks passed
@masseyke masseyke deleted the fix-TransportGetRollupIndexCapsAction-slowness branch November 19, 2025 21:08
ncordon pushed a commit to ncordon/elasticsearch that referenced this pull request Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :StorageEngine/Rollup Turn fine-grained time-based data into coarser-grained data Team:StorageEngine v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants