Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
reduced internal logging and reduced memory that internal logging can use
orbiter9e4db75aace6
diff --git a/source/de/anomic/kelondro/text/IndexCell.java b/source/de/anomic/kelondro/text/IndexCell.javaindex e563d7037..187d5b891 100644--- a/source/de/anomic/kelondro/text/IndexCell.java+++ b/source/de/anomic/kelondro/text/IndexCell.java@@ -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 AbstractBuprivate 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) {diff --git a/source/de/anomic/kelondro/text/ReferenceContainerCache.java b/source/de/anomic/kelondro/text/ReferenceContainerCache.javaindex 2cdae11d6..b20a0aa61 100644--- a/source/de/anomic/kelondro/text/ReferenceContainerCache.java+++ b/source/de/anomic/kelondro/text/ReferenceContainerCache.java@@ -507,5 +507,5 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> extepublic ByteOrder ordering() {return this.termOrder;}-+}diff --git a/source/de/anomic/server/serverProfiling.java b/source/de/anomic/server/serverProfiling.javaindex bd63361a4..acc8ebb27 100644--- a/source/de/anomic/server/serverProfiling.java+++ b/source/de/anomic/server/serverProfiling.java@@ -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 accessedprivate 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>();