int getDesiredSpeedPerSecond(double diskTimePerMbInMs, int latencyThreshold) {
    int currentLatency = diskTimePerMbInMs > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) diskTimePerMbInMs;
    int desiredRatePerSec = config.storeCompactionOperationsBytesPerSec;
    if (currentLatency > latencyThreshold) {
      desiredRatePerSec = (int) (config.storeCompactionMinOperationsBytesPerSec +
          (config.storeCompactionOperationsBytesPerSec - config.storeCompactionMinOperationsBytesPerSec)
              * latencyThreshold / currentLatency / config.storeCompactionOperationsAdjustK);
      if (desiredRatePerSec < config.storeCompactionMinOperationsBytesPerSec) {
        desiredRatePerSec = config.storeCompactionMinOperationsBytesPerSec;
      }
      if (desiredRatePerSec > config.storeCompactionOperationsBytesPerSec) {
        desiredRatePerSec = config.storeCompactionOperationsBytesPerSec;
      }
    }
    return desiredRatePerSec;
  }
Calculate the desired rate based on current disk latency and threshold.
@param diskTimePerMbInMs current disk latency per MB in ms.
@param latencyThreshold the threshold.
@return the adjusted compaction speed.
ambry-store/src/main/java/com/github/ambry/store/BlobStoreCompactor.java