Skip to content

Commit

Permalink
Moved the average calculation logic to common memory manager util.
Browse files Browse the repository at this point in the history
Signed-off-by: Saurabh Singh <[email protected]>
  • Loading branch information
getsaurabh02 committed Jul 31, 2021
1 parent 8dbb32e commit c7721a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ private void calculateRequestThroughput(long bytes, long requestLatency, Perform
performanceTracker.addNewThroughout(requestThroughput);
if (performanceTracker.getThroughputMovingQueueSize() > shardIndexingPressureSettings.getRequestSizeWindow()) {
double front = performanceTracker.getFirstThroughput();
double movingAverage = calculateMovingAverage(performanceTracker.getThroughputMovingAverage(), front, requestThroughput,
shardIndexingPressureSettings.getRequestSizeWindow());
double movingAverage = memoryManager.calculateMovingAverage(performanceTracker.getThroughputMovingAverage(), front,
requestThroughput, shardIndexingPressureSettings.getRequestSizeWindow());
performanceTracker.updateThroughputMovingAverage(Double.doubleToLongBits(movingAverage));
} else {
double movingAverage = (double) statsTracker.getTotalBytes() / performanceTracker.getLatencyInMillis();
Expand Down Expand Up @@ -255,14 +255,6 @@ private void tryReleaseTracker(ShardIndexingPressureTracker tracker) {
tracker.getReplicaOperationTracker().getStatsTracker().getCurrentBytes() == 0));
}

private double calculateMovingAverage(long currentAverage, double frontValue, double currentValue, int count) {
if(count > 0) {
return ((Double.longBitsToDouble(currentAverage) * count) + currentValue - frontValue) / count;
} else {
return currentValue;
}
}

private void rejectShardRequest(ShardIndexingPressureTracker tracker, long bytes, long nodeTotalBytes, long shardTotalBytes,
RejectionTracker rejectionTracker, String operationType) {
long nodeBytesWithoutOperation = nodeTotalBytes - bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ void tryTrackerCleanupFromHotStore(ShardIndexingPressureTracker tracker, Boolean
shardIndexingPressureStore.tryTrackerCleanupFromHotStore(tracker, condition);
}

double calculateMovingAverage(long currentAverage, double frontValue, double currentValue, int count) {
if(count > 0) {
return ((Double.longBitsToDouble(currentAverage) * count) + currentValue - frontValue) / count;
} else {
return currentValue;
}
}

long getTotalNodeLimitsBreachedRejections() {
return totalNodeLimitsBreachedRejections.get();
}
Expand Down

0 comments on commit c7721a8

Please sign in to comment.