Skip to content

Commit

Permalink
changed word cache flush scheduling and removed possible locks
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@910 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Oct 11, 2005
1 parent dced5c7 commit 10d3627
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion htroot/NetworkPicture.java
Expand Up @@ -66,7 +66,7 @@ public class NetworkPicture {
public static BufferedImage respond(httpHeader header, serverObjects post, serverSwitch env) {

int width = 640;
int height = 420;
int height = 480;

if (post != null) {
width = post.getInt("width", 640);
Expand Down
1 change: 1 addition & 0 deletions htroot/PerformanceQueues_p.java
Expand Up @@ -173,6 +173,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
if ((post != null) && (post.containsKey("cacheSizeSubmit"))) {
int wordCacheMaxLow = Integer.parseInt((String) post.get("wordCacheMaxLow", "8000"));
int wordCacheMaxHigh = Integer.parseInt((String) post.get("wordCacheMaxHigh", "10000"));
if (wordCacheMaxLow > wordCacheMaxHigh) wordCacheMaxLow = wordCacheMaxHigh;
switchboard.setConfig("wordCacheMaxLow", Integer.toString(wordCacheMaxLow));
switchboard.setConfig("wordCacheMaxHigh", Integer.toString(wordCacheMaxHigh));
switchboard.wordIndex.setMaxWords(wordCacheMaxLow, wordCacheMaxHigh);
Expand Down
5 changes: 4 additions & 1 deletion source/de/anomic/plasma/plasmaSearchEvent.java
Expand Up @@ -42,11 +42,14 @@

package de.anomic.plasma;

import java.util.Iterator;

public final class plasmaSearchEvent {

private plasmaSearchQuery query;

public plasmaSearchEvent() {
public plasmaSearchEvent(plasmaSearchQuery query) {
this.query = query;
}

}
10 changes: 8 additions & 2 deletions source/de/anomic/plasma/plasmaSwitchboard.java
Expand Up @@ -306,8 +306,8 @@ public plasmaSwitchboard(String rootPath, String initPath, String configPath) th
urlPool = new plasmaURLPool(plasmaPath, ramLURL, ramNURL, ramEURL);

wordIndex = new plasmaWordIndex(plasmaPath, ramRWI, log);
int wordCacheMaxLow = Integer.parseInt((String) getConfig("wordCacheMaxLow", "8000"));
int wordCacheMaxHigh = Integer.parseInt((String) getConfig("wordCacheMaxHigh", "10000"));
int wordCacheMaxLow = (int) getConfigLong("wordCacheMaxLow", 8000);
int wordCacheMaxHigh = (int) getConfigLong("wordCacheMaxHigh", 10000);
wordIndex.setMaxWords(wordCacheMaxLow, wordCacheMaxHigh);
searchManager = new plasmaSearch(urlPool.loadedURL, wordIndex);

Expand Down Expand Up @@ -698,6 +698,12 @@ public boolean deQueue() {
return false;
}

if (wordIndex.wordCacheRAMSize() + 1000 > (int) getConfigLong("wordCacheMaxLow", 8000)) {
log.logFine("deQueue: word index ram cache too full (" + ((int) getConfigLong("wordCacheMaxLow", 8000) - wordIndex.wordCacheRAMSize()) +
" slots left); dismissed to omit ram flush lock");
return false;
}

int stackCrawlQueueSize;
if ((stackCrawlQueueSize = sbStackCrawlThread.size()) >= stackCrawlSlots) {
log.logFine("deQueue: too many processes in stack crawl thread queue, dismissed to protect emergency case (" +
Expand Down
25 changes: 17 additions & 8 deletions source/de/anomic/plasma/plasmaWordIndexCache.java
Expand Up @@ -390,7 +390,7 @@ private int flushFromMem(String key) {
}

// now decide where to flush that container
if (container.size() <= assortmentCluster.clusterCapacity) {
//if (container.size() <= assortmentCluster.clusterCapacity) {
// this fits into the assortments
plasmaWordIndexEntryContainer feedback = assortmentCluster.storeTry(key, container);
if (feedback == null) {
Expand All @@ -399,10 +399,12 @@ private int flushFromMem(String key) {
// *** should care about another option here ***
return backend.addEntries(feedback, time, true);
}
/*
} else {
// store to back-end; this should be a rare case
return backend.addEntries(container, time, true);
}
**/

}

Expand Down Expand Up @@ -466,9 +468,10 @@ public synchronized int removeEntries(String wordHash, String[] urlHashes, boole
return removed;
}

public synchronized int addEntries(plasmaWordIndexEntryContainer container, long updateTime, boolean highPriority) {
public int addEntries(plasmaWordIndexEntryContainer container, long updateTime, boolean highPriority) {
// this puts the entries into the cache, not into the assortment directly

int added = 0;
// check cache space
if (cache.size() > 0) try {
// pause to get space in the cache (while it is flushed)
Expand All @@ -485,14 +488,17 @@ public synchronized int addEntries(plasmaWordIndexEntryContainer container, long
Thread.sleep(pausetime);
} catch (InterruptedException e) {}

// stop flushing now for one moment
flushThread.pause();
//serverLog.logDebug("PLASMA INDEXING", "addEntryToIndexMem: cache.size=" + cache.size() + "; hashScore.size=" + hashScore.size());

// put new words into cache
int added = 0;
String wordHash = container.wordHash();
synchronized (cache) {

synchronized (cache) {

// stop flushing now for one moment
flushThread.pause();

// put container into cache
plasmaWordIndexEntryContainer entries = (plasmaWordIndexEntryContainer) cache.get(wordHash); // null pointer exception? wordhash != null! must be cache==null
if (entries == null) entries = new plasmaWordIndexEntryContainer(wordHash);
added = entries.add(container);
Expand All @@ -502,9 +508,12 @@ public synchronized int addEntries(plasmaWordIndexEntryContainer container, long
hashDate.setScore(wordHash, intTime(updateTime));
}
entries = null;

// resume flushing
flushThread.proceed();
}
//System.out.println("DEBUG: cache = " + cache.toString());
flushThread.proceed();

return added;
}

Expand Down

0 comments on commit 10d3627

Please sign in to comment.