new memory limit computation for indexing queue

shall better prevent outofmemory errors

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3118 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent a9f1d3a065
commit c48374d14a

@ -62,6 +62,10 @@ public class indexCachedRI implements indexRI {
return payloadrow; return payloadrow;
} }
public int minMem() {
return 1024 * 1024;
}
public void setWordFlushDivisor(int idleDivisor, int busyDivisor) { public void setWordFlushDivisor(int idleDivisor, int busyDivisor) {
this.idleDivisor = idleDivisor; this.idleDivisor = idleDivisor;
this.busyDivisor = busyDivisor; this.busyDivisor = busyDivisor;

@ -83,6 +83,12 @@ public class indexCollectionRI implements indexRI {
} }
} }
public int minMem() {
// calculate a minimum amount of memory that is necessary to use the index
// during runtime (after the object was initialized)
return collectionIndex.minMem();
}
public synchronized Iterator wordContainers(String startWordHash, boolean rot) { public synchronized Iterator wordContainers(String startWordHash, boolean rot) {
return new wordContainersIterator(startWordHash, rot); return new wordContainersIterator(startWordHash, rot);
} }

@ -62,13 +62,6 @@ public final class indexRAMRI implements indexRI {
private kelondroRow payloadrow; private kelondroRow payloadrow;
private kelondroRow bufferStructureBasis; private kelondroRow bufferStructureBasis;
// calculated constants
private static String maxKey;
static {
maxKey = ""; for (int i = 0; i < yacySeedDB.commonHashLength; i++) maxKey += 'z';
//minKey = ""; for (int i = 0; i < yacySeedDB.commonHashLength; i++) maxKey += '-';
}
public indexRAMRI(File databaseRoot, kelondroRow payloadrow, int wCacheReferenceLimitInit, String dumpname, serverLog log) { public indexRAMRI(File databaseRoot, kelondroRow payloadrow, int wCacheReferenceLimitInit, String dumpname, serverLog log) {
// creates a new index cache // creates a new index cache
@ -98,6 +91,9 @@ public final class indexRAMRI implements indexRI {
} }
} }
public int minMem() {
return 1024*1024;
}
public synchronized long getUpdateTime(String wordHash) { public synchronized long getUpdateTime(String wordHash) {
indexContainer entries = getContainer(wordHash, null, -1); indexContainer entries = getContainer(wordHash, null, -1);

@ -34,6 +34,7 @@ import java.util.Set;
public interface indexRI { public interface indexRI {
public int size(); public int size();
public int minMem();
public Iterator wordContainers(String startWordHash, boolean rot); // method to replace wordHashes public Iterator wordContainers(String startWordHash, boolean rot); // method to replace wordHashes

@ -251,6 +251,19 @@ public class kelondroCollectionIndex {
return index.size(); return index.size();
} }
public int minMem() {
// calculate a minimum amount of memory that is necessary to use the collection
// during runtime (after the index was initialized)
// caclculate an upper limit (not the correct size) of the maximum number of indexes for a wordHash
// this is computed by the size of the biggest used collection
int m = 1;
for (int i = 0; i < arrays.size(); i++) m = m * this.loadfactor;
// this must be multiplied with the payload size
// and doubled for necessary memory transformation during sort operation
return 2 * m * this.payloadrow.objectsize;
}
public synchronized void put(byte[] key, kelondroRowCollection collection) throws IOException, kelondroOutOfLimitsException { public synchronized void put(byte[] key, kelondroRowCollection collection) throws IOException, kelondroOutOfLimitsException {
// this replaces an old collection by a new one // this replaces an old collection by a new one

@ -228,6 +228,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
(newColumn != rowdef.primaryKey)) { (newColumn != rowdef.primaryKey)) {
resolveMarkedRemoved(); resolveMarkedRemoved();
rowdef.setOrdering(newOrder, newColumn); rowdef.setOrdering(newOrder, newColumn);
assert (removeMarker.size() == 0);
this.sortBound = 0; this.sortBound = 0;
} }
} }

@ -444,6 +444,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
int wordInCacheMaxCount = (int) getConfigLong("indexDistribution.dhtReceiptLimit", 1000); int wordInCacheMaxCount = (int) getConfigLong("indexDistribution.dhtReceiptLimit", 1000);
wordIndex.setInMaxWordCount(wordInCacheMaxCount); wordIndex.setInMaxWordCount(wordInCacheMaxCount);
// set a minimum amount of memory for the indexer thread
setConfig("80_indexing_memprereq", Math.max(getConfigLong("80_indexing_memprereq", 0), wordIndex.minMem()));
// start a cache manager // start a cache manager
log.logConfig("Starting HT Cache Manager"); log.logConfig("Starting HT Cache Manager");
@ -1184,6 +1187,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
if (yacyCore.newsPool.automaticProcess() > 0) hasDoneSomething = true; if (yacyCore.newsPool.automaticProcess() > 0) hasDoneSomething = true;
} catch (IOException e) {} } catch (IOException e) {}
// set new memory limit for indexer thread
setConfig("80_indexing_memprereq", Math.max(getConfigLong("80_indexing_memprereq", 0), wordIndex.minMem()));
return hasDoneSomething; return hasDoneSomething;
} catch (InterruptedException e) { } catch (InterruptedException e) {
this.log.logInfo("cleanupJob: Shutdown detected"); this.log.logInfo("cleanupJob: Shutdown detected");

@ -81,6 +81,10 @@ public final class plasmaWordIndex implements indexRI {
this.idleDivisor = 420; this.idleDivisor = 420;
} }
public int minMem() {
return dhtOutCache.minMem() + dhtInCache.minMem() + collections.minMem();
}
public int maxURLinDHTOutCache() { public int maxURLinDHTOutCache() {
return dhtOutCache.maxURLinCache(); return dhtOutCache.maxURLinCache();
} }

@ -279,4 +279,8 @@ public class plasmaWordIndexFileCluster implements indexRI {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public int minMem() {
return 1024*1024;
}
} }

@ -495,7 +495,7 @@ xpstopw=true
70_cachemanager_busysleep=0 70_cachemanager_busysleep=0
70_cachemanager_memprereq=1048576 70_cachemanager_memprereq=1048576
80_indexing_idlesleep=2000 80_indexing_idlesleep=2000
80_indexing_busysleep=100 80_indexing_busysleep=200
80_indexing_memprereq=2097152 80_indexing_memprereq=2097152
82_crawlstack_idlesleep=5000 82_crawlstack_idlesleep=5000
82_crawlstack_busysleep=0 82_crawlstack_busysleep=0
@ -572,10 +572,10 @@ ramCacheProfiles_time= 500
# not for first startup of YaCy # not for first startup of YaCy
# -Xmx<size> set maximum Java heap size # -Xmx<size> set maximum Java heap size
javastart_Xmx=Xmx64m javastart_Xmx=Xmx96m
# -Xms<size> set initial Java heap size # -Xms<size> set initial Java heap size
javastart_Xms=Xms10m javastart_Xms=Xms96m
# performance properties for the word index cache # performance properties for the word index cache
# wordCacheMaxLow/High is the number of word indexes that shall be held in the # wordCacheMaxLow/High is the number of word indexes that shall be held in the
@ -587,7 +587,7 @@ javastart_Xms=Xms10m
# may last for the word flush # may last for the word flush
wordCacheMaxCount = 20000 wordCacheMaxCount = 20000
wordCacheInitCount = 30000 wordCacheInitCount = 30000
wordFlushIdleDivisor = 420; wordFlushIdleDivisor = 500;
wordFlushBusyDivisor = 5000; wordFlushBusyDivisor = 5000;
# Specifies if yacy can be used as transparent http proxy. # Specifies if yacy can be used as transparent http proxy.

Loading…
Cancel
Save