Optimize blinear closed file cleanup logic
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s

This commit is contained in:
2026-08-19 11:36:01 +08:00
parent 0cc941be27
commit 899927a935
2 changed files with 4 additions and 15 deletions
@@ -459,6 +459,9 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
return; return;
} }
// remove from flusher
this.markClosed();
IOException failure = null; IOException failure = null;
// final sync so no buffered data is lost; holding syncLock also guarantees no // final sync so no buffered data is lost; holding syncLock also guarantees no
@@ -473,8 +476,6 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
} }
try { try {
this.markClosed();
this.swapFileChannel.close(); this.swapFileChannel.close();
} catch (IOException ex) { } catch (IOException ex) {
if (failure == null) failure = ex; if (failure == null) failure = ex;
@@ -488,9 +489,6 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
else failure.addSuppressed(e); else failure.addSuppressed(e);
} }
// finalize
this.markClosed();
if (failure != null) { if (failure != null) {
throw failure; throw failure;
} }
@@ -62,7 +62,6 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
copied = this.inManagement.toArray(new BufferedLinearRegionFile[0]); copied = this.inManagement.toArray(new BufferedLinearRegionFile[0]);
} }
final List<BufferedLinearRegionFile> toRemove = new ObjectArrayList<>();
for (BufferedLinearRegionFile file : copied) { for (BufferedLinearRegionFile file : copied) {
// try acquiring the read lock // try acquiring the read lock
if (!file.softReadLock()) { if (!file.softReadLock()) {
@@ -80,8 +79,7 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
} }
if (closed) { if (closed) {
// add to pending remove list so that we could clean the closed file correctly // closed already, should be removed soon
toRemove.add(file);
continue; continue;
} }
@@ -109,13 +107,6 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
}); });
} }
} }
synchronized (this) {
// clean closed files
for (BufferedLinearRegionFile file : toRemove) {
this.inManagement.remove(file);
}
}
} }
public void removeFile(BufferedLinearRegionFile fileToRemove) { public void removeFile(BufferedLinearRegionFile fileToRemove) {