Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

simplification / speedup of GenerationMemoryStrategy

sixcoolerd3b9349b6f2c
diff --git a/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java b/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java
index 55b24ea3e..1253537a6 100644
--- a/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java
+++ b/source/net/yacy/kelondro/util/GenerationMemoryStrategy.java
@@ -51,7 +51,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
*/
@Override
protected final long free() {
- return getUsage(eden, false).getCommitted() - getUsage(eden, false).getUsed();
+ return youngAvailable();
}
/**
@@ -61,7 +61,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
*/
@Override
protected final long available() {
- return available(true);
+ return available(false);
}
/**
@@ -70,7 +70,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
* @return bytes
*/
private final long available(final boolean force) {
- return force & properState(force) ? Math.max(youngAvailable(), oldAvailable()) : Math.min(youngAvailable(), Math.max(M, oldAvailable()));
+ return force & properState(force) ? Math.max(youngAvailable(), oldAvailable()) : oldAvailable();
}
/**
@@ -99,6 +99,14 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
protected final long maxMemory() {
return heap.getHeapMemoryUsage().getMax();
}
+
+ /**
+ * get the memory that needs to be available for properState
+ */
+ protected final long minMemory()
+ {
+ return getUsage(eden, true).getUsed();
+ }
/**
* checks if a specified amount of bytes are available
@@ -151,7 +159,7 @@ public class GenerationMemoryStrategy extends MemoryStrategy {
* @return if survivor fits into old space
*/
private boolean properState(final boolean force) {
- final long surv = force? Math.max(M, getUsage(survivor, false).getUsed()) : getUsage(survivor, false).getCommitted();
+ final long surv = force? M + getUsage(survivor, false).getUsed() : getUsage(survivor, false).getCommitted();
return surv < oldAvailable();
}
diff --git a/source/net/yacy/kelondro/workflow/InstantBusyThread.java b/source/net/yacy/kelondro/workflow/InstantBusyThread.java
index 1a03b79b5..e8d62ab23 100644
--- a/source/net/yacy/kelondro/workflow/InstantBusyThread.java
+++ b/source/net/yacy/kelondro/workflow/InstantBusyThread.java
@@ -162,7 +162,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT
thread.setIdleSleep(-1);
thread.setBusySleep(-1);
thread.setMemPreReqisite(0);
- thread.setLoadPreReqisite(99); // this is called during initialization phase and some code parts depend on it; therefore we cannot set a prerequisite that prevents the start of that thread
+ thread.setLoadPreReqisite(Double.MAX_VALUE); // this is called during initialization phase and some code parts depend on it; therefore we cannot set a prerequisite that prevents the start of that thread
thread.start();
return thread;
}