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 { public void add(ReferenceContainer<ReferenceType> newEntries) throws IOException {
this.ram.add(newEntries); this.ram.add(newEntries);
serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true); if (this.ram.size() % 100 == 0) {
cleanCache(); serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true);
cleanCache();
}
} }
public void add(byte[] termHash, ReferenceType entry) throws IOException { public void add(byte[] termHash, ReferenceType entry) throws IOException {
this.ram.add(termHash, entry); this.ram.add(termHash, entry);
serverProfiling.update("wordcache", Long.valueOf(this.ram.size()), true); if (this.ram.size() % 100 == 0) {
cleanCache(); 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() { private synchronized void cleanCache() {
// dump the cache if necessary // 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 { try {
cacheDump(); cacheDump();
} catch (IOException e) { } catch (IOException e) {

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

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

Loading…
Cancel
Save