Skip to content
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

Add time in index throttle to index stats. #7896

Closed
wants to merge 1 commit into from

Conversation

GaelTadh
Copy link
Contributor

This PR adds the time spent throttling indexing to a single thread to the stats API.

Closes #7861

@mikemccand
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

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 :)

@s1monw
Copy link
Contributor

s1monw commented Sep 26, 2014

I left some comments - this PR needs some more work IMO

@s1monw s1monw removed the review label Sep 26, 2014
@GaelTadh
Copy link
Contributor Author

@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.

@kimchy
Copy link
Member

kimchy commented Sep 29, 2014

I was actually thinking of implementing it slightly differently. I was thinking of adding additional callbacks to ShardIndexingService, something like #beforeThrottling and #afterThrottling.

Then, we can keep the relevant stats on ShardIndexingService, and add it to the more appropriate place (compared to SegmentsStats) which is IndexingStats.

@kimchy
Copy link
Member

kimchy commented Sep 29, 2014

also, I think that we should have 2 stats, the first is is_throttled which is true or false, and the second is the time spent throttling.

@mikemccand
Copy link
Contributor

I don't want to change behavior when just adding some timing information.

OK makes sense.

@GaelTadh
Copy link
Contributor Author

@kimchy Do you want to add the callbacks at the same place we emit the log message ? I think @s1monw's point is that we are not actually throttling until the throttle lock has been acquired, we are just in a state where we may throttle.

@kimchy
Copy link
Member

kimchy commented Sep 30, 2014

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?

@s1monw
Copy link
Contributor

s1monw commented Sep 30, 2014

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?

@GaelTadh
Copy link
Contributor Author

GaelTadh commented Oct 2, 2014

@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 ?

@s1monw
Copy link
Contributor

s1monw commented Oct 14, 2014

@kimchy can you comment on my latest comment

@kimchy
Copy link
Member

kimchy commented Oct 14, 2014

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

@GaelTadh
Copy link
Contributor Author

Ok sounds good, thanks I'll implement the call back at the time between the two log messages.

@GaelTadh GaelTadh force-pushed the nodestats-indexthrottling branch 2 times, most recently from 7afc1d4 to 8fdbdf6 Compare October 22, 2014 11:19
@GaelTadh
Copy link
Contributor Author

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 {
Copy link
Contributor

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();
Copy link
Member

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

@s1monw
Copy link
Contributor

s1monw commented Oct 22, 2014

left some comments

@s1monw s1monw removed the review label Oct 22, 2014
// make sure we see throttling kicking in:
boolean done = false;
while (!done) {
for(int i=0;i<100;i++) {
Copy link
Contributor

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?

@s1monw
Copy link
Contributor

s1monw commented Oct 22, 2014

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
@GaelTadh GaelTadh closed this Oct 22, 2014
@clintongormley clintongormley added :Data Management/Stats Statistics tracking and retrieval APIs v1.5.0 labels Mar 19, 2015
@clintongormley clintongormley changed the title Stats : Add time in index throttle to stats. Add time in index throttle to index stats. Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add index throttling to node stats
5 participants