Skip to content

Conversation

@ywangd
Copy link
Member

@ywangd ywangd commented May 9, 2025

No need to call the method separately as it can be invoked the first time getQueueTimeNanos is called.

Relates: #120488

No need to call the method separately as it can be invoked the first
time getQueueTimeNanos is called.

Relates: elastic#120488
@ywangd ywangd requested a review from nicktindall May 9, 2025 07:06
@ywangd ywangd requested a review from a team as a code owner May 9, 2025 07:06
@ywangd ywangd added v9.1.0 :Distributed Coordination/Distributed A catch all label for anything in the Distributed Coordination area. Please avoid if you can. labels May 9, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label May 9, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@ywangd
Copy link
Member Author

ywangd commented May 9, 2025

Just a minor improvement when reading through #120488

Copy link
Contributor

@nicktindall nicktindall left a comment

Choose a reason for hiding this comment

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

I'm not sure about this change, if for whatever reason we move the call to getQueueTimeNanos to somewhere else it will return incorrect results?

Also calling it early would erroneously return a time, even if the runnable was still queued?

The only reason for the somewhat convoluted dance here is that the source of createdTimeNanos is not specified so I wanted to avoid exposing it and doing the arithmetic outside TimedRunnable (i.e. we only ever return the deltas between the timestamps and not the timestamps themselves, so there's nothing in the API that indicates whether it's a cached time or not, and hence whether it's safe to compare to a cached/non-cached timestamp)

@ywangd
Copy link
Member Author

ywangd commented May 19, 2025

if for whatever reason we move the call to getQueueTimeNanos to somewhere else it will return incorrect results?

Also calling it early would erroneously return a time, even if the runnable was still queued?

Both is true. I had assumed there would not be other usages outside TaskExecutionTimeTrackingEsThreadPoolExecutor since TimedRunnable and its relevant methods are package private and used really just inside the Executor. If we move TimedRunnable to be an inner class and change the relevant methods to be private, I think it would make this PR more justified. That said, it is probably not worth the effort. So I am happy to close it.

@ywangd ywangd closed this May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Distributed A catch all label for anything in the Distributed Coordination area. Please avoid if you can. >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants