waste less cycles when quick deleting

otherwise that .wait is using quite a lot
This commit is contained in:
2024-06-30 14:10:57 +02:00
parent cc856d788f
commit 3e0403eede
5 changed files with 23 additions and 18 deletions

View File

@@ -451,7 +451,6 @@ public class DhfsFileServiceImpl implements DhfsFileService {
m.removeRef(f.getName());
return null;
});
jObjectManager.tryQuickDelete(ci.get());
}
}
}

View File

@@ -223,11 +223,11 @@ public class JObjectManagerImpl implements JObjectManager {
object.discardData();
refs.forEach(c -> get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (mc, dc, bc, ic) -> {
mc.removeRef(object.getName());
tryQuickDelete(ref);
return null;
})));
refs.forEach(c -> get(c)
.ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (mc, dc, bc, ic) -> {
mc.removeRef(object.getName());
return null;
})));
return true;
});

View File

@@ -45,9 +45,9 @@ public class JObjectRefProcessor {
private final LinkedHashMap<String, Long> _candidates = new LinkedHashMap<>();
public void putDeletionCandidate(String name) {
synchronized (this) {
synchronized (_candidates) {
if (_candidates.putIfAbsent(name, System.currentTimeMillis()) == null)
this.notify();
_candidates.notify();
}
}
@@ -57,9 +57,9 @@ public class JObjectRefProcessor {
String next;
Long nextTime;
synchronized (this) {
synchronized (_candidates) {
while (_candidates.isEmpty())
this.wait();
_candidates.wait();
var e = _candidates.firstEntry();
next = e.getKey();

View File

@@ -88,7 +88,10 @@ public class JObjectResolver {
if (self.getMeta().getRefcount() <= 0)
if (!self.isDeleted())
jObjectRefProcessor.putDeletionCandidate(self.getName());
if (self.getMeta().isSeen())
jObjectRefProcessor.putDeletionCandidate(self.getName());
else
jobjectManager.tryQuickDelete(self);
}
public <T extends JObjectData> Optional<T> resolveDataLocal(JObject<T> jObject) {

View File

@@ -143,13 +143,16 @@ public class JObjectWriteback {
flushOne(obj);
} catch (Exception e) {
Log.error("Failed writing object " + obj.getName() + ", will retry.", e);
obj.runReadLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (m, d) -> {
var size = jObjectSizeEstimator.estimateObjectSize(d);
synchronized (_writeQueue) {
_writeQueue.put(Pair.of(size, m.getName()), obj);
}
return null;
});
try {
obj.runReadLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (m, d) -> {
var size = jObjectSizeEstimator.estimateObjectSize(d);
synchronized (_writeQueue) {
_writeQueue.put(Pair.of(size, m.getName()), obj);
}
return null;
});
} catch (JObject.DeletedObjectAccessException ignored) {
}
}
}
} catch (InterruptedException ignored) {