reduced internal logging and reduced memory that internal logging can use

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5867 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent c10c257255
commit 9e4db75aac

@ -98,14 +98,18 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
*/
public void add(ReferenceContainer<ReferenceType> newEntries) throws IOException {
this.ram.add(newEntries);
serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true);
cleanCache();
if (this.ram.size() % 100 == 0) {
serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true);
cleanCache();
}
}
public void add(byte[] termHash, ReferenceType entry) throws IOException {
this.ram.add(termHash, entry);
serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true);
cleanCache();
if (this.ram.size() % 100 == 0) {
serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true);
cleanCache();
}
}
/**
@ -272,7 +276,7 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
private synchronized void cleanCache() {
// dump the cache if necessary
if (this.ram.size() > this.maxRamEntries || (this.ram.size() > 2000 && !MemoryControl.request(100L * 1024L * 1024L, false))) {
if (this.ram.size() >= this.maxRamEntries || (this.ram.size() > 2000 && !MemoryControl.request(100L * 1024L * 1024L, false))) {
try {
cacheDump();
} catch (IOException e) {

@ -507,5 +507,5 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
public ByteOrder ordering() {
return this.termOrder;
}
}

@ -35,7 +35,7 @@ import de.anomic.kelondro.util.MemoryControl;
public class serverProfiling extends Thread {
private static final Map<String, ConcurrentLinkedQueue<Event>> historyMaps = new ConcurrentHashMap<String, ConcurrentLinkedQueue<Event>>(); // value=TreeMap of Long/Event
private static final Map<String, ConcurrentLinkedQueue<Event>> historyMaps = new ConcurrentHashMap<String, ConcurrentLinkedQueue<Event>>();
private static final Map<String, Long> eventAccess = new ConcurrentHashMap<String, Long>(); // value: last time when this was accessed
private static serverProfiling systemProfiler = null;
@ -73,8 +73,9 @@ public class serverProfiling extends Thread {
if (lastAcc == null) {
eventAccess.put(eventName, Long.valueOf(System.currentTimeMillis()));
} else {
if (!useProtection || System.currentTimeMillis() - lastAcc.longValue() > 1000) {
eventAccess.put(eventName, Long.valueOf(System.currentTimeMillis()));
long time = System.currentTimeMillis();
if (!useProtection || time - lastAcc.longValue() > 1000) {
eventAccess.put(eventName, Long.valueOf(time));
} else {
return; // protect against too heavy load
}
@ -86,12 +87,15 @@ public class serverProfiling extends Thread {
history.add(new Event(eventPayload));
// clean up too old entries
Event e;
final long now = System.currentTimeMillis();
while (history.size() > 0) {
e = history.peek();
if (now - e.time < 600000) break;
history.poll();
while (history.size() > 1000) history.poll();
if (history.size() % 10 == 0) { // reduce number of System.currentTimeMillis() calls
Event e;
final long now = System.currentTimeMillis();
while (history.size() > 0) {
e = history.peek();
if (now - e.time < 600000) break;
history.poll();
}
}
} else {
history = new ConcurrentLinkedQueue<Event>();

Loading…
Cancel
Save