private void compactIfNeeded() {
    lock(true);
    try {
      if (compactInProgress) {
        return;
      }
      if (ifTotalRecordCount == 0) {
        return;
      }
      if (ifTotalRecordCount == ifLiveRecordCount) {
        return;
      }
      if (ifRAF.length() <= MIN_SIZE_BEFORE_COMPACT) {
        return;
      }
      if ((double) ifLiveRecordCount / (double) ifTotalRecordCount > COMPACT_RATIO) {
        return;
      }
      compact();
    } catch (IOException ignore) {
    } finally {
      unlock(true);
    }
  }
If the ratio of live vs. dead is not less than this constant then no need to compact.
geode-core/src/main/java/org/apache/geode/internal/cache/DiskInitFile.java