Skip to content

Commit 6dc1af4

Browse files
committed
review comments
1 parent 018a86c commit 6dc1af4

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

server/src/main/java/org/elasticsearch/index/shard/InternalIndexingStats.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ void writeIndexingBuffersTime(long took) {
172172
}
173173

174174
static class StatsHolder {
175-
private final MeanMetric indexMetric = new MeanMetric(); // Used for the count and total 'took' time (in ns) of index operations
176-
private final LongAdder writeIndexingBufferTime = new LongAdder();
175+
// Used for the count and total 'took' time (in ns) of index operations
176+
private final MeanMetric indexMetric = new MeanMetric();
177177
// Used for the total time taken to flush indexing buffers to disk (on indexing threads) (in ns)
178+
private final LongAdder writeIndexingBufferTime = new LongAdder();
179+
// An EWMR of the total 'took' time of index operations (indexMetric) plus the writeIndexingBufferTime (in ns)
178180
private final ExponentiallyWeightedMovingRate recentIndexMetric;
179-
// An EWMR of the total 'took' time of index operations (in ns) plus the writeIndexingBufferTime
180-
private final AtomicReference<Double> peakIndexMetric;
181181
// The peak value of the EWMR (recentIndexMetric) observed in any stats() call
182+
private final AtomicReference<Double> peakIndexMetric;
182183
private final MeanMetric deleteMetric = new MeanMetric();
183184
private final CounterMetric indexCurrent = new CounterMetric();
184185
private final CounterMetric indexFailed = new CounterMetric();
@@ -208,8 +209,9 @@ IndexingStats.Stats stats(
208209
) {
209210
final long totalIndexingTimeInNanos = indexMetric.sum();
210211
final long totalIndexingTimeSinceShardStartedInNanos = totalIndexingTimeInNanos - indexingTimeBeforeShardStartedInNanos;
211-
final long totalIndexingLoadInNanos = totalIndexingTimeInNanos + writeIndexingBufferTime.sum();
212-
final long totalIndexingLoadSinceShardStartedInNanos = totalIndexingLoadInNanos - indexingLoadBeforeShardStartedInNanos;
212+
// This is different from indexing time as it also includes the
213+
final long totalIndexingExecutionTimeInNanos = totalIndexingTimeInNanos + writeIndexingBufferTime.sum();
214+
final long totalIndexingExecutionTimeSinceShardStartedInNanos = totalIndexingExecutionTimeInNanos - indexingLoadBeforeShardStartedInNanos;
213215
final double recentIndexingLoadSinceShardStarted = recentIndexMetric.calculateRateSince(
214216
currentTimeInNanos,
215217
recentIndexMetric.getRate(currentTimeInNanos),
@@ -243,7 +245,7 @@ IndexingStats.Stats stats(
243245
isThrottled,
244246
TimeUnit.MILLISECONDS.toMillis(currentThrottleMillis),
245247
totalIndexingTimeSinceShardStartedInNanos,
246-
totalIndexingLoadSinceShardStartedInNanos,
248+
totalIndexingExecutionTimeSinceShardStartedInNanos,
247249
timeSinceShardStartedInNanos,
248250
recentIndexingLoadSinceShardStarted,
249251
peakIndexingLoad

server/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,14 @@ protected void enqueueWriteIndexingBuffer(IndexShard shard) {
205205
*/
206206
private boolean writePendingIndexingBuffers() {
207207
boolean wrotePendingIndexingBuffer = false;
208-
long startTime;
209-
long took;
210208
for (IndexShard shard = pendingWriteIndexingBufferQueue.pollFirst(); shard != null; shard = pendingWriteIndexingBufferQueue
211209
.pollFirst()) {
212210
// Remove the shard from the set first, so that multiple threads can run writeIndexingBuffer concurrently on the same shard.
213211
pendingWriteIndexingBufferSet.remove(shard);
214212
// Calculate the time taken to write the indexing buffers so it can be accounted for in the index write load
215-
startTime = System.nanoTime();
213+
long startTime = System.nanoTime();
216214
shard.writeIndexingBuffer();
217-
took = System.nanoTime() - startTime;
215+
long took = System.nanoTime() - startTime;
218216
shard.writeIndexBuffersOnIndexThreads(took);
219217
wrotePendingIndexingBuffer = true;
220218
}

0 commit comments

Comments
 (0)