- fixed a caching bug

- added counter for cache delete to distinguish between flush and delete
- changed some default paramenters for cache size settings

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2143 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent b48327904a
commit 24686e50a2

@ -91,11 +91,11 @@
<td class="small">Chunk Size<br>high/med/low<br>(bytes)</td>
<td class="small">Empty<br>(avail.)<br>Slots</td>
<td class="small">Used: High, Medium, Low Prio</td>
<td class="small">Node-Cache<br>Hit:Miss<br>Uniq:Doub<br>Flush<br></td>
<td class="small">Node-Cache<br>Hit:Miss<br>Uniq:Doub<br>Del:Flush<br></td>
<td class="small">&nbsp;<br>Size<br>Max</td>
<td class="small">&nbsp;<br>Size<br>Current</td>
<td class="small">Hit-Cache<br>Hit:Miss<br>Uniq:Doub<br>Flush<br></td>
<td class="small">Miss-Cache<br>Hit:Miss<br>Uniq:Doub<br>Flush<br></td>
<td class="small">Hit-Cache<br>Hit:Miss<br>Uniq:Doub<br>Del:Flush<br></td>
<td class="small">Miss-Cache<br>Hit:Miss<br>Uniq:Doub<br>Del:Flush<br></td>
<td class="small">Used Now</td>
<td class="small">Assigned Max</td>
<td class="small">Default Max</td>

@ -300,15 +300,15 @@ public class PerformanceMemory_p {
prop.put("sllow" + db, slt[3]);
prop.put("slhittmiss" + db, slt[4] + ":" + slt[5]);
prop.put("sluniqdoub" + db, slt[6] + ":" + slt[7]);
prop.put("slflush" + db, slt[8]);
prop.put("slflush" + db, slt[8] + ":" + slt[9]);
prop.put("ochunkmax" + db, ost[0]);
prop.put("ochunkcur" + db, ost[1]);
prop.put("ohittmiss" + db, ost[5] + ":" + ost[6]);
prop.put("ouniqdoub" + db, ost[7] + ":" + ost[8]);
prop.put("oflush" + db, ost[9]);
prop.put("nhittmiss" + db, ost[10] + ":" + ost[11]);
prop.put("nuniqdoub" + db, ost[12] + ":" + ost[13]);
prop.put("nflush" + db, ost[14]);
prop.put("oflush" + db, ost[9] + ":" + ost[10]);
prop.put("nhittmiss" + db, ost[11] + ":" + ost[12]);
prop.put("nuniqdoub" + db, ost[13] + ":" + ost[14]);
prop.put("nflush" + db, ost[15] + ":" + ost[16]);
prop.put("used" + db, usd / KB);
prop.put("good" + db, god / KB);
prop.put("best" + db, bst / KB);

@ -66,8 +66,8 @@ public class kelondroObjectCache {
private int maxSize;
private long maxAge;
private long minMem;
private int readHit, readMiss, writeUnique, writeDouble, cacheFlush;
private int hasnotHit, hasnotMiss, hasnotUnique, hasnotDouble, hasnotFlush;
private int readHit, readMiss, writeUnique, writeDouble, cacheDelete, cacheFlush;
private int hasnotHit, hasnotMiss, hasnotUnique, hasnotDouble, hasnotDelete, hasnotFlush;
private String name;
public kelondroObjectCache(String name, int maxSize, long maxAge, long minMem) {
@ -83,11 +83,13 @@ public class kelondroObjectCache {
this.readMiss = 0;
this.writeUnique = 0;
this.writeDouble = 0;
this.cacheDelete = 0;
this.cacheFlush = 0;
this.hasnotHit = 0;
this.hasnotMiss = 0;
this.hasnotUnique = 0;
this.hasnotDouble = 0;
this.hasnotDelete = 0;
this.hasnotFlush = 0;
}
@ -136,11 +138,13 @@ public class kelondroObjectCache {
Integer.toString(readMiss),
Integer.toString(writeUnique),
Integer.toString(writeDouble),
Integer.toString(cacheDelete),
Integer.toString(cacheFlush),
Integer.toString(hasnotHit),
Integer.toString(hasnotMiss),
Integer.toString(hasnotUnique),
Integer.toString(hasnotDouble),
Integer.toString(hasnotDelete),
Integer.toString(hasnotFlush)
};
}
@ -161,7 +165,9 @@ public class kelondroObjectCache {
Integer.toString(Integer.parseInt(a[11]) + Integer.parseInt(b[11])),
Integer.toString(Integer.parseInt(a[12]) + Integer.parseInt(b[12])),
Integer.toString(Integer.parseInt(a[13]) + Integer.parseInt(b[13])),
Integer.toString(Integer.parseInt(a[14]) + Integer.parseInt(b[14]))
Integer.toString(Integer.parseInt(a[14]) + Integer.parseInt(b[14])),
Integer.toString(Integer.parseInt(a[15]) + Integer.parseInt(b[15])),
Integer.toString(Integer.parseInt(a[16]) + Integer.parseInt(b[16]))
};
}
@ -190,7 +196,7 @@ public class kelondroObjectCache {
synchronized(cache) {
prev = cache.put(key, value);
ages.setScore(key, intTime(System.currentTimeMillis()));
hasnot.deleteScore(key);
if (hasnot.deleteScore(key) != 0) hasnotDelete++;
}
if (prev == null) this.writeUnique++; else this.writeDouble++;
flushc();
@ -205,10 +211,14 @@ public class kelondroObjectCache {
Object r = null;
synchronized(cache) {
r = cache.get(key);
ages.setScore(key, intTime(System.currentTimeMillis())); // renew cache update time
if (r == null) {
this.readMiss++;
} else {
this.readHit++;
ages.setScore(key, intTime(System.currentTimeMillis())); // renew cache update time
}
}
flushc();
if (r == null) this.readMiss++; else this.readHit++;
return r;
}
@ -220,7 +230,7 @@ public class kelondroObjectCache {
if (key == null) return;
int prev = 0;
synchronized(cache) {
cache.remove(key);
if (cache.remove(key) != null) cacheDelete++;
ages.deleteScore(key);
prev = hasnot.getScore(key);
hasnot.setScore(key, intTime(System.currentTimeMillis()));
@ -259,7 +269,7 @@ public class kelondroObjectCache {
public void remove(String key) {
if (key == null) return;
synchronized(cache) {
cache.remove(key);
if (cache.remove(key) != null) cacheDelete++;
ages.deleteScore(key);
hasnot.setScore(key, intTime(System.currentTimeMillis()));
}

@ -153,7 +153,7 @@ public class kelondroRecords {
private int cacheSize; // number of cache records
private long cacheStartup; // startup time; for cache aging
private kelondroMScoreCluster cacheScore; // controls cache aging
private int readHit, readMiss, writeUnique, writeDouble, cacheFlush;
private int readHit, readMiss, writeUnique, writeDouble, cacheDelete, cacheFlush;
// optional logger
protected Logger theLogger = null;
@ -443,6 +443,7 @@ public class kelondroRecords {
this.readMiss = 0;
this.writeUnique = 0;
this.writeDouble = 0;
this.cacheDelete = 0;
this.cacheFlush = 0;
}
@ -476,7 +477,7 @@ public class kelondroRecords {
}
public int[] cacheNodeStatus() {
if (cacheHeaders == null) return new int[]{0,0,0,0,0,0,0,0,0};
if (cacheHeaders == null) return new int[]{0,0,0,0,0,0,0,0,0,0};
return new int[]{
cacheSize,
cacheHeaders[CP_HIGH].size(),
@ -486,6 +487,7 @@ public class kelondroRecords {
readMiss,
writeUnique,
writeDouble,
cacheDelete,
cacheFlush
};
}
@ -533,7 +535,7 @@ public class kelondroRecords {
// no cache control for low-priority entries
cacheHeaders[CP_LOW].remove(handle);
}
cacheFlush++;
cacheDelete++;
}
}
dispose(handle);

@ -164,7 +164,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
if (objectCachePercent > 0) {
long objectbuffersize = objectCachePercent * buffersize / 100;
long nodecachesize = objectbuffersize / cacheObjectChunkSize();
this.objectCache = new kelondroObjectCache(this.filename, (int) nodecachesize, nodecachesize * 300 , 4*1024*1024);
this.objectCache = new kelondroObjectCache(this.filename, (int) nodecachesize, nodecachesize * 3000 , 2*1024*1024);
} else {
this.objectCache = null;
}

@ -499,10 +499,10 @@ xpstopw=true
ramCacheRWI = 8388608
# ram cache for responseHeader.db
ramCacheHTTP = 4194304
ramCacheHTTP = 1048576
# ram cache for urlHash.db
ramCacheLURL = 4194304
ramCacheLURL = 8388608
# ram cache for urlNotice.db
ramCacheNURL = 4194304
@ -511,7 +511,7 @@ ramCacheNURL = 4194304
ramCacheEURL = 8192
# ram cache for seedDBs
ramCacheDHT = 8192
ramCacheDHT = 131072
# ram cache for message.db
ramCacheMessage = 8192
@ -523,10 +523,10 @@ ramCacheWiki = 8192
ramCacheBlog = 2048
# ram cache for news1.db
ramCacheNews = 8192
ramCacheNews = 1048576
# ram cache for robotsTxt.db
ramCacheRobots = 2097152
ramCacheRobots = 4194304
# ram cache for crawlProfile.db
ramCacheProfiles = 8192

Loading…
Cancel
Save