Skip to content

Conversation

@HiDAl
Copy link

@HiDAl HiDAl commented May 29, 2023

Add a new target (thread_pool) to the /_info API. It consolidates all the thread pools information from the cluster nodes and returns a summary at the cluster level (compared with _nodes/stats/thread_pool it lacks the <node> dimension)

GET _info/thread_pool { "cluster_name": "runTask", "thread_pool": { "analyze": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "auto_complete": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "azure_event_loop": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "ccr": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "cluster_coordination": { "threads": 1, "queue": 0, "active": 0, "rejected": 0, "largest": 1, "completed": 104 }, "fetch_shard_started": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "fetch_shard_store": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "flush": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "force_merge": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "generic": { "threads": 16, "queue": 0, "active": 0, "rejected": 0, "largest": 16, "completed": 226 }, "get": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "management": { "threads": 2, "queue": 0, "active": 1, "rejected": 0, "largest": 2, "completed": 18 }, "profiling": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "refresh": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "repository_azure": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "rollup_indexing": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "search": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "search_coordination": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "search_throttled": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "searchable_snapshots_cache_fetch_async": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "searchable_snapshots_cache_prewarming": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "snapshot": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "snapshot_meta": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "system_critical_read": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "system_critical_write": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "system_read": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "system_write": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "vector_tile_generation": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "warmer": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "watcher": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 }, "write": { "threads": 0, "queue": 0, "active": 0, "rejected": 0, "largest": 0, "completed": 0 } } } $ curl localhost:9200/_info/_all | jq 'keys' [ "cluster_name", "http", "ingest", "thread_pool" ]

Closes #95393

Pablo Alcantar Morales added 5 commits May 29, 2023 11:19
@HiDAl HiDAl added >enhancement :Data Management/Stats Statistics tracking and retrieval APIs Team:Data Management Meta label for data/management team v8.9.0 labels May 29, 2023
@HiDAl HiDAl requested a review from gmarouli May 29, 2023 10:13
@github-actions
Copy link
Contributor

Documentation preview:

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine
Copy link
Collaborator

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

@HiDAl
Copy link
Author

HiDAl commented May 29, 2023

@elasticmachine run elasticsearch-ci/part-1

@HiDAl
Copy link
Author

HiDAl commented May 30, 2023

@elasticmachine run elasticsearch-ci/packaging-tests-windows-sample

Copy link
Contributor

@gmarouli gmarouli left a comment

Choose a reason for hiding this comment

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

Thank you @HiDAl this is looking great already! I started a discussion on some small topics :).

Comment on lines +61 to +62
ThreadPoolStats.Stats.merge(firstStats.get(1), secondStats.get(2)), // name-2
ThreadPoolStats.Stats.merge(firstStats.get(2), secondStats.get(3)), // name-3
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer here to not use the methods we are testing, I would be ok with writing a helper function for this but in the test. The idea behind this is, if a bug is introduced accidentally in ThreadPoolStats.Stats.merge we will catch it easier.

What do you think?

Copy link
Author

@HiDAl HiDAl May 31, 2023

Choose a reason for hiding this comment

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

yeah, I thought the same while writing this. That's the reason why I wrote a separate test for this method at testStatsMerge() (a couple of lines below). IMO, that would give us enough confidence in case a bug is introduced to the other method it'll be caught. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

True, I do have a preference to have it not calling the merge, in case the other test is removed or changed somehow, but I understand if you want to leave it as is.

Ingest information.

`thread_pool`::
Statistics about each thread pool, including current size, queue and rejected tasks.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should say queue size instead of queue, what do you think?

[[cluster-info-api-response-body-threadpool]]
`thread_pool`::
(object)
Contains thread pool information of the cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe Contains information about the thread pools of the cluster reads a bit better? What do you think?

======
`<thread_pool_name>`::
(object)
Contains information about the thread pool of the cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about something like this:

Contains information about the thread pool of the cluster with name <thread_pool_name>.

.reduce(IngestStats.IDENTITY, IngestStats::merge),
//
THREAD_POOL.metricName(),
response -> response.getNodes().stream().map(NodeStats::getThreadPool).reduce(ThreadPoolStats.IDENTITY, ThreadPoolStats::merge)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, if I am not mistaken this response is the same as the nodesStatsResponse in the other metrics. I would prefer to have it consistent over all the metrics to show that they have the same input.

Comment on lines 39 to 40
assertThat(copy.stream().map(ThreadPoolStats.Stats::name).toList(), contains("a", "d", "m", "m", "m", "t", "z"));
assertThat(copy.stream().map(ThreadPoolStats.Stats::threads).toList(), contains(-1, 2, -3, 4, 5, 6, 7));
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly are we testing with these two lines? It's not very clear to me. I thought the next two lines would be sufficient.

Copy link
Author

Choose a reason for hiding this comment

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

These are the old tests: basically, checking that the method compareTo is correct. anyway, you're right, the next 2 lines should suffice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I didn't think of that :), thanks for the explanation.

Comment on lines 131 to 135
public ThreadPoolStats {
Collections.sort(stats);
stats = Collections.unmodifiableList(stats);
var statsCopy = new ArrayList<>(stats);
Collections.sort(statsCopy);
stats = Collections.unmodifiableList(statsCopy);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should we add another constructor that accepts a Collection to avoid having to do new ThreadPoolStats(new ArrayList<>(mergedThreadPools.values())) in the merge method?

Copy link
Author

Choose a reason for hiding this comment

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

sadly no, it clashes because we're using a List<Stat> (List is a Collection)...

Copy link
Contributor

@gmarouli gmarouli May 31, 2023

Choose a reason for hiding this comment

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

What about changing the constructor to ThreadPoolStats(Collection<Stat> stats)?

ArrayList constructor is also accepting Collection:

public ArrayList(Collection<? extends E> c) {...} 
Copy link
Author

Choose a reason for hiding this comment

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

good idea, will change it. Thanks Mary

@HiDAl HiDAl requested a review from gmarouli May 31, 2023 13:54
Copy link
Contributor

@gmarouli gmarouli left a comment

Choose a reason for hiding this comment

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

LGTM, I added two comments that continue our previous discussion.

@HiDAl HiDAl merged commit f5d47cc into elastic:main Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Stats Statistics tracking and retrieval APIs >enhancement Team:Data Management Meta label for data/management team v8.9.0

3 participants