Skip to content

Commit 331595c

Browse files
committed
Add comments
1 parent 78f521f commit 331595c

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3245,7 +3245,7 @@ public void noopUpdate() {
32453245
* @see org.elasticsearch.indices.IndexingMemoryController
32463246
*/
32473247
public void writeIndexBuffersOnIndexThreads(long took) {
3248-
internalIndexingStats.writeIndexBuffers(took);
3248+
internalIndexingStats.writeIndexingBuffersTime(took);
32493249
}
32503250

32513251
public void maybeCheckIndex() {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,26 @@ void noopUpdate() {
166166
* @param took time taken to write buffers
167167
* @see org.elasticsearch.indices.IndexingMemoryController
168168
*/
169-
void writeIndexBuffers(long took) {
169+
void writeIndexingBuffersTime(long took) {
170170
totalStats.writeIndexingBufferTime.add(took);
171171
totalStats.recentIndexMetric.addIncrement(took, relativeTimeInNanosSupplier.getAsLong());
172172
}
173173

174174
static class StatsHolder {
175175
private final MeanMetric indexMetric = new MeanMetric(); // Used for the count and total 'took' time (in ns) of index operations
176-
private final ExponentiallyWeightedMovingRate recentIndexMetric; // An EWMR of the total 'took' time of index operations (in ns)
177-
private final AtomicReference<Double> peakIndexMetric; // The peak value of the EWMR observed in any stats() call
176+
private final LongAdder writeIndexingBufferTime = new LongAdder();
177+
// Used for the total time taken to flush indexing buffers to disk (on indexing threads) (in ns)
178+
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;
181+
// The peak value of the EWMR (recentIndexMetric) observed in any stats() call
178182
private final MeanMetric deleteMetric = new MeanMetric();
179183
private final CounterMetric indexCurrent = new CounterMetric();
180184
private final CounterMetric indexFailed = new CounterMetric();
181185
private final CounterMetric indexFailedDueToVersionConflicts = new CounterMetric();
182186
private final CounterMetric deleteCurrent = new CounterMetric();
183187
private final CounterMetric noopUpdates = new CounterMetric();
184-
private final LongAdder writeIndexingBufferTime = new LongAdder();
188+
185189

186190
StatsHolder(long startTimeInNanos, TimeValue recentWriteLoadHalfLife) {
187191
double lambdaInInverseNanos = Math.log(2.0) / recentWriteLoadHalfLife.nanos();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ private boolean writePendingIndexingBuffers() {
211211
.pollFirst()) {
212212
// Remove the shard from the set first, so that multiple threads can run writeIndexingBuffer concurrently on the same shard.
213213
pendingWriteIndexingBufferSet.remove(shard);
214+
// Calculate the time taken to write the indexing buffers so it can be accounted for in the index write load
214215
startTime = System.nanoTime();
215216
shard.writeIndexingBuffer();
216217
took = System.nanoTime() - startTime;

server/src/test/java/org/elasticsearch/index/shard/IndexingStatsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void testStatsGetWriteLoad() {
3333
false,
3434
10,
3535
1_800_000_000L, // totalIndexingTimeSinceShardStartedInNanos - 1.8sec
36-
1_800_000_000L, // totalIndexingTimeSinceShardStartedInNanos - 1.8sec
36+
1_800_000_000L, // totalIndexingLoadSinceShardStartedInNanos - 1.8sec
3737
3_000_000_000L, // totalActiveTimeInNanos - 3sec
3838
0.1357,
3939
0.2468
@@ -106,7 +106,7 @@ public void testStatsAdd_writeLoads() {
106106
false,
107107
10,
108108
1_000_000_000L, // totalIndexingTimeSinceShardStartedInNanos - 1sec
109-
1_000_000_000L, // totalIndexingTimeSinceShardStartedInNanos - 1sec
109+
1_000_000_000L, // totalIndexingLoadSinceShardStartedInNanos - 1sec
110110
2_000_000_000L, // totalActiveTimeInNanos - 2sec
111111
0.1357, // recentWriteLoad
112112
0.3579 // peakWriteLoad

0 commit comments

Comments
 (0)