-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add time in index throttle to index stats. #7896
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
Conversation
I think docs need to be updated, and we need some sort of test case? |
@@ -846,6 +851,9 @@ public void flush(Flush flush) throws EngineException { | |||
// to be allocated to a different node | |||
currentIndexWriter().close(false); | |||
indexWriter = createWriter(); | |||
if (this.throttle != null) { |
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.
honestly this seems just wrong. The throttle is never null. It's designed to be used all the time and it's the actual lock that is used inside class IndexThrottle
that make the difference. I think this should be implemented by using a TimedInternalLock extends InternalLock
wrapper that is used inside IndexThrottle
this implementation actually makes no sense to me to be honest.
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.
there is also no test for this at all I think we need one that 1. checks that is works and 2. that it's 0 if no throttle :)
I left some comments - this PR needs some more work IMO |
@s1monw I've moved the timing into a TimedLock. @mikemccand we still create a throttle on start and flush. I don't want to change behavior when just adding some timing information. Perhaps a different PR for that. |
I was actually thinking of implementing it slightly differently. I was thinking of adding additional callbacks to Then, we can keep the relevant stats on |
also, I think that we should have 2 stats, the first is |
OK makes sense. |
We can put the callback after or before, I personally don't think its as important (missing a millisecond here or there, and now that the method is sync'ed, its simpler to reason). @s1monw what do you think about the idea of callback and adding it to indexing stats? |
yeah I agree we can just use a callback - I wonder what info we need here do we want the time we spend indexing under the throttle or the time the index throttle was active? I think these are 2 different impls? |
@s1monw @kimchy I'm happy to do either one or both ? To be clear the time we spend under the throttle [1] is the time the lock was acquired (the current implementation in this PR) and the time the throttle was active [2] is the time between the two log messages. For [1] are we ok making a callback from within a lock acquire and release ? |
@kimchy can you comment on my latest comment |
I think the most important time is the period index throttle was active (much simpler to reason about when comparing it to other rate type graphs) I would just do the callback when throttling gets enbed, and a callback when it gets disabled. The indexing stats service can then keep track of the time. The throttling stats would include the time spent while in throttling mode, and a false/true if it's in throttle mode. Both of those can be easily handled by the callbacks on the indexing stats service |
Ok sounds good, thanks I'll implement the call back at the time between the two log messages. |
7afc1d4
to
8fdbdf6
Compare
I've made the changes and added new tests. |
@@ -1667,7 +1670,7 @@ public void close() throws ElasticsearchException { | |||
} | |||
} | |||
|
|||
private static final class InternalLock implements Releasable { |
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.
this can be final again?
|
||
public void setThrottled(boolean isThrottled) { | ||
if (!this.isThrottled && isThrottled) { | ||
startOfThrottle = System.nanoTime(); |
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 would use System.currentTimeInMillis, nanoTime has different semantics
left some comments |
// make sure we see throttling kicking in: | ||
boolean done = false; | ||
while (!done) { | ||
for(int i=0;i<100;i++) { |
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.
format this loop? as well as the others?
LGTM |
This commit adds throttle stats to the indexing stats and uses a call back from InternalEngine to manage the stats. Also includes updates the IndexStatsTests to test for these new stats. Stats added : ``` throttle_time_in_millis is_throttled ``` Closes elastic#7861
1023a09
to
56940c5
Compare
This PR adds the time spent throttling indexing to a single thread to the stats API.
Closes #7861