Skip to content
Permalink
Browse files
Revert rocksdb compaction on checkpoint to reduce cpu intensive (#3144)
  • Loading branch information
hangc0276 committed Mar 31, 2022
1 parent f55ac1e commit ef0b5cc7726b929aa1fc9c617f2130afae527c18
Showing 2 changed files with 0 additions and 14 deletions.
@@ -201,7 +201,6 @@ public void removeOffsetFromDeletedLedgers() throws IOException {
long deletedEntriesInBatch = 0;

Batch batch = locationsDb.newBatch();
final byte[] firstDeletedKey = new byte[keyToDelete.array.length];

try {
for (long ledgerId : ledgersToDelete) {
@@ -244,9 +243,6 @@ public void removeOffsetFromDeletedLedgers() throws IOException {
}
batch.remove(keyToDelete.array);
++deletedEntriesInBatch;
if (deletedEntries++ == 0) {
System.arraycopy(keyToDelete.array, 0, firstDeletedKey, 0, firstDeletedKey.length);
}
}

if (deletedEntriesInBatch > DELETE_ENTRIES_BATCH_SIZE) {
@@ -259,9 +255,6 @@ public void removeOffsetFromDeletedLedgers() throws IOException {
try {
batch.flush();
batch.clear();
if (deletedEntries != 0) {
locationsDb.compact(firstDeletedKey, keyToDelete.array);
}
} finally {
firstKeyWrapper.recycle();
lastKeyWrapper.recycle();
@@ -321,26 +321,19 @@ public void flush() throws IOException {

public void removeDeletedLedgers() throws IOException {
LongWrapper key = LongWrapper.get();
final byte[] startKey = new byte[key.array.length];

int deletedLedgers = 0;
while (!pendingDeletedLedgers.isEmpty()) {
long ledgerId = pendingDeletedLedgers.poll();
key.set(ledgerId);
ledgersDb.delete(key.array);
if (deletedLedgers++ == 0) {
System.arraycopy(key.array, 0, startKey, 0, startKey.length);
}
}

if (log.isDebugEnabled()) {
log.debug("Persisting deletes of ledgers {}", deletedLedgers);
}

ledgersDb.sync();
if (deletedLedgers != 0) {
ledgersDb.compact(startKey, key.array);
}
key.recycle();
}

0 comments on commit ef0b5cc

Please sign in to comment.