-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Track total task execution time in TaskExecutionTimeTrackingEsThreadPoolExecutor #96944
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
Track total task execution time in TaskExecutionTimeTrackingEsThreadPoolExecutor #96944
Conversation
b49aa47 to
3226f32
Compare
3226f32 to
e486e17
Compare
| * An extension to thread pool executor, which tracks statistics for the task execution time. | ||
| */ | ||
| public final class EWMATrackingEsThreadPoolExecutor extends EsThreadPoolExecutor { | ||
| public final class TaskExecutionTimeTrackingEsThreadPoolExecutor extends EsThreadPoolExecutor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names a bit verbose/long, but we rarely use it directly. I'm open for suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It follows the venerable Java naming tradition, it's good 😅
| if (taskExecutionNanos != -1) { | ||
| // taskExecutionNanos may be -1 if the task threw an exception | ||
| executionEWMA.addValue(taskExecutionNanos); | ||
| totalExecutionTime.add(taskExecutionNanos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've kept this as nano (rather than millis). I think it is safe.
|
Pinging @elastic/es-distributed (Team:Distributed) |
fcofdez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I left a couple of minor nits around tests
| assertThat(executor.getTotalTaskExecutionTime(), equalTo(0L)); | ||
| executeTask(executor, 1); | ||
| assertBusy(() -> { assertThat((long) executor.getTaskExecutionEWMA(), equalTo(30L)); }); | ||
| assertBusy(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could we add a comment to note that fastWrapper makes each execution look like it took 100ns?
|
|
||
| assertThat((long) executor.getTaskExecutionEWMA(), equalTo(0L)); | ||
| executeTask(executor, 1); | ||
| int taskCount = randomIntBetween(1, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same as above, could we add a comment regarding exceptionalWrapper?
| * An extension to thread pool executor, which tracks statistics for the task execution time. | ||
| */ | ||
| public final class EWMATrackingEsThreadPoolExecutor extends EsThreadPoolExecutor { | ||
| public final class TaskExecutionTimeTrackingEsThreadPoolExecutor extends EsThreadPoolExecutor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It follows the venerable Java naming tradition, it's good 😅
Track total task execution time in EWMATrackingEsThreadPoolExecutor and rename it.
Relates ES-6249